[libcxx] r224658 - Move test into test/std subdirectory.
Eric Fiselier
eric at efcs.ca
Fri Dec 19 17:40:31 PST 2014
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class InputIterator>
+// piecewise_constant_distribution(InputIteratorB firstB,
+// InputIteratorB lastB,
+// InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10};
+ double p[] = {12};
+ D d(b, b, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10};
+ double p[] = {12};
+ D d(b, b+1, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 15};
+ double p[] = {12};
+ D d(b, b+2, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1/5.);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 15, 16};
+ double p[] = {.25, .75};
+ D d(b, b+3, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ assert(iv[2] == 16);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == .25/5.);
+ assert(dn[1] == .75);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ D d(b, b+4, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .0625);
+ assert(dn[1] == .3125);
+ assert(dn[2] == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// explicit piecewise_constant_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P pa(b, b+4, p);
+ D d(pa);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .0625);
+ assert(dn[1] == .3125);
+ assert(dn[2] == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// bool operator=(const piecewise_constant_distribution& x,
+// const piecewise_constant_distribution& y);
+// bool operator!(const piecewise_constant_distribution& x,
+// const piecewise_constant_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d1;
+ D d2;
+ assert(d1 == d2);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ D d1(b, b+4, p);
+ D d2(b, b+4, p);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ D d1(b, b+4, p);
+ D d2;
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,695 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 0, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 0, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 25, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 0, 1};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16};
+ double p[] = {75, 25};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16};
+ double p[] = {0, 25};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16};
+ double p[] = {1, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14};
+ double p[] = {1};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d;
+ P pa(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, pa);
+ assert(10 <= v && v < 17);
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P pa(b, b+Np+1, p);
+ D d(pa);
+ assert(d.param() == pa);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const piecewise_constant_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// piecewise_constant_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d1(b, b+Np+1, p);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ assert(d.max() == 17);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ assert(d.min() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P p0(b, b+Np+1, p);
+ P p1;
+ p1 = p0;
+ assert(p1 == p0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P p0(b, b+Np+1, p);
+ P p1 = p0;
+ assert(p1 == p0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// param_type();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa;
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class UnaryOperation>
+// param_type(size_t nw, double xmin, double xmax,
+// UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return 2*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa(0, 0, 1, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa(1, 10, 12, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 0.5);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa(2, 6, 14, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0.1);
+ assert(dn[1] == 0.15);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// param_type(initializer_list<result_type> bl, UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+ return x*2;
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({12}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({12, 14}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 12);
+ assert(iv[1] == 14);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 0.5);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({5.5, 7.5, 11.5}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 5.5);
+ assert(iv[1] == 7.5);
+ assert(iv[2] == 11.5);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0.203125);
+ assert(dn[1] == 0.1484375);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class InputIterator>
+// param_type(InputIteratorB firstB, InputIteratorB lastB,
+// InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10};
+ double p[] = {12};
+ P pa(b, b, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10};
+ double p[] = {12};
+ P pa(b, b+1, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 15};
+ double p[] = {12};
+ P pa(b, b+2, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1/5.);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 15, 16};
+ double p[] = {.25, .75};
+ P pa(b, b+3, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ assert(iv[2] == 16);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == .25/5.);
+ assert(dn[1] == .75);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P pa(b, b+4, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .0625);
+ assert(dn[1] == .3125);
+ assert(dn[2] == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P p1(b, b+4, p);
+ P p2(b, b+4, p);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P p1(b, b+3, p);
+ P p2(b, b+4, p);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P pa(b, b+4, p);
+ D d;
+ d.param(pa);
+ assert(d.param() == pa);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::piecewise_constant_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution& operator=(const piecewise_linear_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::piecewise_linear_distribution<> D;
+ double p[] = {2, 4, 1, 8, 3};
+ double b[] = {2, 4, 5, 8, 9};
+ D d1(b, b+5, p);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution(const piecewise_linear_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::piecewise_linear_distribution<> D;
+ double p[] = {2, 4, 1, 8, 2};
+ double b[] = {2, 4, 5, 8, 9};
+ D d1(b, b+5, p);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d;
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class UnaryOperation>
+// piecewise_linear_distribution(size_t nw, result_type xmin,
+// result_type xmax, UnaryOperation fw);
+
+#include <iostream>
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return 2*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d(0, 0, 1, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0);
+ assert(dn[1] == 2);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d(1, 10, 12, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 20./44);
+ assert(dn[1] == 24./44);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d(2, 6, 14, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == 0.075);
+ assert(dn[1] == 0.125);
+ assert(dn[2] == 0.175);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution(initializer_list<result_type> bl,
+// UnaryOperation fw);
+
+#include <iostream>
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+ return x*2;
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d({}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d({12}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d({10, 12}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 20./44);
+ assert(dn[1] == 24./44);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d({6, 10, 14}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == 0.075);
+ assert(dn[1] == 0.125);
+ assert(dn[2] == 0.175);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class InputIterator>
+// piecewise_linear_distribution(InputIteratorB firstB,
+// InputIteratorB lastB,
+// InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10};
+ double p[] = {12};
+ D d(b, b, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10};
+ double p[] = {12};
+ D d(b, b+1, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 15};
+ double p[] = {20, 20};
+ D d(b, b+2, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1/5.);
+ assert(dn[1] == 1/5.);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 15, 16};
+ double p[] = {.25, .75, .25};
+ D d(b, b+3, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ assert(iv[2] == 16);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .25/3);
+ assert(dn[1] == .75/3);
+ assert(dn[2] == .25/3);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 1, 1, 0};
+ D d(b, b+4, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 4);
+ assert(dn[0] == 0);
+ assert(dn[1] == 1/4.5);
+ assert(dn[2] == 1/4.5);
+ assert(dn[3] == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// explicit piecewise_linear_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ P pa(b, b+4, p);
+ D d(pa);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 4);
+ assert(dn[0] == 25/256.25);
+ assert(dn[1] == 62.5/256.25);
+ assert(dn[2] == 12.5/256.25);
+ assert(dn[3] == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// bool operator=(const piecewise_linear_distribution& x,
+// const piecewise_linear_distribution& y);
+// bool operator!(const piecewise_linear_distribution& x,
+// const piecewise_linear_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d1;
+ D d2;
+ assert(d1 == d2);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 1};
+ D d1(b, b+4, p);
+ D d2(b, b+4, p);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ D d1(b, b+4, p);
+ D d2;
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,343 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <iostream>
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x*x;
+}
+
+double
+f(double x, double a, double m, double b, double c)
+{
+ return a + m*(sqr(x) - sqr(b))/2 + c*(x-b);
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 1, 1, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 0, 1, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {1, 0, 0, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16};
+ double p[] = {0, 1, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14};
+ double p[] = {1, 1};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x*x;
+}
+
+double
+f(double x, double a, double m, double b, double c)
+{
+ return a + m*(sqr(x) - sqr(b))/2 + c*(x-b);
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d;
+ P pa(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, pa);
+ assert(10 <= v && v < 17);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 10};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P pa(b, b+Np, p);
+ D d(pa);
+ assert(d.param() == pa);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const piecewise_linear_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// piecewise_linear_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 25};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d1(b, b+Np, p);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np, p);
+ assert(d.max() == 17);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np, p);
+ assert(d.min() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 2};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P p0(b, b+Np, p);
+ P p1;
+ p1 = p0;
+ assert(p1 == p0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P p0(b, b+Np, p);
+ P p1 = p0;
+ assert(p1 == p0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// param_type();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa;
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class UnaryOperation>
+// param_type(size_t nw, double xmin, double xmax,
+// UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return 2*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa(0, 0, 1, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0);
+ assert(dn[1] == 2);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa(1, 10, 12, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 20./44);
+ assert(dn[1] == 24./44);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa(2, 6, 14, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == 0.075);
+ assert(dn[1] == 0.125);
+ assert(dn[2] == 0.175);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// param_type(initializer_list<result_type> bl, UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+ return x*2;
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa({}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa({12}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa({10, 12}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 20./44);
+ assert(dn[1] == 24./44);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa({6, 10, 14}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == 0.075);
+ assert(dn[1] == 0.125);
+ assert(dn[2] == 0.175);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class InputIterator>
+// param_type(InputIteratorB firstB, InputIteratorB lastB,
+// InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10};
+ double p[] = {12};
+ P pa(b, b, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10};
+ double p[] = {12};
+ P pa(b, b+1, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 15};
+ double p[] = {12, 12};
+ P pa(b, b+2, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1/5.);
+ assert(dn[1] == 1/5.);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 15, 16};
+ double p[] = {.25, .75, .25};
+ P pa(b, b+3, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ assert(iv[2] == 16);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .25/3);
+ assert(dn[1] == .75/3);
+ assert(dn[2] == .25/3);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 1, 1, 0};
+ P pa(b, b+4, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 4);
+ assert(dn[0] == 0);
+ assert(dn[1] == 1/4.5);
+ assert(dn[2] == 1/4.5);
+ assert(dn[3] == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ P p1(b, b+4, p);
+ P p2(b, b+4, p);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ P p1(b, b+3, p);
+ P p2(b, b+4, p);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ P pa(b, b+4, p);
+ D d;
+ d.param(pa);
+ assert(d.param() == pa);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::piecewise_linear_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,455 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::minstd_rand0 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::ranlux24_base G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::ranlux48_base G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::ranlux24 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::ranlux48 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::knuth_b G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ 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);
+ }
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5, 100);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::minstd_rand G;
+ typedef D::param_type P;
+ G g;
+ D d(5, 100);
+ P p(-10, 20);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(p.a() <= v && v <= p.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)p.a() + p.b()) / 2;
+ double x_var = (sqr((double)p.b() - p.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)p.b() - p.a() + 1) + 1) /
+ (5. * (sqr((double)p.b() - p.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,474 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::minstd_rand0 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::ranlux24_base G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.02);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::ranlux48_base G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::ranlux24 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::ranlux48 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::knuth_b G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(-1, 1);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs(mean - x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5.5, 25);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::minstd_rand G;
+ typedef D::param_type P;
+ G g;
+ D d(5.5, 25);
+ P p(-10, 20);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(p.a() <= v && v < p.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (p.a() + p.b()) / 2;
+ D::result_type x_var = sqr(p.b() - p.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+ }
+ {
+ unsigned a[] = {3, 5, 7, 9, 11};
+ std::seed_seq sseq(a, a+5);
+ typedef std::linear_congruential_engine<unsigned long long, 1, 1, 0x200000001ULL> E;
+ E e1(4309005589);
+ E e2(sseq);
+ assert(e1 == e2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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 _Tp>
+void where(const _Tp &) {}
+
+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), "");
+ where(LCE::multiplier);
+ where(LCE::increment);
+ where(LCE::modulus);
+ where(LCE::default_seed);
+}
+
+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>();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,245 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,309 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+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), "");
+ where(E::word_size);
+ where(E::state_size);
+ where(E::shift_size);
+ where(E::mask_bits);
+ where(E::xor_mask);
+ where(E::tempering_u);
+ where(E::tempering_d);
+ where(E::tempering_s);
+ where(E::tempering_b);
+ where(E::tempering_t);
+ where(E::tempering_c);
+ where(E::tempering_l);
+ where(E::initialization_multiplier);
+ where(E::default_seed);
+}
+
+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), "");
+ where(E::word_size);
+ where(E::state_size);
+ where(E::shift_size);
+ where(E::mask_bits);
+ where(E::xor_mask);
+ where(E::tempering_u);
+ where(E::tempering_d);
+ where(E::tempering_s);
+ where(E::tempering_b);
+ where(E::tempering_t);
+ where(E::tempering_c);
+ where(E::tempering_l);
+ where(E::initialization_multiplier);
+ where(E::default_seed);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+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), "");
+ where(E::word_size);
+ where(E::short_lag);
+ where(E::long_lag);
+ where(E::default_seed);
+}
+
+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), "");
+ where(E::word_size);
+ where(E::short_lag);
+ where(E::long_lag);
+ where(E::default_seed);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef minstd_rand0 default_random_engine;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::default_random_engine e;
+ e.discard(9999);
+ assert(e() == 399268537u);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.predef/knuth_b.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/knuth_b.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.predef/knuth_b.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.predef/knuth_b.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.predef/minstd_rand.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/minstd_rand.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.predef/minstd_rand.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.predef/minstd_rand.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.predef/minstd_rand0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/minstd_rand0.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.predef/minstd_rand0.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.predef/minstd_rand0.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.predef/mt19937.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/mt19937.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.predef/mt19937.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.predef/mt19937.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.predef/mt19937_64.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/mt19937_64.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.predef/mt19937_64.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.predef/mt19937_64.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux24.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux24.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux24.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux24.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux24_base.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux24_base.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux24_base.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux24_base.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux48.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux48.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux48.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux48.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux48_base.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux48_base.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux48_base.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.predef/ranlux48_base.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.req/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.req/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.req/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.req/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.synopsis/version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.synopsis/version.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.synopsis/version.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.synopsis/version.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+#include <random>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.util/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.util/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.util/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.util/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType, size_t bits, class URNG>
+// RealType generate_canonical(URNG& g);
+
+#include <random>
+#include <cassert>
+
+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))));
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+
+int main()
+{
+ std::seed_seq s0;
+ std::seed_seq s;
+ s = s0;
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+
+int main()
+{
+ std::seed_seq s0;
+ std::seed_seq s(s0);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::seed_seq s;
+ assert(s.size() == 0);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,805 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// template<class T>
+// seed_seq(initializer_list<T> il);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ 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 // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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);
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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), "");
+}
Added: libcxx/trunk/test/std/re/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.alg/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,1389 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT,
+// class traits>
+// bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags
+// = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+/* {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_match(s, m, std::regex("-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+*/ {
+ std::cmatch m;
+ const char s[] = "m";
+ /* assert(std::regex_match(s, m,*/ std::regex("[a[=M=]z]"/*,
+ std::regex_constants::awk*/);//));
+/* assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+*/ }
+/* {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "\n\n\n";
+ assert(std::regex_match(s, m, std::regex("[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"\n\n\n";
+ assert(std::regex_match(s, m, std::wregex(L"[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+*/}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.fail.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class ST, class SA, class Allocator, class charT, class traits>
+// bool regex_match(const basic_string<charT, ST, SA>&&,
+// match_results<
+// typename basic_string<charT, ST, SA>::const_iterator,
+// Allocator>&,
+// const basic_regex<charT, traits>&,
+// regex_constants::match_flag_type =
+// regex_constants::match_default) = delete;
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::smatch m;
+ std::regex re{"*"};
+ std::regex_match(std::string("abcde"), m, re);
+ }
+}
+#endif
Added: libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,1366 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ assert(!std::regex_match("a", m, std::regex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbabb";
+ assert(std::regex_match(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbab";
+ assert(!std::regex_match(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(std::regex_match(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "Abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(!std::regex_match(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ assert(!std::regex_match(L"a", m, std::wregex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbabb";
+ assert(std::regex_match(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbab";
+ assert(!std::regex_match(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(std::regex_match(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"Abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(!std::regex_match(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/ecma.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/ecma.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/ecma.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,1348 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("(a*)*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(!std::regex_match(s, m, std::regex("tour|to|tournament")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(!std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_match(s, m, std::regex("-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "foobar";
+ assert(std::regex_match(s, m, std::regex("[^\\0]*")));
+ assert(m.size() == 1);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "foo\0bar";
+ assert(std::regex_match(s, s+7, m, std::regex("[abfor\\0]*")));
+ assert(m.size() == 1);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]+")));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeff Jeffs ";
+ assert(!std::regex_match(s, m, std::regex("Jeff(?=s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeffs Jeff";
+ assert(!std::regex_match(s, m, std::regex("Jeff(?!s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "5%k";
+ assert(std::regex_match(s, m, std::regex("\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"(a*)*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(!std::regex_match(s, m, std::wregex(L"tour|to|tournament")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(!std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+")));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeff Jeffs ";
+ assert(!std::regex_match(s, m, std::wregex(L"Jeff(?=s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeffs Jeff";
+ assert(!std::regex_match(s, m, std::wregex(L"Jeff(?!s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"5%k";
+ assert(std::regex_match(s, m, std::wregex(L"\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.match/egrep.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/egrep.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/egrep.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/egrep.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(!std::regex_match(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tourna";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tourna");
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.match/extended.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/extended.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/extended.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/extended.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,1362 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_match(s, m, std::regex("-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.match/grep.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/grep.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/grep.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/grep.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(!std::regex_match(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 0);
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// std::regex in ECMAScript mode should not ignore capture groups inside lookahead assertions.
+// For example, matching /(?=(a))(a)/ to "a" should yield two captures: \1 = "a", \2 = "a"
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::regex re("^(?=(.))a$");
+ assert(re.mark_count() == 1);
+
+ std::string s("a");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 2);
+ assert(m[0] == "a");
+ assert(m[1] == "a");
+ }
+
+ {
+ std::regex re("^(a)(?=(.))(b)$");
+ assert(re.mark_count() == 3);
+
+ std::string s("ab");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 4);
+ assert(m[0] == "ab");
+ assert(m[1] == "a");
+ assert(m[2] == "b");
+ assert(m[3] == "b");
+ }
+
+ {
+ std::regex re("^(.)(?=(.)(?=.(.)))(...)$");
+ assert(re.mark_count() == 4);
+
+ std::string s("abcd");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 5);
+ assert(m[0] == "abcd");
+ assert(m[1] == "a");
+ assert(m[2] == "b");
+ assert(m[3] == "d");
+ assert(m[4] == "bcd");
+ }
+
+ {
+ std::regex re("^(a)(?!([^b]))(.c)$");
+ assert(re.mark_count() == 3);
+
+ std::string s("abc");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 4);
+ assert(m[0] == "abc");
+ assert(m[1] == "a");
+ assert(m[2] == "");
+ assert(m[3] == "bc");
+ }
+
+ {
+ std::regex re("^(?!((b)))(?=(.))(?!(abc)).b$");
+ assert(re.mark_count() == 4);
+
+ std::string s("ab");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 5);
+ assert(m[0] == "ab");
+ assert(m[1] == "");
+ assert(m[2] == "");
+ assert(m[3] == "a");
+ assert(m[4] == "");
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16135
+
+#include <string>
+#include <regex>
+#include <cassert>
+
+void
+test1()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test2()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re, std::regex::extended);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test3()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re, std::regex::awk);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test4()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re, std::regex::egrep);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+int
+main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.replace/test1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.replace/test1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.replace/test1.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.replace/test1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class OutputIterator, class BidirectionalIterator,
+// class traits, class charT, class ST, class SA>
+// OutputIterator
+// regex_replace(OutputIterator out,
+// BidirectionalIterator first, BidirectionalIterator last,
+// const basic_regex<charT, traits>& e,
+// const basic_string<charT, ST, SA>& fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"));
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+43);
+ assert(buf == std::string("123-$555-1234, 123-$555-2345, 123-$555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-&"),
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+36);
+ assert(buf == std::string("123-555-1234123-555-2345123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only);
+ assert(r.base() == buf+32);
+ assert(buf == std::string("123-555-1234, 555-2345, 555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+12);
+ assert(buf == std::string("123-555-1234"));
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.replace/test2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.replace/test2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.replace/test2.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.replace/test2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class OutputIterator, class BidirectionalIterator,
+// class traits, class charT, class ST, class SA>
+// OutputIterator
+// regex_replace(OutputIterator out,
+// BidirectionalIterator first, BidirectionalIterator last,
+// const basic_regex<charT, traits>& e,
+// const charT* fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&");
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+43);
+ assert(buf == std::string("123-$555-1234, 123-$555-2345, 123-$555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-&",
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+36);
+ assert(buf == std::string("123-555-1234123-555-2345123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only);
+ assert(r.base() == buf+32);
+ assert(buf == std::string("123-555-1234, 555-2345, 555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+12);
+ assert(buf == std::string("123-555-1234"));
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.replace/test3.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.replace/test3.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.replace/test3.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.replace/test3.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT, class ST, class SA, class FST, class FSA>>
+// basic_string<charT, ST, SA>
+// regex_replace(const basic_string<charT, ST, SA>& s,
+// const basic_regex<charT, traits>& e,
+// const basic_string<charT, FST, FSA>& fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"));
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.replace/test4.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.replace/test4.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.replace/test4.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.replace/test4.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT, class ST, class SA>
+// basic_string<charT, ST, SA>
+// regex_replace(const basic_string<charT, ST, SA>& s,
+// const basic_regex<charT, traits>& e, const charT* fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&");
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-&",
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.replace/test5.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.replace/test5.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.replace/test5.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.replace/test5.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT, class ST, class SA>
+// basic_string<charT>
+// regex_replace(const charT* s,
+// const basic_regex<charT, traits>& e,
+// const basic_string<charT, ST, SA>& fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"));
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.replace/test6.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.replace/test6.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.replace/test6.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.replace/test6.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT>
+// basic_string<charT>
+// regex_replace(const charT* s,
+// const basic_regex<charT, traits>& e,
+// const charT* fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&");
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-&",
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.search/awk.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/awk.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/awk.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/awk.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,1573 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_search(s, m, std::regex("-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "\n\n\n";
+ assert(std::regex_search(s, m, std::regex("[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"\n\n\n";
+ assert(std::regex_search(s, m, std::wregex(L"[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.search/backup.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/backup.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/backup.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/backup.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <string>
+#include <list>
+#include <cassert>
+
+int main()
+{
+ // This regex_iterator uses regex_search(__wrap_iter<_Iter> __first, ...)
+ // Test for http://llvm.org/bugs/show_bug.cgi?id=16240 fixed in r185273.
+ {
+ std::string s("aaaa a");
+ std::regex re("\\ba");
+ std::sregex_iterator it(s.begin(), s.end(), re);
+ std::sregex_iterator end = std::sregex_iterator();
+
+ assert(it->position(0) == 0);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it->position(0) == 5);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it == end);
+ }
+
+ // This regex_iterator uses regex_search(_BidirectionalIterator __first, ...)
+ {
+ std::string s("aaaa a");
+ std::list<char> l(s.begin(), s.end());
+ std::regex re("\\ba");
+ std::regex_iterator<std::list<char>::iterator> it(l.begin(), l.end(), re);
+ std::regex_iterator<std::list<char>::iterator> end = std::regex_iterator<std::list<char>::iterator>();
+
+ assert(it->position(0) == 0);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it->position(0) == 5);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it == end);
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.fail.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class ST, class SA, class Allocator, class charT, class traits>
+// bool regex_search(const basic_string<charT, ST, SA>&&,
+// match_results<
+// typename basic_string<charT, ST, SA>::const_iterator,
+// Allocator>&,
+// const basic_regex<charT, traits>&,
+// regex_constants::match_flag_type =
+// regex_constants::match_default) = delete;
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::smatch m;
+ std::regex re{"*"};
+ std::regex_search(std::string("abcde"), m, re);
+ }
+}
+#endif
Added: libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,1546 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ assert(!std::regex_search("a", m, std::regex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbabb";
+ assert(std::regex_search(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbab";
+ assert(!std::regex_search(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(std::regex_search(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "Abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(!std::regex_search(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ assert(!std::regex_search(L"a", m, std::wregex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbabb";
+ assert(std::regex_search(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbab";
+ assert(!std::regex_search(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(std::regex_search(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"Abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(!std::regex_search(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.search/ecma.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/ecma.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/ecma.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/ecma.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,1588 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("(a*)*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour|to|tournament")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_search(s, m, std::regex("-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]+")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeff Jeffs ";
+ assert(std::regex_search(s, m, std::regex("Jeff(?=s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 5);
+ assert(m.str(0) == "Jeff");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeffs Jeff";
+ assert(std::regex_search(s, m, std::regex("Jeff(?!s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 6);
+ assert(m.str(0) == "Jeff");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "5%k";
+ assert(std::regex_search(s, m, std::regex("\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"(a*)*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeff Jeffs ";
+ assert(std::regex_search(s, m, std::wregex(L"Jeff(?=s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 5);
+ assert(m.str(0) == L"Jeff");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeffs Jeff";
+ assert(std::regex_search(s, m, std::wregex(L"Jeff(?!s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 6);
+ assert(m.str(0) == L"Jeff");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"5%k";
+ assert(std::regex_search(s, m, std::wregex(L"\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.search/egrep.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/egrep.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/egrep.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/egrep.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(std::regex_search(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tourna";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tourna");
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.search/extended.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/extended.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/extended.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/extended.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,1542 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_search(s, m, std::regex("-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(std::regex_search(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// http://llvm.org/bugs/show_bug.cgi?id=11118
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(!std::regex_search("ab", std::regex("(?=^)b")));
+ assert(!std::regex_search("ab", std::regex("a(?=^)b")));
+}
Added: libcxx/trunk/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ // Iterating over /^a/ should yield one instance at the beginning
+ // of the text.
+
+ const char *text = "aaa\naa";
+ std::regex re("^a");
+ std::cregex_iterator it(text, text+6, re);
+ std::cregex_iterator end = std::cregex_iterator();
+
+ assert(it->str() == "a");
+ assert(it->position(0) == 0);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it == end);
+}
Added: libcxx/trunk/test/std/re/re.alg/re.except/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.except/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.alg/re.except/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.alg/re.except/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.badexp/regex_error.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.badexp/regex_error.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.badexp/regex_error.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.badexp/regex_error.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,96 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_error
+// : public runtime_error
+// {
+// public:
+// explicit regex_error(regex_constants::error_type ecode);
+// regex_constants::error_type code() const;
+// };
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex_error e(std::regex_constants::error_collate);
+ assert(e.code() == std::regex_constants::error_collate);
+ assert(e.what() == std::string("The expression contained an invalid collating element name."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_ctype);
+ assert(e.code() == std::regex_constants::error_ctype);
+ assert(e.what() == std::string("The expression contained an invalid character class name."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_escape);
+ assert(e.code() == std::regex_constants::error_escape);
+ assert(e.what() == std::string("The expression contained an invalid escaped character, or a "
+ "trailing escape."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_backref);
+ assert(e.code() == std::regex_constants::error_backref);
+ assert(e.what() == std::string("The expression contained an invalid back reference."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_brack);
+ assert(e.code() == std::regex_constants::error_brack);
+ assert(e.what() == std::string("The expression contained mismatched [ and ]."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_paren);
+ assert(e.code() == std::regex_constants::error_paren);
+ assert(e.what() == std::string("The expression contained mismatched ( and )."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_brace);
+ assert(e.code() == std::regex_constants::error_brace);
+ assert(e.what() == std::string("The expression contained mismatched { and }."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_badbrace);
+ assert(e.code() == std::regex_constants::error_badbrace);
+ assert(e.what() == std::string("The expression contained an invalid range in a {} expression."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_range);
+ assert(e.code() == std::regex_constants::error_range);
+ assert(e.what() == std::string("The expression contained an invalid character range, "
+ "such as [b-a] in most encodings."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_space);
+ assert(e.code() == std::regex_constants::error_space);
+ assert(e.what() == std::string("There was insufficient memory to convert the expression into "
+ "a finite state machine."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_badrepeat);
+ assert(e.code() == std::regex_constants::error_badrepeat);
+ assert(e.what() == std::string("One of *?+{ was not preceded by a valid regular expression."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_complexity);
+ assert(e.code() == std::regex_constants::error_complexity);
+ assert(e.what() == std::string("The complexity of an attempted match against a regular "
+ "expression exceeded a pre-set level."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_stack);
+ assert(e.code() == std::regex_constants::error_stack);
+ assert(e.what() == std::string("There was insufficient memory to determine whether the regular "
+ "expression could match the specified character sequence."));
+ }
+}
Added: libcxx/trunk/test/std/re/re.const/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.const/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.const/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.const/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.const/re.err/error_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.const/re.err/error_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.const/re.err/error_type.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.const/re.err/error_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,143 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// namespace regex_constants
+// {
+//
+// enum error_type
+// {
+// error_collate = unspecified,
+// error_ctype = unspecified,
+// error_escape = unspecified,
+// error_backref = unspecified,
+// error_brack = unspecified,
+// error_paren = unspecified,
+// error_brace = unspecified,
+// error_badbrace = unspecified,
+// error_range = unspecified,
+// error_space = unspecified,
+// error_badrepeat = unspecified,
+// error_complexity = unspecified,
+// error_stack = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(std::regex_constants::error_collate != 0);
+ assert(std::regex_constants::error_ctype != 0);
+ assert(std::regex_constants::error_escape != 0);
+ assert(std::regex_constants::error_backref != 0);
+ assert(std::regex_constants::error_brack != 0);
+ assert(std::regex_constants::error_paren != 0);
+ assert(std::regex_constants::error_brace != 0);
+ assert(std::regex_constants::error_badbrace != 0);
+ assert(std::regex_constants::error_range != 0);
+ assert(std::regex_constants::error_space != 0);
+ assert(std::regex_constants::error_badrepeat != 0);
+ assert(std::regex_constants::error_complexity != 0);
+ assert(std::regex_constants::error_stack != 0);
+
+ assert(std::regex_constants::error_collate != std::regex_constants::error_ctype);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_escape);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_backref);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_range);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_space);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_escape);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_backref);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_range);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_space);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_escape != std::regex_constants::error_backref);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_range);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_space);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_backref != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_range);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_space);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_brack != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_range);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_space);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_paren != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_range);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_space);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_brace != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_range);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_space);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_range);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_space);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_range != std::regex_constants::error_space);
+ assert(std::regex_constants::error_range != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_range != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_range != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_space != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_space != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_space != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_badrepeat != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_badrepeat != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_complexity != std::regex_constants::error_stack);
+}
Added: libcxx/trunk/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,128 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// namespace regex_constants
+// {
+//
+// emum match_flag_type // bitmask type
+// {
+// match_default = 0,
+// match_not_bol = unspecified,
+// match_not_eol = unspecified,
+// match_not_bow = unspecified,
+// match_not_eow = unspecified,
+// match_any = unspecified,
+// match_not_null = unspecified,
+// match_continuous = unspecified,
+// match_prev_avail = unspecified,
+// format_default = 0,
+// format_sed = unspecified,
+// format_no_copy = unspecified,
+// format_first_only = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(std::regex_constants::match_default == 0);
+ assert(std::regex_constants::match_not_bol != 0);
+ assert(std::regex_constants::match_not_eol != 0);
+ assert(std::regex_constants::match_not_bow != 0);
+ assert(std::regex_constants::match_not_eow != 0);
+ assert(std::regex_constants::match_any != 0);
+ assert(std::regex_constants::match_not_null != 0);
+ assert(std::regex_constants::match_continuous != 0);
+ assert(std::regex_constants::match_prev_avail != 0);
+ assert(std::regex_constants::format_default == 0);
+ assert(std::regex_constants::format_sed != 0);
+ assert(std::regex_constants::format_no_copy != 0);
+ assert(std::regex_constants::format_first_only != 0);
+
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_eol) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_bow) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_eow) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_bow) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_eow) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_not_eow) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_any & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_null & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_continuous & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_continuous & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_continuous & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_continuous & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_prev_avail & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_prev_avail & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_prev_avail & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::format_sed & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::format_sed & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::format_no_copy & std::regex_constants::format_first_only) == 0);
+
+ std::regex_constants::match_flag_type e1 = std::regex_constants::match_not_bol;
+ std::regex_constants::match_flag_type e2 = std::regex_constants::match_not_eol;
+ e1 = ~e1;
+ e1 = e1 & e2;
+ e1 = e1 | e2;
+ e1 = e1 ^ e2;
+ e1 &= e2;
+ e1 |= e2;
+ e1 ^= e2;
+}
Added: libcxx/trunk/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,114 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// namespace regex_constants
+// {
+//
+// emum syntax_option_type // bitmask type
+// {
+// icase = unspecified,
+// nosubs = unspecified,
+// optimize = unspecified,
+// collate = unspecified,
+// ECMAScript = unspecified,
+// basic = unspecified,
+// extended = unspecified,
+// awk = unspecified,
+// grep = unspecified,
+// egrep = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(std::regex_constants::icase != 0);
+ assert(std::regex_constants::nosubs != 0);
+ assert(std::regex_constants::optimize != 0);
+ assert(std::regex_constants::collate != 0);
+ assert(std::regex_constants::ECMAScript == 0);
+ assert(std::regex_constants::basic != 0);
+ assert(std::regex_constants::extended != 0);
+ assert(std::regex_constants::awk != 0);
+ assert(std::regex_constants::grep != 0);
+ assert(std::regex_constants::egrep != 0);
+
+ assert((std::regex_constants::icase & std::regex_constants::nosubs) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::optimize) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::collate) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::nosubs & std::regex_constants::optimize) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::collate) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::optimize & std::regex_constants::collate) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::collate & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::ECMAScript & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::basic & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::basic & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::basic & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::basic & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::extended & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::extended & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::extended & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::awk & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::awk & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::grep & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::icase | std::regex_constants::nosubs) != 0);
+ assert((std::regex_constants::icase ^ std::regex_constants::nosubs) != 0);
+
+ std::regex_constants::syntax_option_type e1 = std::regex_constants::icase;
+ std::regex_constants::syntax_option_type e2 = std::regex_constants::nosubs;
+ e1 = ~e1;
+ e1 = e1 & e2;
+ e1 = e1 | e2;
+ e1 = e1 ^ e2;
+ e1 &= e2;
+ e1 |= e2;
+ e1 ^= e2;
+}
Added: libcxx/trunk/test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.def/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.def/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.def/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.def/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.general/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.general/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.general/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.general/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.grammar/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.grammar/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.grammar/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.grammar/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.iter/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// int submatch = 0,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default) = delete;
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(
+ std::begin(phone_book), std::end(phone_book),
+ std::regex("\\d{3}-\\d{4}"));
+ }
+}
+#endif
Added: libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// regex_constants::match_flag_type m = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 0);
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 10);
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 20);
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_iterator());
+ }
+}
Added: libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_iterator<const CharT*> I;
+ I i1;
+ assert(i1 == I());
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
Added: libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// bool operator==(const regex_iterator& right) const;
+// bool operator!=(const regex_iterator& right) const;
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// const value_type& operator*() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 0);
+ assert((*i).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 10);
+ assert((*i).str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 20);
+ assert((*i).str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_iterator());
+ }
+}
Added: libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator operator++(int);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ std::cregex_iterator i2 = i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 0);
+ assert((*i).str() == "555-1234");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ i++;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 10);
+ assert((*i).str() == "555-2345");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ i++;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 20);
+ assert((*i).str() == "555-3456");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ i++;
+ assert(i == std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ std::cregex_iterator i2 = i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 0);
+ assert((*i).str() == "555-1234");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 10);
+ assert((*i).str() == "555-2345");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 20);
+ assert((*i).str() == "555-3456");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ ++i;
+ assert(i == std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ }
+}
Added: libcxx/trunk/test/std/re/re.iter/re.regiter/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.regiter/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.regiter/types.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.regiter/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator,
+// class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+// class traits = regex_traits<charT>>
+// class regex_iterator
+// {
+// public:
+// typedef basic_regex<charT, traits> regex_type;
+// typedef match_results<BidirectionalIterator> value_type;
+// typedef ptrdiff_t difference_type;
+// typedef const value_type* pointer;
+// typedef const value_type& reference;
+// typedef forward_iterator_tag iterator_category;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_iterator<const CharT*> I;
+ static_assert((std::is_same<typename I::regex_type, std::basic_regex<CharT> >::value), "");
+ static_assert((std::is_same<typename I::value_type, std::match_results<const CharT*> >::value), "");
+ static_assert((std::is_same<typename I::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<typename I::pointer, const std::match_results<const CharT*>*>::value), "");
+ static_assert((std::is_same<typename I::reference, const std::match_results<const CharT*>&>::value), "");
+ static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// template <size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// const int (&submatches)[N],
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ const int indices[] = {-1, 0, 1};
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), indices);
+ }
+}
+#endif
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// template <size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// const int (&submatches)[N],
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ const int indices[] = {-1, 0, 1};
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, indices);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_token_iterator<const CharT*> I;
+ I i1;
+ assert(i1 == I());
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// initializer_list<int> submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), {-1, 0, 1});
+ }
+}
+#endif
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// initializer_list<int> submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, {-1, 0, 1});
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re, int submatch = 0,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), -1);
+ }
+}
+#endif
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re, int submatch = 0,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, 1);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// template <std::size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// const std::vector<int>& submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(-1);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), v);
+ }
+}
+#endif
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// const std::vector<int>& submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(-1);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, v);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(0);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, v);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(0);
+ v.push_back(1);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, v);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// bool operator==(const regex_token_iterator& right) const;
+// bool operator!=(const regex_token_iterator& right) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ assert(i != std::cregex_token_iterator());
+ assert(!(i == std::cregex_token_iterator()));
+ std::cregex_token_iterator i2 = i;
+ assert(i2 == i);
+ assert(!(i2 != i));
+ ++i;
+ assert(!(i2 == i));
+ assert(i2 != i);
+ }
+}
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// const value_type& operator*() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers);
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, 1);
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,135 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator& operator++(int);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ std::cregex_token_iterator i2 = i;
+ std::cregex_token_iterator i3;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ assert(i2->str() == "start ");
+ i3 = i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == "start ");
+ i3 = i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i++;
+ assert(i == std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i2->str() == "start ");
+ assert(i3->str() == " end");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ std::cregex_token_iterator i2 = i;
+ std::cregex_token_iterator i3;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ assert(i2->str() == "start ");
+ i3 = i;
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == "start ");
+ i3 = i;
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i;
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i;
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i2->str() == "start ");
+ assert(i3->str() == " end");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ i++;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, 1);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ i++;
+ assert(i == std::cregex_token_iterator());
+ }
+}
Added: libcxx/trunk/test/std/re/re.iter/re.tokiter/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/types.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator,
+// class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+// class traits = regex_traits<charT>>
+// class regex_token_iterator
+// {
+// public:
+// typedef basic_regex<charT, traits> regex_type;
+// typedef sub_match<BidirectionalIterator> value_type;
+// typedef ptrdiff_t difference_type;
+// typedef const value_type* pointer;
+// typedef const value_type& reference;
+// typedef forward_iterator_tag iterator_category;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_token_iterator<const CharT*> I;
+ static_assert((std::is_same<typename I::regex_type, std::basic_regex<CharT> >::value), "");
+ static_assert((std::is_same<typename I::value_type, std::sub_match<const CharT*> >::value), "");
+ static_assert((std::is_same<typename I::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<typename I::pointer, const std::sub_match<const CharT*>*>::value), "");
+ static_assert((std::is_same<typename I::reference, const std::sub_match<const CharT*>&>::value), "");
+ static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex&
+// assign(initializer_list<charT> il,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::regex r2;
+ r2.assign({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'});
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& assign(const basic_regex& that);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2;
+ r2.assign(r1);
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class InputIterator>
+// basic_regex&
+// assign(InputIterator first, InputIterator last,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ typedef input_iterator<std::string::const_iterator> I;
+ typedef forward_iterator<std::string::const_iterator> F;
+ std::string s4("(a([bc]))");
+ std::regex r2;
+
+ r2.assign(I(s4.begin()), I(s4.end()));
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(I(s4.begin()), I(s4.end()), std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(F(s4.begin()), F(s4.end()));
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(F(s4.begin()), F(s4.end()), std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2.assign("(a([bc]))");
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign("(a([bc]))", std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& assign(const charT* ptr, size_t len, flag_type f);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2.assign("(a([bc]))", 9, std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class string_traits, class A>
+// basic_regex& assign(const basic_string<charT, string_traits, A>& s,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2.assign(std::string("(a([bc]))"));
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(std::string("(a([bc]))"), std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.assign/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& operator=(const basic_regex& e);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2;
+ r2 = r1;
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.assign/il.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/il.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/il.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/il.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& operator=(initializer_list<charT> il);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::regex r2;
+ r2 = {'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'};
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& operator=(const charT* ptr);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2 = "(a([bc]))";
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.assign/string.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/string.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/string.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/string.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+// basic_regex& operator=(const basic_string<charT, ST, SA>& p);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2 = std::string("(a([bc]))");
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.const/constants.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.const/constants.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.const/constants.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.const/constants.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>>
+// class basic_regex
+// {
+// public:
+// // constants:
+// static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
+// static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
+// static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
+// static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
+// static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
+// static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
+// static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
+// static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
+// static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
+// static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
+
+#include <regex>
+#include <type_traits>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+template <class CharT>
+void
+test()
+{
+ typedef std::basic_regex<CharT> BR;
+ static_assert((BR::icase == std::regex_constants::icase), "");
+ static_assert((BR::nosubs == std::regex_constants::nosubs), "");
+ static_assert((BR::optimize == std::regex_constants::optimize), "");
+ static_assert((BR::collate == std::regex_constants::collate), "");
+ static_assert((BR::ECMAScript == std::regex_constants::ECMAScript), "");
+ static_assert((BR::basic == std::regex_constants::basic), "");
+ static_assert((BR::extended == std::regex_constants::extended), "");
+ static_assert((BR::awk == std::regex_constants::awk), "");
+ static_assert((BR::grep == std::regex_constants::grep), "");
+ static_assert((BR::egrep == std::regex_constants::egrep), "");
+ where(BR::icase);
+ where(BR::nosubs);
+ where(BR::optimize);
+ where(BR::collate);
+ where(BR::ECMAScript);
+ where(BR::basic);
+ where(BR::extended);
+ where(BR::awk);
+ where(BR::grep);
+ where(BR::egrep);
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ using std::regex_constants::awk;
+
+ assert(std::regex_match("\4", std::regex("\\4", awk)));
+ assert(std::regex_match("\41", std::regex("\\41", awk)));
+ assert(std::regex_match("\141", std::regex("\\141", awk)));
+ assert(std::regex_match("\1411", std::regex("\\1411", awk)));
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+static bool error_escape_thrown(const char *pat)
+{
+ bool result = false;
+ try {
+ std::regex re(pat);
+ } catch (std::regex_error &ex) {
+ result = (ex.code() == std::regex_constants::error_escape);
+ }
+ return result;
+}
+
+int main()
+{
+ assert(error_escape_thrown("[\\a]"));
+ assert(error_escape_thrown("\\a"));
+
+ assert(error_escape_thrown("[\\e]"));
+ assert(error_escape_thrown("\\e"));
+
+ assert(error_escape_thrown("[\\c:]"));
+ assert(error_escape_thrown("\\c:"));
+ assert(error_escape_thrown("\\c"));
+ assert(!error_escape_thrown("[\\cA]"));
+ assert(!error_escape_thrown("\\cA"));
+
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const basic_regex& e);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2 = r1;
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/default.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ std::basic_regex<CharT> r;
+ assert(r.flags() == 0);
+ assert(r.mark_count() == 0);
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(initializer_list<charT> il,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+void
+test(std::initializer_list<char> il, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<char> r(il, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::string s1("\\(a\\)");
+ std::string s2("\\(a[bc]\\)");
+ std::string s3("\\(a\\([bc]\\)\\)");
+ std::string s4("(a([bc]))");
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::basic, 1);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::basic, 1);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::basic, 2);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::basic, 0);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::extended, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::extended, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::extended, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::extended, 2);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::ECMAScript, 2);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::awk, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::awk, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::awk, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::awk, 2);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::grep, 1);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::grep, 1);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::grep, 2);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::grep, 0);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::egrep, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::egrep, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::egrep, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::egrep, 2);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ForwardIterator>
+// basic_regex(ForwardIterator first, ForwardIterator last);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last, unsigned mc)
+{
+ std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last);
+ assert(r.flags() == std::regex_constants::ECMAScript);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ typedef forward_iterator<std::string::const_iterator> F;
+ std::string s1("\\(a\\)");
+ std::string s2("\\(a[bc]\\)");
+ std::string s3("\\(a\\([bc]\\)\\)");
+ std::string s4("(a([bc]))");
+
+ test(F(s1.begin()), F(s1.end()), 0);
+ test(F(s2.begin()), F(s2.end()), 0);
+ test(F(s3.begin()), F(s3.end()), 0);
+ test(F(s4.begin()), F(s4.end()), 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ForwardIterator>
+// basic_regex(ForwardIterator first, ForwardIterator last,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ typedef forward_iterator<std::string::const_iterator> F;
+ std::string s1("\\(a\\)");
+ std::string s2("\\(a[bc]\\)");
+ std::string s3("\\(a\\([bc]\\)\\)");
+ std::string s4("(a([bc]))");
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::basic, 1);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::basic, 1);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::basic, 2);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::basic, 0);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::extended, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::extended, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::extended, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::extended, 2);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::ECMAScript, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::ECMAScript, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::ECMAScript, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::ECMAScript, 2);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::awk, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::awk, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::awk, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::awk, 2);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::grep, 1);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::grep, 1);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::grep, 2);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::grep, 0);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::egrep, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::egrep, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::egrep, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::egrep, 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const charT* p);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, unsigned mc)
+{
+ std::basic_regex<CharT> r(p);
+ assert(r.flags() == std::regex_constants::ECMAScript);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test("\\(a\\)", 0);
+ test("\\(a[bc]\\)", 0);
+ test("\\(a\\([bc]\\)\\)", 0);
+ test("(a([bc]))", 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<CharT> r(p, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test("\\(a\\)", std::regex_constants::basic, 1);
+ test("\\(a[bc]\\)", std::regex_constants::basic, 1);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::basic, 2);
+ test("(a([bc]))", std::regex_constants::basic, 0);
+
+ test("\\(a\\)", std::regex_constants::extended, 0);
+ test("\\(a[bc]\\)", std::regex_constants::extended, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::extended, 0);
+ test("(a([bc]))", std::regex_constants::extended, 2);
+
+ test("\\(a\\)", std::regex_constants::ECMAScript, 0);
+ test("\\(a[bc]\\)", std::regex_constants::ECMAScript, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::ECMAScript, 0);
+ test("(a([bc]))", std::regex_constants::ECMAScript, 2);
+
+ test("\\(a\\)", std::regex_constants::awk, 0);
+ test("\\(a[bc]\\)", std::regex_constants::awk, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::awk, 0);
+ test("(a([bc]))", std::regex_constants::awk, 2);
+
+ test("\\(a\\)", std::regex_constants::grep, 1);
+ test("\\(a[bc]\\)", std::regex_constants::grep, 1);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::grep, 2);
+ test("(a([bc]))", std::regex_constants::grep, 0);
+
+ test("\\(a\\)", std::regex_constants::egrep, 0);
+ test("\\(a[bc]\\)", std::regex_constants::egrep, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::egrep, 0);
+ test("(a([bc]))", std::regex_constants::egrep, 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const charT* p, size_t len, flag_type f);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, std::size_t len, std::regex_constants::syntax_option_type f,
+ unsigned mc)
+{
+ std::basic_regex<CharT> r(p, len, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test("\\(a\\)", 5, std::regex_constants::basic, 1);
+ test("\\(a[bc]\\)", 9, std::regex_constants::basic, 1);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::basic, 2);
+ test("(a([bc]))", 9, std::regex_constants::basic, 0);
+
+ test("\\(a\\)", 5, std::regex_constants::extended, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::extended, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::extended, 0);
+ test("(a([bc]))", 9, std::regex_constants::extended, 2);
+
+ test("\\(a\\)", 5, std::regex_constants::ECMAScript, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::ECMAScript, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::ECMAScript, 0);
+ test("(a([bc]))", 9, std::regex_constants::ECMAScript, 2);
+
+ test("\\(a\\)", 5, std::regex_constants::awk, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::awk, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::awk, 0);
+ test("(a([bc]))", 9, std::regex_constants::awk, 2);
+
+ test("\\(a\\)", 5, std::regex_constants::grep, 1);
+ test("\\(a[bc]\\)", 9, std::regex_constants::grep, 1);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::grep, 2);
+ test("(a([bc]))", 9, std::regex_constants::grep, 0);
+
+ test("\\(a\\)", 5, std::regex_constants::egrep, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::egrep, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::egrep, 0);
+ test("(a([bc]))", 9, std::regex_constants::egrep, 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/string.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/string.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/string.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/string.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+template <class String>
+void
+test(const String& p, unsigned mc)
+{
+ std::basic_regex<typename String::value_type> r(p);
+ assert(r.flags() == std::regex_constants::ECMAScript);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test(std::string("\\(a\\)"), 0);
+ test(std::string("\\(a[bc]\\)"), 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), 0);
+ test(std::string("(a([bc]))"), 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+template <class String>
+void
+test(const String& p, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<typename String::value_type> r(p, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test(std::string("\\(a\\)"), std::regex_constants::basic, 1);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::basic, 1);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::basic, 2);
+ test(std::string("(a([bc]))"), std::regex_constants::basic, 0);
+
+ test(std::string("\\(a\\)"), std::regex_constants::extended, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::extended, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::extended, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::extended, 2);
+
+ test(std::string("\\(a\\)"), std::regex_constants::ECMAScript, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::ECMAScript, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::ECMAScript, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::ECMAScript, 2);
+
+ test(std::string("\\(a\\)"), std::regex_constants::awk, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::awk, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::awk, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::awk, 2);
+
+ test(std::string("\\(a\\)"), std::regex_constants::grep, 1);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::grep, 1);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::grep, 2);
+ test(std::string("(a([bc]))"), std::regex_constants::grep, 0);
+
+ test(std::string("\\(a\\)"), std::regex_constants::egrep, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::egrep, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::egrep, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::egrep, 2);
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// locale_type imbue(locale_type loc);
+
+#include <regex>
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ std::regex r;
+ std::locale loc = r.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(loc.name() == "C");
+ assert(r.getloc().name() == LOCALE_en_US_UTF_8);
+ loc = r.imbue(std::locale("C"));
+ assert(loc.name() == LOCALE_en_US_UTF_8);
+ assert(r.getloc().name() == "C");
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class charT, class traits>
+// void swap(basic_regex<charT, traits>& lhs, basic_regex<charT, traits>& rhs);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2;
+ swap(r2, r1);
+ assert(r1.flags() == std::regex::ECMAScript);
+ assert(r1.mark_count() == 0);
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
More information about the cfe-commits
mailing list