forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jbytheway/large_volumes
Test item::charges_per_volume
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "catch/catch.hpp" | ||
|
||
#include "item.h" | ||
#include "units.h" | ||
|
||
TEST_CASE( "item_volume", "[item]" ) | ||
{ | ||
item i( "battery", 0, item::default_charges_tag() ); | ||
// Would be better with Catch2 generators | ||
units::volume big_volume = units::from_milliliter( std::numeric_limits<int>::max() / 2 ); | ||
for( units::volume v : { | ||
0_ml, 1_ml, i.volume(), big_volume | ||
} ) { | ||
INFO( "checking batteries that fit in " << v ); | ||
auto charges_that_should_fit = i.charges_per_volume( v ); | ||
i.charges = charges_that_should_fit; | ||
CHECK( i.volume() <= v ); | ||
i.charges++; | ||
CHECK( i.volume() > v ); | ||
} | ||
} |