Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Test enumerated pointfiles have correct names
PointfileFunctor now accepts fs::path references rather than bare std::strings,
and this information is now recorded and examined in the unit test to ensure
the returned pointfiles have the correct filenames (ignoring parent paths).
  • Loading branch information
Matthew Mott committed May 18, 2021
1 parent e1072c8 commit dc165ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 4 additions & 2 deletions include/imap.h
Expand Up @@ -7,6 +7,8 @@
#include "ikeyvaluestore.h"
#include <sigc++/signal.h>

#include <os/fs.h>

// Registry setting for suppressing the map load progress dialog
const char* const RKEY_MAP_SUPPRESS_LOAD_STATUS_DIALOG = "user/ui/map/suppressMapLoadDialog";

Expand Down Expand Up @@ -170,8 +172,8 @@ class IMap :
// Exports the current selection to the given output stream, using the given map format
virtual void exportSelected(std::ostream& out, const map::MapFormatPtr& format) = 0;

/// Functor to receive pointfile names
using PointfileFunctor = std::function<void(const std::string&)>;
/// Functor to receive pointfile paths
using PointfileFunctor = std::function<void(const fs::path&)>;

/// Enumerate pointfiles associated with the current map
virtual void forEachPointfile(PointfileFunctor func) const = 0;
Expand Down
15 changes: 9 additions & 6 deletions test/PointTrace.cpp
Expand Up @@ -39,13 +39,13 @@ TEST_F(PointTraceTest, ConstructPointTraceWithData)
namespace
{

using StringList = std::list<std::string>;
using Paths = std::vector<fs::path>;

// Get pointfile names in a list
StringList pointfiles()
Paths pointfiles()
{
StringList result;
GlobalMapModule().forEachPointfile([&](const std::string& pf)
Paths result;
GlobalMapModule().forEachPointfile([&](const fs::path& pf)
{ result.push_back(pf); });
return result;
}
Expand All @@ -56,8 +56,11 @@ TEST_F(PointTraceTest, IdentifyMapPointfiles)
{
GlobalCommandSystem().executeCommand("OpenMap", std::string("altar.map"));

// Check the number of pointfiles for this map
EXPECT_EQ(pointfiles().size(), 2);
// Check the pointfiles for this map
auto pfs = pointfiles();
ASSERT_EQ(pfs.size(), 2);
EXPECT_EQ(pfs[0].filename(), "altar.lin");
EXPECT_EQ(pfs[1].filename(), "altar_portalL_544_64_112.lin");
}

TEST_F(PointTraceTest, PointFilesAssociatedWithCorrectMap)
Expand Down

0 comments on commit dc165ce

Please sign in to comment.