Skip to content

Commit

Permalink
[libc++] Remove additional uses of std::rand() missed by 63aeadb
Browse files Browse the repository at this point in the history
  • Loading branch information
ldionne committed Oct 29, 2020
1 parent 7a79921 commit bd8884f
Show file tree
Hide file tree
Showing 22 changed files with 63 additions and 96 deletions.
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -16,7 +16,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <std::size_t N>
Expand Down
Expand Up @@ -27,7 +27,7 @@
#include <string>
#include <vector>

#include "bitset_test_cases.h"
#include "../bitset_test_cases.h"
#include "test_macros.h"

template <class CharT, std::size_t N>
Expand Down
Expand Up @@ -9,38 +9,27 @@
// test bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs);

#include <bitset>
#include <cstdlib>
#include <cassert>
#include <cstddef>
#include <vector>

#include "../bitset_test_cases.h"
#include "test_macros.h"

#if defined(TEST_COMPILER_CLANG)
#pragma clang diagnostic ignored "-Wtautological-compare"
#elif defined(TEST_COMPILER_C1XX)
#pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
#endif

template <std::size_t N>
std::bitset<N>
make_bitset()
{
std::bitset<N> v;
for (std::size_t i = 0; i < N; ++i)
v[i] = static_cast<bool>(std::rand() & 1);
return v;
}

template <std::size_t N>
void test_op_and()
{
std::bitset<N> v1 = make_bitset<N>();
std::bitset<N> v2 = make_bitset<N>();
std::bitset<N> v3 = v1;
assert((v1 & v2) == (v3 &= v2));
void test_op_and() {
std::vector<std::bitset<N> > const cases = get_test_cases<N>();
for (std::size_t c1 = 0; c1 != cases.size(); ++c1) {
for (std::size_t c2 = 0; c2 != cases.size(); ++c2) {
std::bitset<N> v1 = cases[c1];
std::bitset<N> v2 = cases[c2];
std::bitset<N> v3 = v1;
assert((v1 & v2) == (v3 &= v2));
}
}
}

int main(int, char**)
{
int main(int, char**) {
test_op_and<0>();
test_op_and<1>();
test_op_and<31>();
Expand All @@ -51,5 +40,5 @@ int main(int, char**)
test_op_and<65>();
test_op_and<1000>();

return 0;
return 0;
}
Expand Up @@ -9,38 +9,27 @@
// test bitset<N> operator^(const bitset<N>& lhs, const bitset<N>& rhs);

#include <bitset>
#include <cstdlib>
#include <cassert>
#include <cstddef>
#include <vector>

#include "../bitset_test_cases.h"
#include "test_macros.h"

#if defined(TEST_COMPILER_CLANG)
#pragma clang diagnostic ignored "-Wtautological-compare"
#elif defined(TEST_COMPILER_C1XX)
#pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
#endif

template <std::size_t N>
std::bitset<N>
make_bitset()
{
std::bitset<N> v;
for (std::size_t i = 0; i < N; ++i)
v[i] = static_cast<bool>(std::rand() & 1);
return v;
}

template <std::size_t N>
void test_op_not()
{
std::bitset<N> v1 = make_bitset<N>();
std::bitset<N> v2 = make_bitset<N>();
std::bitset<N> v3 = v1;
assert((v1 ^ v2) == (v3 ^= v2));
void test_op_not() {
std::vector<std::bitset<N> > const cases = get_test_cases<N>();
for (std::size_t c1 = 0; c1 != cases.size(); ++c1) {
for (std::size_t c2 = 0; c2 != cases.size(); ++c2) {
std::bitset<N> v1 = cases[c1];
std::bitset<N> v2 = cases[c2];
std::bitset<N> v3 = v1;
assert((v1 ^ v2) == (v3 ^= v2));
}
}
}

int main(int, char**)
{
int main(int, char**) {
test_op_not<0>();
test_op_not<1>();
test_op_not<31>();
Expand All @@ -51,5 +40,5 @@ int main(int, char**)
test_op_not<65>();
test_op_not<1000>();

return 0;
return 0;
}
Expand Up @@ -9,38 +9,27 @@
// test bitset<N> operator|(const bitset<N>& lhs, const bitset<N>& rhs);

#include <bitset>
#include <cstdlib>
#include <cassert>
#include <cstddef>
#include <vector>

#include "../bitset_test_cases.h"
#include "test_macros.h"

#if defined(TEST_COMPILER_CLANG)
#pragma clang diagnostic ignored "-Wtautological-compare"
#elif defined(TEST_COMPILER_C1XX)
#pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
#endif

template <std::size_t N>
std::bitset<N>
make_bitset()
{
std::bitset<N> v;
for (std::size_t i = 0; i < N; ++i)
v[i] = static_cast<bool>(std::rand() & 1);
return v;
}

template <std::size_t N>
void test_op_or()
{
std::bitset<N> v1 = make_bitset<N>();
std::bitset<N> v2 = make_bitset<N>();
std::bitset<N> v3 = v1;
assert((v1 | v2) == (v3 |= v2));
void test_op_or() {
std::vector<std::bitset<N> > const cases = get_test_cases<N>();
for (std::size_t c1 = 0; c1 != cases.size(); ++c1) {
for (std::size_t c2 = 0; c2 != cases.size(); ++c2) {
std::bitset<N> v1 = cases[c1];
std::bitset<N> v2 = cases[c2];
std::bitset<N> v3 = v1;
assert((v1 | v2) == (v3 |= v2));
}
}
}

int main(int, char**)
{
int main(int, char**) {
test_op_or<0>();
test_op_or<1>();
test_op_or<31>();
Expand All @@ -51,5 +40,5 @@ int main(int, char**)
test_op_or<65>();
test_op_or<1000>();

return 0;
return 0;
}

0 comments on commit bd8884f

Please sign in to comment.