|
@@ -23,10 +23,16 @@ TEST(director, director_debugging) {
|
|
|
Director dir;
|
|
|
std::vector<std::string> client;
|
|
|
std::vector<std::string> server;
|
|
|
- dir.to_client = [&client](const std::string line) -> void { client.push_back(line); };
|
|
|
- dir.to_server = [&server](const std::string &line, const std::string &source) -> void { server.push_back(line); };
|
|
|
- // dir.to_server = [](const std::string &line, const std::string &source) -> void { server.push_back(line); };
|
|
|
- // activating the game gets this over to dir.galaxy.username.
|
|
|
+ dir.to_client = [&client](const std::string line) -> void {
|
|
|
+ client.push_back(line);
|
|
|
+ };
|
|
|
+ dir.to_server = [&server](const std::string &line,
|
|
|
+ const std::string &source) -> void {
|
|
|
+ server.push_back(line);
|
|
|
+ };
|
|
|
+ // dir.to_server = [](const std::string &line, const std::string &source) ->
|
|
|
+ // void { server.push_back(line); }; activating the game gets this over to
|
|
|
+ // dir.galaxy.username.
|
|
|
dir.username = "test";
|
|
|
|
|
|
// should I setup galaxy-N-test.yaml ? Probably yes.
|
|
@@ -78,7 +84,10 @@ TEST(director, director_parsing_density) {
|
|
|
std::vector<std::string> client;
|
|
|
std::vector<std::string> server;
|
|
|
dir.to_client = [&client](const std::string line) { client.push_back(line); };
|
|
|
- dir.to_server = [&server](const std::string &line, const std::string &source) { server.push_back(line); };
|
|
|
+ dir.to_server = [&server](const std::string &line,
|
|
|
+ const std::string &source) {
|
|
|
+ server.push_back(line);
|
|
|
+ };
|
|
|
|
|
|
dir.username = "test";
|
|
|
std::string lines[] = {
|
|
@@ -129,7 +138,7 @@ TEST(director, director_parsing_density) {
|
|
|
{629, 1, 4, 0, false, true},
|
|
|
{711, 101, 6, 0, false, true}}};
|
|
|
|
|
|
- for (auto const& s : dense) {
|
|
|
+ for (auto const &s : dense) {
|
|
|
auto d = dir.galaxy.dscan.find(s.sector);
|
|
|
EXPECT_EQ(d, s) << "Sector " << s.sector << " density";
|
|
|
}
|
|
@@ -137,57 +146,59 @@ TEST(director, director_parsing_density) {
|
|
|
// Check that each sector was correctly processed
|
|
|
std::vector<int> sectors = {70, 441, 575, 600, 629, 711};
|
|
|
|
|
|
- json sector_data;
|
|
|
- sector_data[70]["density"] = 0;
|
|
|
- sector_data[70]["warps"] = 6;
|
|
|
- sector_data[70]["navhaz"] = 0;
|
|
|
- sector_data[70]["anom"] = false;
|
|
|
- sector_data[70]["known"] = true;
|
|
|
- sector_data[441]["density"] = 100;
|
|
|
- sector_data[441]["warps"] = 2;
|
|
|
- sector_data[441]["navhaz"] = 0;
|
|
|
- sector_data[441]["anom"] = false;
|
|
|
- sector_data[441]["known"] = true;
|
|
|
- sector_data[575]["density"] = 1000;
|
|
|
- sector_data[575]["warps"] = 2;
|
|
|
- sector_data[575]["navhaz"] = 15;
|
|
|
- sector_data[575]["anom"] = true;
|
|
|
- sector_data[575]["known"] = false;
|
|
|
- sector_data[600]["density"] = 40;
|
|
|
- sector_data[600]["warps"] = 6;
|
|
|
- sector_data[600]["navhaz"] = 0;
|
|
|
- sector_data[600]["anom"] = false;
|
|
|
- sector_data[600]["known"] = true;
|
|
|
- sector_data[629]["density"] = 1;
|
|
|
- sector_data[629]["warps"] = 4;
|
|
|
- sector_data[629]["navhaz"] = 0;
|
|
|
- sector_data[629]["anom"] = false;
|
|
|
- sector_data[629]["known"] = true;
|
|
|
- sector_data[711]["density"] = 101;
|
|
|
- sector_data[711]["warps"] = 6;
|
|
|
- sector_data[711]["navhaz"] = 0;
|
|
|
- sector_data[711]["anom"] = false;
|
|
|
- sector_data[711]["known"] = true;
|
|
|
+ json sector_data = {{"70",
|
|
|
+ {{"density", 0},
|
|
|
+ {"warps", 6},
|
|
|
+ {"navhaz", 0},
|
|
|
+ {"anom", false},
|
|
|
+ {"known", true}}},
|
|
|
+ {"441",
|
|
|
+ {{"density", 100},
|
|
|
+ {"warps", 2},
|
|
|
+ {"navhaz", 0},
|
|
|
+ {"anom", false},
|
|
|
+ {"known", true}}},
|
|
|
+ {"575",
|
|
|
+ {{"density", 1000},
|
|
|
+ {"warps", 2},
|
|
|
+ {"navhaz", 15},
|
|
|
+ {"anom", true},
|
|
|
+ {"known", false}}},
|
|
|
+ {"600",
|
|
|
+ {{"density", 40},
|
|
|
+ {"warps", 6},
|
|
|
+ {"navhaz", 0},
|
|
|
+ {"anom", false},
|
|
|
+ {"known", true}}},
|
|
|
+ {"629",
|
|
|
+ {{"density", 1},
|
|
|
+ {"warps", 4},
|
|
|
+ {"navhaz", 0},
|
|
|
+ {"anom", false},
|
|
|
+ {"known", true}}},
|
|
|
+ {"711",
|
|
|
+ {{"density", 101},
|
|
|
+ {"warps", 6},
|
|
|
+ {"navhaz", 0},
|
|
|
+ {"anom", false},
|
|
|
+ {"known", true}}}};
|
|
|
|
|
|
density_scan &ds = dir.galaxy.dscan;
|
|
|
|
|
|
for (int x = 0; x < ds.pos; ++x) {
|
|
|
int sector = sectors[x];
|
|
|
+ // json prefers strings for keys.
|
|
|
+ std::string sector_s = std::to_string(sector);
|
|
|
// GTEST_COUT << "Testing Sector " << sector << std::endl;
|
|
|
- EXPECT_EQ(ds.d[x].density,
|
|
|
- json_int(sector_data[sector]["density"]))
|
|
|
+ EXPECT_EQ(ds.d[x].density, json_int(sector_data[sector_s]["density"]))
|
|
|
<< "Sector " << sector << " density";
|
|
|
- EXPECT_EQ(ds.d[x].warps,
|
|
|
- json_int(sector_data[sector]["warps"]))
|
|
|
+ EXPECT_EQ(ds.d[x].warps, json_int(sector_data[sector_s]["warps"]))
|
|
|
<< "Sector " << sector << " warps";
|
|
|
- EXPECT_EQ(ds.d[x].navhaz,
|
|
|
- json_int(sector_data[sector]["navhaz"]))
|
|
|
+ EXPECT_EQ(ds.d[x].navhaz, json_int(sector_data[sector_s]["navhaz"]))
|
|
|
<< "Sector " << sector << " navhaz";
|
|
|
- EXPECT_EQ(ds.d[x].anomaly,
|
|
|
- json_bool(sector_data[sector]["anom"]))
|
|
|
+ EXPECT_EQ(ds.d[x].anomaly, json_bool(sector_data[sector_s]["anom"]))
|
|
|
<< "Sector " << sector << " anom";
|
|
|
- EXPECT_EQ(ds.d[x].known,
|
|
|
- json_bool(sector_data[sector]["known"]))
|
|
|
+ EXPECT_EQ(ds.d[x].known, json_bool(sector_data[sector_s]["known"]))
|
|
|
<< "Sector " << sector << " known";
|
|
|
}
|
|
|
}
|