#include #include #include "characteristic.hpp" #include "character_sheet.hpp" using namespace character::characteristic; TEST_CASE("[A] Serialize adresse", "[serialize][0]") { Characteristic adresse{ characType::Adresse }; json serializer; REQUIRE_NOTHROW(serializer.emplace("adresse", adresse)); const auto &tester = serializer.at("adresse"); REQUIRE_NOTHROW(tester.at("base") == 1); REQUIRE_NOTHROW(tester.at("carac") == 0); REQUIRE_NOTHROW(tester.at("materiel") == 0); REQUIRE_NOTHROW(tester.at("additional") == 0); { std::ofstream file{ "adresse.json" }; file << serializer << std::flush; } } TEST_CASE("[A] Serialize chance", "[serialize][1]") { Characteristic chance{ characType::Chance }; json serializer; REQUIRE_NOTHROW(serializer.emplace("chance", chance)); const auto &tester = serializer.at("chance"); REQUIRE_NOTHROW(tester.at("base") == 3); REQUIRE_NOTHROW(tester.at("carac") == 0); REQUIRE_NOTHROW(tester.at("materiel") == 0); REQUIRE_NOTHROW(tester.at("additional") == 0); { std::ofstream file{ "chance.json" }; file << serializer << std::flush; } } TEST_CASE("[A] Serialize endurance", "[serialize][2]") { Characteristic endurance{ characType::Endurance }; json serializer; REQUIRE_NOTHROW(serializer.emplace("endurance", endurance)); const auto &tester = serializer.at("endurance"); REQUIRE_NOTHROW(tester.at("base") == 2); REQUIRE_NOTHROW(tester.at("carac") == 0); REQUIRE_NOTHROW(tester.at("materiel") == 0); REQUIRE_NOTHROW(tester.at("additional") == 0); { std::ofstream file{ "endurance.json" }; file << serializer << std::flush; } } TEST_CASE("[A] Serialize habilete", "[serialize][3]") { Characteristic habilete{ characType::Habilete }; json serializer; REQUIRE_NOTHROW(serializer.emplace("habilete", habilete)); const auto &tester = serializer.at("habilete"); REQUIRE_NOTHROW(tester.at("base") == 2); REQUIRE_NOTHROW(tester.at("carac") == 0); REQUIRE_NOTHROW(tester.at("materiel") == 0); REQUIRE_NOTHROW(tester.at("additional") == 0); { std::ofstream file{ "habilete.json" }; file << serializer << std::flush; } } TEST_CASE("[B] Deserialize adresse", "[deserialize][0]") { const json deserializer = []() -> json { std::ifstream file{ "adresse.json" }; json des = json::parse(file); return des; }(); REQUIRE_NOTHROW([&]() -> void { const auto adresse = deserializer.at("adresse").get(); REQUIRE(adresse.get_base() == 1); REQUIRE(adresse.get_carac() == 0); REQUIRE(adresse.get_materiel() == 0); REQUIRE(adresse.get_additional() == 0); }()); } TEST_CASE("[B] Deserialize chance", "[deserialize][1]") { const json deserializer = []() -> json { std::ifstream file{ "chance.json" }; json des = json::parse(file); return des; }(); REQUIRE_NOTHROW([&]() -> void { const auto adresse = deserializer.at("chance").get(); REQUIRE(adresse.get_base() == 3); REQUIRE(adresse.get_carac() == 0); REQUIRE(adresse.get_materiel() == 0); REQUIRE(adresse.get_additional() == 0); }()); } TEST_CASE("[B] Deserialize endurance", "[deserialize][2]") { const json deserializer = []() -> json { std::ifstream file{ "endurance.json" }; json des = json::parse(file); return des; }(); REQUIRE_NOTHROW([&]() -> void { const auto adresse = deserializer.at("endurance").get(); REQUIRE(adresse.get_base() == 2); REQUIRE(adresse.get_carac() == 0); REQUIRE(adresse.get_materiel() == 0); REQUIRE(adresse.get_additional() == 0); }()); } TEST_CASE("[B] Deserialize habilete", "[deserialize][3]") { const json deserializer = []() -> json { std::ifstream file{ "habilete.json" }; json des = json::parse(file); return des; }(); REQUIRE_NOTHROW([&]() -> void { const auto adresse = deserializer.at("habilete").get(); REQUIRE(adresse.get_base() == 2); REQUIRE(adresse.get_carac() == 0); REQUIRE(adresse.get_materiel() == 0); REQUIRE(adresse.get_additional() == 0); }()); }