Files
Cataclysm-DDA/tests/visitable_test.cpp
T
John Bytheway b285a13080 Make time_point( int ) constructor explicit
Resolves a TODO on that constructor, and one more TODO elsewhere due to
the resulting refactoring.

time_point was implicitly convertible from int.  This led to unclear
code.  In particular, the item constructor took a time_point and a
quantity, and these two ints appeared adjacent with no obvious way to
see what they meant at call sites.

Make the constructor explicit, so the conversion is no longer implicit.
Update the rest of the code accordingly.

In most cases switched from 0 to calendar::turn_zero, which is
equivalent.  In a couple of places, used start_of_cataclysm instead,
when it seemed more appropriate (such as birthday of toilet water).
It's possible there are more cases which should have been something
other than turn_zero.
2020-11-10 11:21:02 -08:00

25 lines
781 B
C++

#include "catch/catch.hpp"
#include "calendar.h"
#include "inventory.h"
#include "item.h"
#include "item_pocket.h"
#include "ret_val.h"
#include "type_id.h"
TEST_CASE( "visitable_summation" )
{
inventory test_inv;
item bottle_of_water( "bottle_plastic", calendar::turn );
item water_in_bottle( "water", calendar::turn );
water_in_bottle.charges = bottle_of_water.get_remaining_capacity_for_liquid( water_in_bottle );
bottle_of_water.put_in( water_in_bottle, item_pocket::pocket_type::CONTAINER );
test_inv.add_item( bottle_of_water );
const item unlimited_water( "water", calendar::turn_zero, item::INFINITE_CHARGES );
test_inv.add_item( unlimited_water );
CHECK( test_inv.charges_of( itype_id( "water" ), item::INFINITE_CHARGES ) > 1 );
}