Adding two more tests.
Deleting useless default case.
This commit is contained in:
parent
2c3d736d5f
commit
b2f4f31abd
@ -105,3 +105,64 @@ TEST_CASE("[D] Deserialize full BillyObjects", "[deserialize][1]") {
|
|||||||
REQUIRE(std::holds_alternative<equipments>(dummy_object.objects[2]));
|
REQUIRE(std::holds_alternative<equipments>(dummy_object.objects[2]));
|
||||||
REQUIRE(std::get<equipments>(dummy_object.objects[2]) == equipments::MedicKit);
|
REQUIRE(std::get<equipments>(dummy_object.objects[2]) == equipments::MedicKit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[D] Pushing popping BillyObjects", "[pushpop][0]") {
|
||||||
|
constexpr std::array<BillyObjects::billyObject, 12> all_objects{
|
||||||
|
weapons::Sword,
|
||||||
|
weapons::Lance,
|
||||||
|
weapons::Morgenstern,
|
||||||
|
weapons::Bow,
|
||||||
|
equipments::Chainmail,
|
||||||
|
equipments::CookingPot,
|
||||||
|
equipments::PamphletTourist,
|
||||||
|
equipments::MedicKit,
|
||||||
|
tools::Fourche,
|
||||||
|
tools::Dagger,
|
||||||
|
tools::RockClimbingKit,
|
||||||
|
tools::SackOfGrain,
|
||||||
|
};
|
||||||
|
|
||||||
|
BillyObjects gestionnaire{};
|
||||||
|
CharacterSheet sheet;
|
||||||
|
REQUIRE(sheet.get_objects().empty());
|
||||||
|
|
||||||
|
REQUIRE_NOTHROW(gestionnaire.push_object(weapons::Sword, sheet));
|
||||||
|
REQUIRE_FALSE(sheet.get_objects().empty());
|
||||||
|
REQUIRE(std::holds_alternative<weapons>(sheet.get_objects().back()));
|
||||||
|
REQUIRE(std::get<weapons>(sheet.get_objects().back()) == weapons::Sword);
|
||||||
|
|
||||||
|
REQUIRE_NOTHROW(gestionnaire.pop_object(sheet));
|
||||||
|
REQUIRE(sheet.get_objects().empty());
|
||||||
|
|
||||||
|
for (std::size_t j = 0; j < all_objects.size(); j += 3) {
|
||||||
|
for (std::size_t i = 0; i < 3; ++i) {
|
||||||
|
REQUIRE_NOTHROW(gestionnaire.push_object(all_objects[i + j], sheet));
|
||||||
|
}
|
||||||
|
REQUIRE_FALSE(sheet.get_objects().empty());
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < 3; ++i) {
|
||||||
|
REQUIRE_NOTHROW(gestionnaire.pop_object(sheet));
|
||||||
|
}
|
||||||
|
REQUIRE(sheet.get_objects().empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[D] Printing Billy's objects", "[printing]") {
|
||||||
|
constexpr std::array<BillyObjects::billyObject, 12> all_objects{
|
||||||
|
weapons::Sword,
|
||||||
|
weapons::Lance,
|
||||||
|
weapons::Morgenstern,
|
||||||
|
weapons::Bow,
|
||||||
|
equipments::Chainmail,
|
||||||
|
equipments::CookingPot,
|
||||||
|
equipments::PamphletTourist,
|
||||||
|
equipments::MedicKit,
|
||||||
|
tools::Fourche,
|
||||||
|
tools::Dagger,
|
||||||
|
tools::RockClimbingKit,
|
||||||
|
tools::SackOfGrain,
|
||||||
|
};
|
||||||
|
for (const auto &object: all_objects) {
|
||||||
|
REQUIRE_NOTHROW(BillyObjects::billy_object_to_string(object));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -229,9 +229,6 @@ namespace character {
|
|||||||
case toolsHash:
|
case toolsHash:
|
||||||
billy.push_back(static_cast<tools>(value));
|
billy.push_back(static_cast<tools>(value));
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
SPDLOG_CRITICAL("Deserialize billy objects error, wrong hash.");
|
|
||||||
throw std::runtime_error("Deserialize billy objects error, wrong hash.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user