From ab5f63e0873a90ecf333ffce3678e2f96f98571c Mon Sep 17 00:00:00 2001 From: wraitii Date: Mon, 22 Apr 2019 12:07:30 +0000 Subject: [PATCH] Add tests for the hierarchical pathfinder. These variously test some simple MakeGoalReachable and FindNearestNavcell calls, as well as checking edges and regions when updating the map. Differential Revision: https://code.wildfiregames.com/D1833 This was SVN commit r22205. --- .../simulation2/helpers/HierarchicalPathfinder.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/simulation2/helpers/HierarchicalPathfinder.h b/source/simulation2/helpers/HierarchicalPathfinder.h index d928838ea6..664307da23 100644 --- a/source/simulation2/helpers/HierarchicalPathfinder.h +++ b/source/simulation2/helpers/HierarchicalPathfinder.h @@ -42,10 +42,19 @@ * region and then doing a relatively small graph search. */ +#ifdef TEST +class TestCmpPathfinder; +class TestHierarchicalPathfinder; +#endif + class HierarchicalOverlay; class HierarchicalPathfinder { +#ifdef TEST + friend class TestCmpPathfinder; + friend class TestHierarchicalPathfinder; +#endif public: struct RegionID { @@ -142,6 +151,13 @@ private: void RegionNavcellNearest(u16 r, int iGoal, int jGoal, int& iBest, int& jBest, u32& dist2Best) const; bool RegionNearestNavcellInGoal(u16 r, u16 i0, u16 j0, const PathGoal& goal, u16& iOut, u16& jOut, u32& dist2Best) const; + +#ifdef TEST + bool operator==(const Chunk& b) const + { + return (m_ChunkI == b.m_ChunkI && m_ChunkJ == b.m_ChunkJ && m_NumRegions == b.m_NumRegions && memcmp(&m_Regions, &b.m_Regions, sizeof(u16) * CHUNK_SIZE * CHUNK_SIZE) == 0); + } +#endif }; typedef std::map > EdgesMap;