Skip to content

Commit bbb27cc

Browse files
committed
Reduce number of iterations in some tests
1 parent be8416c commit bbb27cc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/mutator_test.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,13 @@ std::vector<TestParams> GetMessageTestParams(
309309
return results;
310310
}
311311

312-
bool Mutate(const protobuf::Message& from, const protobuf::Message& to) {
312+
bool Mutate(const protobuf::Message& from, const protobuf::Message& to,
313+
int iterations = 10000) {
313314
EXPECT_FALSE(MessageDifferencer::Equals(from, to));
314315
ReducedTestMutator mutator;
315316
std::unique_ptr<protobuf::Message> message(from.New());
316317
EXPECT_FALSE(MessageDifferencer::Equals(from, to));
317-
for (int j = 0; j < 1000000; ++j) {
318+
for (int j = 0; j < iterations; ++j) {
318319
message->CopyFrom(from);
319320
mutator.Mutate(message.get(), 1000);
320321
if (MessageDifferencer::Equals(*message, to)) return true;
@@ -327,12 +328,12 @@ bool Mutate(const protobuf::Message& from, const protobuf::Message& to) {
327328
}
328329

329330
bool CrossOver(const protobuf::Message& from, const protobuf::Message& with,
330-
const protobuf::Message& to) {
331+
const protobuf::Message& to, int iterations = 10000) {
331332
EXPECT_FALSE(MessageDifferencer::Equals(from, to));
332333
ReducedTestMutator mutator;
333334
std::unique_ptr<protobuf::Message> message(from.New());
334335
EXPECT_FALSE(MessageDifferencer::Equals(from, to));
335-
for (int j = 0; j < 1000000; ++j) {
336+
for (int j = 0; j < iterations; ++j) {
336337
message->CopyFrom(from);
337338
mutator.CrossOver(with, message.get(), 1000);
338339
if (MessageDifferencer::Equals(*message, to)) return true;
@@ -440,8 +441,8 @@ TEST_P(MutatorFieldTest, Initialized) {
440441
TEST_P(MutatorFieldTest, ChangeField) {
441442
LoadWithChangedLine(m1_.get(), 0);
442443
LoadWithChangedLine(m2_.get(), 1);
443-
EXPECT_TRUE(Mutate(*m1_, *m2_));
444-
EXPECT_TRUE(Mutate(*m2_, *m1_));
444+
EXPECT_TRUE(Mutate(*m1_, *m2_, 1000000));
445+
EXPECT_TRUE(Mutate(*m2_, *m1_, 1000000));
445446
}
446447

447448
TEST_P(MutatorFieldTest, CrossOver) {

0 commit comments

Comments
 (0)