This commit is contained in:
@@ -7,6 +7,9 @@ static std::unordered_map<const char*, const char*> _scripts =
|
||||
std::unordered_map<const char*, const char*>{{"testScript1", R"(
|
||||
class testScript1 {
|
||||
bool testName(const Item@ i, const string &in name){ return i.Name == name; }
|
||||
bool testCategory(const Item@ i, ItemCategory category){ return i.Category == category; }
|
||||
bool testBattleCategory(const Item@ i, BattleItemCategory category){ return i.BattleCategory == category; }
|
||||
bool testPrice(const Item@ i, int price){ return i.Price == price; }
|
||||
}
|
||||
)"}};
|
||||
|
||||
@@ -55,4 +58,43 @@ TEST_CASE("Validate Item Name in Script") {
|
||||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
}
|
||||
|
||||
TEST_CASE("Validate Item Category in Script") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto data = GetScript(mainLib, "testCategory");
|
||||
|
||||
auto item = mainLib->GetItemLibrary()->GetItem("testItem");
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::Item*>(item));
|
||||
data.Context->SetArgDWord(1, static_cast<int32_t >(item->GetCategory()));
|
||||
|
||||
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
}
|
||||
|
||||
TEST_CASE("Validate Item Battle Category in Script") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto data = GetScript(mainLib, "testBattleCategory");
|
||||
|
||||
auto item = mainLib->GetItemLibrary()->GetItem("testItem");
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::Item*>(item));
|
||||
data.Context->SetArgDWord(1, static_cast<int32_t >(item->GetBattleCategory()));
|
||||
|
||||
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
}
|
||||
|
||||
TEST_CASE("Validate Item Price in Script") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto data = GetScript(mainLib, "testPrice");
|
||||
|
||||
auto item = mainLib->GetItemLibrary()->GetItem("testItem");
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::Item*>(item));
|
||||
data.Context->SetArgDWord(1, static_cast<int32_t >(item->GetPrice()));
|
||||
|
||||
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user