Skip to content

Commit

Permalink
TESTS: Add unit test for NWN2 items and inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
rjshae authored and DrMcCoy committed Feb 27, 2019
1 parent 4a92335 commit 59cb2ac
Show file tree
Hide file tree
Showing 2 changed files with 5,042 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/engines/nwn2/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "tests/engines/nwn2/creature.h"
#include "tests/engines/nwn2/creature2.h"
#include "tests/engines/nwn2/creature3.h"

#include "src/common/memreadstream.h"
#include "src/common/scopedptr.h"
Expand All @@ -35,6 +36,7 @@

#include "src/engines/nwn2/creature.h"
#include "src/engines/nwn2/types.h"
#include "src/engines/nwn2/item.h"

static const float kEpsilon = 1e-5f;

Expand Down Expand Up @@ -159,3 +161,25 @@ GTEST_TEST(NWN2Creature, creature2) {
EXPECT_TRUE(cr->hasFeat(1870)) << "Feat: Fire Genasi Resistance";
EXPECT_TRUE(cr->hasFeat(1874)) << "Feat: Fire Genasi Reach to the Blaze";
}

GTEST_TEST(NWN2Creature, inventory) {
Common::ScopedPtr<Common::MemoryReadStream> stream(new Common::MemoryReadStream(kDataCreature3));
if (!stream)
throw Common::Exception("No test data available");
Common::ScopedPtr<Aurora::GFF3File> gff(new Aurora::GFF3File(stream.release(), MKTAG('R', 'O', 'S', ' ')));

// Load the PC
const Aurora::GFF3Struct &top = gff->getTopLevel();
Common::ScopedPtr<Engines::NWN2::Creature> cr(new Engines::NWN2::Creature(top));

EXPECT_STREQ(cr->getTag().c_str(), "elanee");
EXPECT_STREQ(cr->getFirstItemInInventory()->getTag().c_str(), "NW_WBLMCL002");
EXPECT_STREQ(cr->getNextItemInInventory()->getTag().c_str(), "NW_IT_SPARSCR204");
EXPECT_STREQ(cr->getNextItemInInventory()->getTag().c_str(), "NW_WSPSC001");
EXPECT_STREQ(cr->getNextItemInInventory()->getTag().c_str(), "X2_IT_SPDVSCR001");
EXPECT_STREQ(cr->getNextItemInInventory()->getTag().c_str(), "NW_WMGWN005");
EXPECT_STREQ(cr->getNextItemInInventory()->getTag().c_str(), "NW_IT_SPARSCR202");
EXPECT_STREQ(cr->getNextItemInInventory()->getTag().c_str(), "NW_IT_SPDVSCR203");
EXPECT_STREQ(cr->getNextItemInInventory()->getTag().c_str(), "x2_nash_boot");
EXPECT_STREQ(cr->getNextItemInInventory()->getTag().c_str(), "NW_WSWSC001");
}

0 comments on commit 59cb2ac

Please sign in to comment.