summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--absl/random/internal/explicit_seed_seq_test.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/absl/random/internal/explicit_seed_seq_test.cc b/absl/random/internal/explicit_seed_seq_test.cc
index f867f610..e36d5fa0 100644
--- a/absl/random/internal/explicit_seed_seq_test.cc
+++ b/absl/random/internal/explicit_seed_seq_test.cc
@@ -140,10 +140,8 @@ TEST(ExplicitSeedSeq, CopyAndMoveConstructors) {
ExplicitSeedSeq seq_copy(seq_from_entropy);
EXPECT_EQ(seq_copy.size(), seq_from_entropy.size());
- std::vector<uint32_t> seeds_1;
- seeds_1.resize(1000, 0);
- std::vector<uint32_t> seeds_2;
- seeds_2.resize(1000, 1);
+ std::vector<uint32_t> seeds_1(1000, 0);
+ std::vector<uint32_t> seeds_2(1000, 1);
seq_from_entropy.generate(seeds_1.begin(), seeds_1.end());
seq_copy.generate(seeds_2.begin(), seeds_2.end());
@@ -157,10 +155,8 @@ TEST(ExplicitSeedSeq, CopyAndMoveConstructors) {
}
ExplicitSeedSeq another_seq(std::begin(entropy), std::end(entropy));
- std::vector<uint32_t> seeds_1;
- seeds_1.resize(1000, 0);
- std::vector<uint32_t> seeds_2;
- seeds_2.resize(1000, 0);
+ std::vector<uint32_t> seeds_1(1000, 0);
+ std::vector<uint32_t> seeds_2(1000, 0);
seq_from_entropy.generate(seeds_1.begin(), seeds_1.end());
another_seq.generate(seeds_2.begin(), seeds_2.end());
@@ -169,7 +165,15 @@ TEST(ExplicitSeedSeq, CopyAndMoveConstructors) {
EXPECT_THAT(seeds_1, Not(Pointwise(Eq(), seeds_2)));
// Apply the assignment-operator.
+ // GCC 12 has a false-positive -Wstringop-overflow warning here.
+#if ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(12, 0)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
another_seq = seq_from_entropy;
+#if ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(12, 0)
+#pragma GCC diagnostic pop
+#endif
// Re-generate seeds.
seq_from_entropy.generate(seeds_1.begin(), seeds_1.end());
@@ -181,15 +185,13 @@ TEST(ExplicitSeedSeq, CopyAndMoveConstructors) {
// Move constructor.
{
// Get seeds from seed-sequence constructed from entropy.
- std::vector<uint32_t> seeds_1;
- seeds_1.resize(1000, 0);
+ std::vector<uint32_t> seeds_1(1000, 0);
seq_from_entropy.generate(seeds_1.begin(), seeds_1.end());
// Apply move-constructor move the sequence to another instance.
absl::random_internal::ExplicitSeedSeq moved_seq(
std::move(seq_from_entropy));
- std::vector<uint32_t> seeds_2;
- seeds_2.resize(1000, 1);
+ std::vector<uint32_t> seeds_2(1000, 1);
moved_seq.generate(seeds_2.begin(), seeds_2.end());
// Verify that seeds produced by moved-instance are the same as original.
EXPECT_THAT(seeds_1, Pointwise(Eq(), seeds_2));