mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Advance MapComparer
This commit is contained in:
parent
0cc47f00c5
commit
0798ef4b2a
@ -62,9 +62,8 @@ BOOST_AUTO_TEST_CASE(CMapFormatVCMI_Simple)
|
||||
std::unique_ptr<CMap> serialized = loader.loadMap();
|
||||
|
||||
|
||||
MapComparer c;
|
||||
|
||||
BOOST_REQUIRE_MESSAGE(c(initialMap, serialized), "Serialize cycle failed");
|
||||
MapComparer c;
|
||||
c(initialMap, serialized);
|
||||
}
|
||||
catch(const std::exception & e)
|
||||
{
|
||||
|
@ -13,8 +13,74 @@
|
||||
|
||||
#include "MapComparer.h"
|
||||
|
||||
bool MapComparer::operator() (const std::unique_ptr<CMap>& lhs, const std::unique_ptr<CMap>& rhs)
|
||||
#define VCMI_CHECK_FIELD_EQUAL(field) BOOST_CHECK_EQUAL(actual->field, expected->field)
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const PlayerInfo & p)
|
||||
{
|
||||
BOOST_ERROR(" MapComparer::operator() not implemented");
|
||||
return false;
|
||||
os << "PlayerInfo";
|
||||
return os;
|
||||
}
|
||||
|
||||
bool operator!=(const PlayerInfo & actual, const PlayerInfo & expected)
|
||||
{
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MapComparer::compareHeader()
|
||||
{
|
||||
VCMI_CHECK_FIELD_EQUAL(name);
|
||||
VCMI_CHECK_FIELD_EQUAL(description);
|
||||
VCMI_CHECK_FIELD_EQUAL(difficulty);
|
||||
VCMI_CHECK_FIELD_EQUAL(levelLimit);
|
||||
|
||||
VCMI_CHECK_FIELD_EQUAL(victoryMessage);
|
||||
VCMI_CHECK_FIELD_EQUAL(defeatMessage);
|
||||
VCMI_CHECK_FIELD_EQUAL(victoryIconIndex);
|
||||
VCMI_CHECK_FIELD_EQUAL(defeatIconIndex);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(actual->players.begin(), actual->players.end(), expected->players.begin(), expected->players.end());
|
||||
|
||||
|
||||
//map size parameters are vital for further checks
|
||||
BOOST_REQUIRE_EQUAL(actual->height, expected->height);
|
||||
BOOST_REQUIRE_EQUAL(actual->width, expected->width);
|
||||
BOOST_REQUIRE_EQUAL(actual->twoLevel, expected->twoLevel);
|
||||
|
||||
BOOST_FAIL("Not implemented");
|
||||
}
|
||||
|
||||
void MapComparer::compareOptions()
|
||||
{
|
||||
BOOST_FAIL("Not implemented");
|
||||
}
|
||||
|
||||
void MapComparer::compareObjects()
|
||||
{
|
||||
BOOST_FAIL("Not implemented");
|
||||
}
|
||||
|
||||
void MapComparer::compareTerrain()
|
||||
{
|
||||
BOOST_FAIL("Not implemented");
|
||||
}
|
||||
|
||||
void MapComparer::compare()
|
||||
{
|
||||
BOOST_REQUIRE_NE((void *) actual, (void *) expected); //should not point to the same object
|
||||
BOOST_REQUIRE_MESSAGE(actual != nullptr, "Actual map is not defined");
|
||||
BOOST_REQUIRE_MESSAGE(actual != nullptr, "Expected map is not defined");
|
||||
|
||||
compareHeader();
|
||||
compareObjects();
|
||||
compareOptions();
|
||||
compareTerrain();
|
||||
}
|
||||
|
||||
void MapComparer::operator() (const std::unique_ptr<CMap>& actual, const std::unique_ptr<CMap>& expected)
|
||||
{
|
||||
this->actual = actual.get();
|
||||
this->expected = expected.get();
|
||||
compare();
|
||||
}
|
||||
|
@ -14,7 +14,17 @@
|
||||
|
||||
struct MapComparer
|
||||
{
|
||||
bool operator() (const std::unique_ptr<CMap>& lhs, const std::unique_ptr<CMap>& rhs);
|
||||
const CMap * actual;
|
||||
const CMap * expected;
|
||||
|
||||
void compareHeader();
|
||||
void compareOptions();
|
||||
void compareObjects();
|
||||
void compareTerrain();
|
||||
|
||||
void compare();
|
||||
|
||||
void operator() (const std::unique_ptr<CMap>& actual, const std::unique_ptr<CMap>& expected);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user