Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ped-dyn-emp/petrack
1 result
Show changes
Commits on Source (5)
......@@ -114,6 +114,11 @@ std::variant<std::unordered_map<int, float>, std::string> IO::readHeightFile(con
return "Duplicate entry for markerID = " + std::to_string(markerID) + ".";
}
}
else if(splitLine.empty())
{
// just ignore empty lines
continue;
}
else
{
return "Line should contain exactly 2 values: id height. But it contains " +
......@@ -320,6 +325,11 @@ std::variant<std::unordered_map<int, int>, std::string> IO::readMarkerIDFile(con
return "Duplicate entry for personID = " + std::to_string(personID) + ".";
}
}
else if(splitLine.empty())
{
// ignore empty lines
continue;
}
else
{
return "Line should contain exactly 2 values: personID markerID. But it contains " +
......
......@@ -216,6 +216,41 @@ TEST_CASE("src/IO", "[tracking][io]")
CHECK_THAT(markerHeightsVec, Catch::UnorderedEquals(referenceValuesVec));
}
SECTION("empty line at end of file")
{
std::for_each(
std::begin(referenceValuesMap),
std::end(referenceValuesMap),
[&heightFile](const std::pair<int, float> &element)
{ heightFile << element.first << " " << element.second << std::endl; });
heightFile << std::endl;
heightFile.close();
auto ret = IO::readHeightFile(QString::fromStdString(heigtFileName));
REQUIRE(std::holds_alternative<std::unordered_map<int, float>>(ret));
std::unordered_map<int, float> markerHeights = std::get<std::unordered_map<int, float>>(ret);
std::vector<std::pair<int, float>> markerHeightsVec;
markerHeightsVec.assign(std::begin(markerHeights), std::end(markerHeights));
CHECK_THAT(markerHeightsVec, Catch::UnorderedEquals(referenceValuesVec));
}
SECTION("empty lines throughout the file")
{
std::for_each(
std::begin(referenceValuesMap),
std::end(referenceValuesMap),
[&heightFile](const std::pair<int, float> &element)
{ heightFile << element.first << " " << element.second << "\n\n"; });
heightFile.close();
auto ret = IO::readHeightFile(QString::fromStdString(heigtFileName));
REQUIRE(std::holds_alternative<std::unordered_map<int, float>>(ret));
std::unordered_map<int, float> markerHeights = std::get<std::unordered_map<int, float>>(ret);
std::vector<std::pair<int, float>> markerHeightsVec;
markerHeightsVec.assign(std::begin(markerHeights), std::end(markerHeights));
CHECK_THAT(markerHeightsVec, Catch::UnorderedEquals(referenceValuesVec));
}
SECTION("z-coordinate in cm")
{
......@@ -463,6 +498,39 @@ TEST_CASE("src/IO", "[tracking][io]")
CHECK_THAT(markerHeightsVec, Catch::UnorderedEquals(referenceValuesVec));
}
SECTION("empty line at end of file")
{
for(const auto &[personID, markerID] : referenceValuesMap)
{
markerFile << personID << " " << markerID << std::endl;
}
markerFile << std::endl;
markerFile.close();
auto ret = IO::readMarkerIDFile(QString::fromStdString(markerFileName));
REQUIRE(std::holds_alternative<std::unordered_map<int, int>>(ret));
auto markerIDs = std::get<std::unordered_map<int, int>>(ret);
std::vector<std::pair<int, int>> markerHeightsVec;
markerHeightsVec.assign(std::begin(markerIDs), std::end(markerIDs));
CHECK_THAT(markerHeightsVec, Catch::UnorderedEquals(referenceValuesVec));
}
SECTION("empty lines throughout the file")
{
for(const auto &[personID, markerID] : referenceValuesMap)
{
markerFile << personID << " " << markerID << "\n\n";
}
markerFile.close();
auto ret = IO::readMarkerIDFile(QString::fromStdString(markerFileName));
REQUIRE(std::holds_alternative<std::unordered_map<int, int>>(ret));
auto markerIDs = std::get<std::unordered_map<int, int>>(ret);
std::vector<std::pair<int, int>> markerHeightsVec;
markerHeightsVec.assign(std::begin(markerIDs), std::end(markerIDs));
CHECK_THAT(markerHeightsVec, Catch::UnorderedEquals(referenceValuesVec));
}
SECTION("with comments")
{
markerFile << "# this is a comment at the beginning" << std::endl;
......