PkmnLib/tests/ScriptTests/MetadataTests.cpp

67 lines
2.5 KiB
C++

#ifdef TESTS_BUILD
#include "../../extern/doctest.hpp"
#include "../../src/ScriptResolving/AngelScript/AngelScriptMetadata.hpp"
TEST_CASE("Metadata without parameters") {
auto m = AngelscriptMetadata("Foo");
REQUIRE_EQ(m.GetIdentifier(), "Foo"_cnc);
}
TEST_CASE("Metadata with single parameter") {
auto m = AngelscriptMetadata("Foo bar=zet");
REQUIRE_EQ(m.GetIdentifier(), "Foo"_cnc);
REQUIRE_EQ(m.GetParameter("bar"_cnc), "zet");
}
TEST_CASE("Metadata with single parameter with trailing space") {
auto m = AngelscriptMetadata("Foo bar=zet ");
REQUIRE_EQ(m.GetIdentifier(), "Foo"_cnc);
REQUIRE_EQ(m.GetParameter("bar"_cnc), "zet");
}
TEST_CASE("Metadata with single parameter with two spaces") {
auto m = AngelscriptMetadata("Foo bar=zet");
REQUIRE_EQ(m.GetIdentifier(), "Foo"_cnc);
REQUIRE_EQ(m.GetParameter("bar"_cnc), "zet");
}
TEST_CASE("Metadata with two parameters") {
auto m = AngelscriptMetadata("Foo bar=zet met=blabla");
REQUIRE_EQ(m.GetIdentifier(), "Foo"_cnc);
REQUIRE_EQ(m.GetParameter("bar"_cnc), "zet");
REQUIRE_EQ(m.GetParameter("met"_cnc), "blabla");
}
TEST_CASE("Metadata with two parameters and two spaces") {
auto m = AngelscriptMetadata("Foo bar=zet met=blabla");
REQUIRE_EQ(m.GetIdentifier(), "Foo"_cnc);
REQUIRE_EQ(m.GetParameter("bar"_cnc), "zet");
REQUIRE_EQ(m.GetParameter("met"_cnc), "blabla");
}
TEST_CASE("Metadata with single parameter in quotes") {
auto m = AngelscriptMetadata("Foo bar=\"this is a test string\"");
REQUIRE_EQ(m.GetIdentifier(), "Foo"_cnc);
REQUIRE_EQ(m.GetParameter("bar"_cnc), "this is a test string");
}
TEST_CASE("Metadata with single parameter in quotes with trailing space") {
auto m = AngelscriptMetadata("Foo bar=\"this is a test string\" ");
REQUIRE_EQ(m.GetIdentifier(), "Foo"_cnc);
REQUIRE_EQ(m.GetParameter("bar"_cnc), "this is a test string");
}
TEST_CASE("Metadata with single parameter in quotes without closing quote") {
auto m = AngelscriptMetadata("Foo bar=\"this is a test string");
REQUIRE_EQ(m.GetIdentifier(), "Foo"_cnc);
REQUIRE_EQ(m.GetParameter("bar"_cnc), "this is a test string");
}
TEST_CASE("Metadata with two parameters in quotes") {
auto m = AngelscriptMetadata("Foo bar=\"this is a test string\" parameter2=\"xoxo another string\"");
REQUIRE_EQ(m.GetIdentifier(), "Foo"_cnc);
REQUIRE_EQ(m.GetParameter("bar"_cnc), "this is a test string");
REQUIRE_EQ(m.GetParameter("parameter2"_cnc), "xoxo another string");
}
#endif