Tests for serializer, valid.

TODO: CI
This commit is contained in:
Pcornat 2022-01-14 23:48:58 +01:00
parent a5ce3c378f
commit 0dc0329770
Signed by: Pcornat
GPG Key ID: 2F3932FF46D9ECA0

View File

@ -1,17 +1,63 @@
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
#include "characteristic/adresse.hpp"
#include "characteristic/chance.hpp"
#include "characteristic/endurance.hpp"
#include "characteristic/habilete.hpp"
using namespace character::characteristic;
TEST_CASE("Serialize adresse", "[serialize][0]") { TEST_CASE("Serialize adresse", "[serialize][0]") {
Adresse 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);
} }
TEST_CASE("Serialize chance", "[serialize][1]") { TEST_CASE("Serialize chance", "[serialize][1]") {
Chance 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);
} }
TEST_CASE("Serialize endurance", "[serialize][2]") { TEST_CASE("Serialize endurance", "[serialize][2]") {
Endurance 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);
} }
TEST_CASE("Serialize habilete", "[serialize][3]") { TEST_CASE("Serialize habilete", "[serialize][3]") {
Habilete 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);
} }