Partition vector algorithms test: move out lex compare family by AlexGuteniev · Pull Request #5063 · microsoft/STL (original) (raw)

there's no commonality between the test support machinery

There is no new commonality extracted during this separation, as all the commonality, which is mostly the randomness initialization, was previously extracted in #4734 into /tests/std/include/test_vector_algorithms_support.hpp to support separate floating minmax testing.

This specific commonality, I think, is not an indication that these tests should be together.
Instead, it seems to be something potentially reusable in more separate tests.
<charconv> test mentioned in #933 is a candidate:

void initialize_randomness(mt19937_64& mt64, const int argc, char** const argv) {
constexpr size_t n = mt19937_64::state_size;
constexpr size_t w = mt19937_64::word_size;
static_assert(w % 32 == 0);
constexpr size_t k = w / 32;
vector<uint32_t> vec(n * k);
puts("USAGE:");
puts("test.exe : generates seed data from random_device.");
puts("test.exe filename.txt : loads seed data from a given text file.");
if (argc == 1) {
random_device rd;
generate(vec.begin(), vec.end(), ref(rd));
puts("Generated seed data.");
} else if (argc == 2) {
const char* const filename = argv[1];
ifstream file(filename);
if (!file) {
printf("ERROR: Can't open %s.\n", filename);
abort();
}
for (auto& elem : vec) {
file >> elem;
if (!file) {
printf("ERROR: Can't read seed data from %s.\n", filename);
abort();
}
}
printf("Loaded seed data from %s.\n", filename);
} else {
puts("ERROR: Too many command-line arguments.");
abort();
}
puts("SEED DATA:");
for (const auto& elem : vec) {
printf("%u ", elem);
}
printf("\n");
seed_seq seq(vec.cbegin(), vec.cend());
mt64.seed(seq);
puts("Successfully seeded mt64. First three values:");
for (int i = 0; i < 3; ++i) {
// libc++ uses long for 64-bit values.
printf("0x%016llX\n", static_cast<unsigned long long>(mt64()));
}
}