Skip to content

Commit

Permalink
test tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
mqrause committed Jan 13, 2024
1 parent 2bfa948 commit 3ea474d
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions tests/reloading_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static const flag_id json_flag_SPEEDLOADER( "SPEEDLOADER" );
static const itype_id itype_glock_19( "glock_19" );
static const itype_id itype_glockbigmag( "glockbigmag" );
static const itype_id itype_glockmag( "glockmag" );
static const itype_id itype_water_clean( "water_clean" );

static void test_reloading( item &target, item &ammo, bool expect_success = true )
{
Expand Down Expand Up @@ -338,26 +339,26 @@ TEST_CASE( "liquid_reloading", "[reload]" )

SECTION( "with water" ) {
item liquid_container( "bottle_plastic" );
liquid_container.put_in( item( "water_clean" ), pocket_type::CONTAINER );
liquid_container.put_in( item( itype_water_clean ), pocket_type::CONTAINER );
test_reloading( container, liquid_container );
}

SECTION( "with lots of water" ) {
item liquid_container( "bottle_twoliter" );
liquid_container.put_in( item( "water_clean", calendar::turn, 8 ),
liquid_container.put_in( item( itype_water_clean, calendar::turn, 8 ),
pocket_type::CONTAINER );
test_reloading( container, liquid_container );
}

SECTION( "with frozen water" ) {
item liquid( "water_clean" );
item liquid( itype_water_clean );
liquid.set_item_temperature( units::from_kelvin( 200 ) );
REQUIRE( liquid.is_frozen_liquid() );
test_reloading( container, liquid, false );
}

SECTION( "with frozen water from container" ) {
item liquid( "water_clean" );
item liquid( itype_water_clean );
liquid.set_item_temperature( units::from_kelvin( 200 ) );
REQUIRE( liquid.is_frozen_liquid() );

Expand All @@ -383,32 +384,32 @@ TEST_CASE( "liquid_reloading", "[reload]" )
SECTION( "partially empty bottle" ) {

item container( "bottle_twoliter" );
container.put_in( item( "water_clean", calendar::turn, 1 ), pocket_type::CONTAINER );
container.put_in( item( itype_water_clean, calendar::turn, 1 ), pocket_type::CONTAINER );
REQUIRE( !container.is_container_empty() );
REQUIRE( !container.is_container_full() );

SECTION( "with one water" ) {
item liquid_container( "bottle_plastic" );
liquid_container.put_in( item( "water_clean" ), pocket_type::CONTAINER );
liquid_container.put_in( item( itype_water_clean ), pocket_type::CONTAINER );
test_reloading( container, liquid_container );
}

SECTION( "with lots of water" ) {
item liquid_container( "bottle_twoliter" );
liquid_container.put_in( item( "water_clean", calendar::turn, 8 ),
liquid_container.put_in( item( itype_water_clean, calendar::turn, 8 ),
pocket_type::CONTAINER );
test_reloading( container, liquid_container );
}

SECTION( "with frozen water" ) {
item liquid( "water_clean" );
item liquid( itype_water_clean );
liquid.set_item_temperature( units::from_kelvin( 200 ) );
REQUIRE( liquid.is_frozen_liquid() );
test_reloading( container, liquid, false );
}

SECTION( "with frozen water from container" ) {
item liquid( "water_clean" );
item liquid( itype_water_clean );
liquid.set_item_temperature( units::from_kelvin( 200 ) );
REQUIRE( liquid.is_frozen_liquid() );

Expand All @@ -432,31 +433,31 @@ TEST_CASE( "liquid_reloading", "[reload]" )

SECTION( "full bottle" ) {
item container( "bottle_plastic" );
container.put_in( item( "water_clean", calendar::turn, 2 ), pocket_type::CONTAINER );
container.put_in( item( itype_water_clean, calendar::turn, 2 ), pocket_type::CONTAINER );
REQUIRE( container.is_container_full() );

SECTION( "with one water" ) {
item liquid_container( "bottle_plastic_small" );
liquid_container.put_in( item( "water_clean" ), pocket_type::CONTAINER );
liquid_container.put_in( item( itype_water_clean ), pocket_type::CONTAINER );
test_reloading( container, liquid_container, false );
}

SECTION( "with lots of water" ) {
item liquid_container( "bottle_twoliter" );
liquid_container.put_in( item( "water_clean", calendar::turn, 8 ),
liquid_container.put_in( item( itype_water_clean, calendar::turn, 8 ),
pocket_type::CONTAINER );
test_reloading( container, liquid_container, false );
}

SECTION( "with frozen water" ) {
item liquid( "water_clean" );
item liquid( itype_water_clean );
liquid.set_item_temperature( units::from_kelvin( 200 ) );
REQUIRE( liquid.is_frozen_liquid() );
test_reloading( container, liquid, false );
}

SECTION( "with frozen water from container" ) {
item liquid( "water_clean" );
item liquid( itype_water_clean );
liquid.set_item_temperature( units::from_kelvin( 200 ) );
REQUIRE( liquid.is_frozen_liquid() );

Expand Down Expand Up @@ -1064,7 +1065,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" )
REQUIRE( dummy.wield( canteen ) ) ;

item_location ammo_jug = dummy.i_add( item( "jug_plastic" ) );
ammo_jug->put_in( item( "water_clean", calendar::turn_zero, 2 ),
ammo_jug->put_in( item( itype_water_clean, calendar::turn_zero, 2 ),
pocket_type::CONTAINER );
units::volume ammo_volume = ammo_jug->total_contained_volume();

Expand All @@ -1077,7 +1078,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" )
}

SECTION( "reload liquid into partially filled container with same type liquid" ) {
item water_one( "water_clean", calendar::turn_zero, 1 );
item water_one( itype_water_clean, calendar::turn_zero, 1 );
units::volume initial_volume = water_one.volume();
dummy.get_wielded_item()->put_in( water_one, pocket_type::CONTAINER );
g->reload_wielded();
Expand Down Expand Up @@ -1112,7 +1113,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" )
}

SECTION( "reload liquid container with more liquid than it can hold" ) {
ammo_jug->fill_with( item( "water_clean", calendar::turn_zero, 1 ) );
ammo_jug->fill_with( item( itype_water_clean, calendar::turn_zero, 1 ) );
ammo_volume = ammo_jug->total_contained_volume();
g->reload_wielded();
REQUIRE( dummy.activity );
Expand All @@ -1133,7 +1134,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" )
ammo_jug.remove_item();
ammo_jug = item_location( map_cursor( near_point ), &here.add_item( near_point,
item( "bottle_plastic" ) ) );
ammo_jug->fill_with( item( "water_clean" ) );
ammo_jug->fill_with( item( itype_water_clean ) );
ammo_volume = ammo_jug->total_contained_volume();
g->reload_wielded();
REQUIRE( dummy.activity );
Expand All @@ -1143,12 +1144,14 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" )
}

SECTION( "liquid spill on floor" ) {
REQUIRE_FALSE( here.has_flag_ter_or_furn( "LIQUIDCONT", near_point ) );
REQUIRE( ammo_jug->spill_contents( near_point ) );
REQUIRE( ammo_jug->total_contained_volume() == units::volume() );
REQUIRE_FALSE( dummy.has_charges( itype_water_clean, 1 ) );
g->reload_wielded();
if( !!dummy.activity ) {
process_activity( dummy );
}
CHECK( ammo_jug->total_contained_volume() == units::volume() );
CHECK( dummy.get_wielded_item()->total_contained_volume() == units::volume() );

Check failure on line 1155 in tests/reloading_test.cpp

View workflow job for this annotation

GitHub Actions / GCC 9, Curses, LTO

500ml == 0ml
}
}
Expand Down

0 comments on commit 3ea474d

Please sign in to comment.