Skip to content

Commit

Permalink
Make date rand test independent of evaluation order
Browse files Browse the repository at this point in the history
  • Loading branch information
lightvector committed Nov 28, 2023
1 parent 64847cc commit f3a171b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cpp/core/datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,11 @@ void DateTime::runTests() {
SimpleDate date1;
SimpleDate date2;
int d1 = rand.nextInt(-10000000,10000000);
int d2 = rand.nextInt(-20,20) * (rand.nextBool(0.1) ? 100 : 1);
int d3 = rand.nextInt(-20,20); d3 = d3 * d3 * (rand.nextBool(0.5) ? -1 : 1) * (rand.nextBool(0.1) ? 37 : 1);
int d2 = rand.nextInt(-20,20);
d2 *= (rand.nextBool(0.1) ? 100 : 1);
int d3 = rand.nextInt(-20,20);
d3 = d3 * d3 * (rand.nextBool(0.5) ? -1 : 1);
d3 *= (rand.nextBool(0.1) ? 37 : 1);

date1 += d1;
testAssert(SimpleDate() + d1 == date1);
Expand Down

0 comments on commit f3a171b

Please sign in to comment.