Skip to content

Commit

Permalink
Be more permissive in season length assertion
Browse files Browse the repository at this point in the history
This was failing on Mingw, probably due to -ffast-math optimizations.
  • Loading branch information
jbytheway committed Dec 31, 2019
1 parent fd88a62 commit 346a794
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/calendar_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

#include "calendar.h"
#include "rng.h"
#include "stringmaker.h"

TEST_CASE( "moon_phases_take_28_days", "[calendar]" )
{
CAPTURE( calendar::season_length() );
// This test only makes sense if the seasons are set to the default length
REQUIRE( calendar::season_from_default_ratio() == 1 );
REQUIRE( calendar::season_from_default_ratio() == Approx( 1.0f ) );

const int num_days = GENERATE( take( 100, random( 0, 1000 ) ) );
const time_point first_time = calendar::turn_zero + time_duration::from_days( num_days );
Expand Down
7 changes: 7 additions & 0 deletions tests/stringmaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ struct StringMaker<cata_variant> {
}
};

template<>
struct StringMaker<time_duration> {
static std::string convert( const time_duration &d ) {
return string_format( "time_duration( %d ) [%s]", to_turns<int>( d ), to_string( d ) );
}
};

} // namespace Catch

#endif // CATA_TESTS_STRINGMAKER_H

0 comments on commit 346a794

Please sign in to comment.