PkmnLib/tests/ScriptTests/Angelscript/MetadataTests.cpp

68 lines
2.5 KiB
C++
Raw Permalink Normal View History

#ifdef TESTS_BUILD
#include "../../../src/ScriptResolving/AngelScript/AngelScriptMetadata.hpp"
#include "Arbutils/StringView.hpp"
#include "doctest.h"
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