Skip to content

Commit

Permalink
#5623: Adjust unit tests covering the source/base node specifics
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed May 24, 2021
1 parent d5157c2 commit 253e95e
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions test/MapMerging.cpp
Expand Up @@ -237,20 +237,6 @@ inline ComparisonResult::Ptr performComparison(const std::string& targetMap, con
return GraphComparer::Compare(resource->getRootNode(), GlobalMapModule().getRoot());
}

inline bool resultHasEntityDifference(const ComparisonResult::Ptr& result, const std::string& name,
const ComparisonResult::EntityDifference::Type type)
{
for (const auto& difference : result->differingEntities)
{
if (difference.entityName == name && difference.type == type)
{
return true;
}
}

return false;
}

inline std::size_t countPrimitiveDifference(const ComparisonResult::EntityDifference& diff,
const ComparisonResult::PrimitiveDifference::Type type)
{
Expand Down Expand Up @@ -299,16 +285,28 @@ TEST_F(MapMergeTest, DetectMissingEntities)
auto result = performComparison("maps/fingerprinting.mapx", _context.getTestProjectPath() + "maps/fingerprinting_2.mapx");

// The player start has been removed in the changed map
EXPECT_TRUE(resultHasEntityDifference(result, "info_player_start_1", ComparisonResult::EntityDifference::Type::EntityMissingInSource));
auto diff = getEntityDifference(result, "info_player_start_1");

EXPECT_EQ(diff.type, ComparisonResult::EntityDifference::Type::EntityMissingInSource);
EXPECT_TRUE(diff.baseNode);
EXPECT_FALSE(diff.sourceNode); // source node is missing, so it must be empty
}

TEST_F(MapMergeTest, DetectAddedEntities)
{
auto result = performComparison("maps/fingerprinting.mapx", _context.getTestProjectPath() + "maps/fingerprinting_2.mapx");

// light_3 start has been added to the changed map
EXPECT_TRUE(resultHasEntityDifference(result, "light_3", ComparisonResult::EntityDifference::Type::EntityMissingInBase));
EXPECT_TRUE(resultHasEntityDifference(result, "func_static_2", ComparisonResult::EntityDifference::Type::EntityMissingInBase));
auto diff = getEntityDifference(result, "light_3");

EXPECT_EQ(diff.type, ComparisonResult::EntityDifference::Type::EntityMissingInBase);
EXPECT_TRUE(diff.sourceNode);
EXPECT_FALSE(diff.baseNode); // base node is missing, so it must be empty

diff = getEntityDifference(result, "func_static_2");
EXPECT_EQ(diff.type, ComparisonResult::EntityDifference::Type::EntityMissingInBase);
EXPECT_TRUE(diff.sourceNode);
EXPECT_FALSE(diff.baseNode); // base node is missing, so it must be empty
}

TEST_F(MapMergeTest, DetectAddedKeyValues)
Expand Down

0 comments on commit 253e95e

Please sign in to comment.