diff --git a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp @@ -30,12 +30,13 @@ G g; D d; const int N = 100; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); for (unsigned i = 0; i < u.size(); ++i) @@ -48,12 +49,13 @@ double p0[] = {.3}; D d(p0, p0+1); const int N = 100; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); for (unsigned i = 0; i < u.size(); ++i) @@ -66,12 +68,13 @@ double p0[] = {.75, .25}; D d(p0, p0+2); const int N = 1000000; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); for (unsigned i = 0; i < u.size(); ++i) @@ -84,12 +87,13 @@ double p0[] = {0, 1}; D d(p0, p0+2); const int N = 1000000; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); assert((double)u[0]/N == prob[0]); @@ -102,12 +106,13 @@ double p0[] = {1, 0}; D d(p0, p0+2); const int N = 1000000; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); assert((double)u[0]/N == prob[0]); @@ -120,12 +125,13 @@ double p0[] = {.3, .1, .6}; D d(p0, p0+3); const int N = 10000000; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); for (unsigned i = 0; i < u.size(); ++i) @@ -138,12 +144,13 @@ double p0[] = {0, 25, 75}; D d(p0, p0+3); const int N = 1000000; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); for (unsigned i = 0; i < u.size(); ++i) @@ -159,12 +166,13 @@ double p0[] = {25, 0, 75}; D d(p0, p0+3); const int N = 1000000; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); for (unsigned i = 0; i < u.size(); ++i) @@ -180,12 +188,13 @@ double p0[] = {25, 75, 0}; D d(p0, p0+3); const int N = 1000000; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); for (unsigned i = 0; i < u.size(); ++i) @@ -201,12 +210,13 @@ double p0[] = {0, 0, 1}; D d(p0, p0+3); const int N = 100; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); for (unsigned i = 0; i < u.size(); ++i) @@ -222,12 +232,13 @@ double p0[] = {0, 1, 0}; D d(p0, p0+3); const int N = 100; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); for (unsigned i = 0; i < u.size(); ++i) @@ -243,12 +254,13 @@ double p0[] = {1, 0, 0}; D d(p0, p0+3); const int N = 100; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); for (unsigned i = 0; i < u.size(); ++i) @@ -264,12 +276,13 @@ double p0[] = {33, 0, 0, 67}; D d(p0, p0+3); const int N = 1000000; - std::vector u(d.max()+1); + std::vector u(static_cast(d.max()+1)); + assert(u.max_size() > static_cast(d.max())); for (int i = 0; i < N; ++i) { typename D::result_type v = d(g); assert(d.min() <= v && v <= d.max()); - u[v]++; + u[static_cast(v)]++; } std::vector prob = d.probabilities(); for (unsigned i = 0; i < u.size(); ++i)