Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#6095: test accessing some values from .game file
It turns out that the tests ARE loading .game files, although these are
not under the test/resources directory so it remains to be seen whether
this test will encounter any problems on other platforms. Possibly it
will only work if the main DR resources (i.e. install/*) are installed
to their expected location before the tests are run.
  • Loading branch information
Matthew Mott committed Sep 14, 2022
1 parent e68aff0 commit 0c52b0b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions include/igame.h
Expand Up @@ -26,8 +26,11 @@ class IGame
virtual ~IGame() {}

/**
* \brief
* Get a string key value from the game file.
* \brief Get a string key value from the game file.
*
* The "key values" are the attributes on the top-level <game> node, for example "type",
* "name" and "index". Originally these were the only data items stored in the .game
* file, before it was expanded into a general XML tree.
*
* \param key
* Name of the key to retrieve. If this key does not exist, a warning is
Expand Down
11 changes: 11 additions & 0 deletions test/Game.cpp
Expand Up @@ -37,4 +37,15 @@ TEST_F(GameTest, GetGameList)
EXPECT_EQ(games[2]->getName(), "Doom 3 Demo");
}

TEST_F(GameTest, GetGameKeyValues)
{
auto game = GlobalGameManager().currentGame();

// Default game is darkmod.game
EXPECT_EQ(game->getKeyValue("type"), "doom3");
EXPECT_EQ(game->getKeyValue("name"), "The Dark Mod 2.0 (Standalone)");
EXPECT_EQ(game->getKeyValue("index"), "10");
EXPECT_EQ(game->getKeyValue("maptypes"), "mapdoom3");
}

}

0 comments on commit 0c52b0b

Please sign in to comment.