Let the ReferencingVerifier fail gracefully if a referencing identifier is not found

This commit is contained in:
Alexander Bock
2017-03-14 13:47:55 -04:00
parent 05057b963e
commit 5e2bf6e820
2 changed files with 38 additions and 28 deletions

View File

@@ -30,32 +30,33 @@
#include <set>
namespace {
// Structure used to make offenses unique
struct OffenseCompare {
using Offense = openspace::documentation::TestResult::Offense;
bool operator()(const Offense& lhs, const Offense& rhs) const {
if (lhs.offender != rhs.offender) {
return lhs.offender < rhs.offender;
}
else {
return std::underlying_type_t<Offense::Reason>(lhs.reason) <
std::underlying_type_t<Offense::Reason>(rhs.reason);
}
}
};
struct WarningCompare {
using Warning = openspace::documentation::TestResult::Warning;
bool operator()(const Warning& lhs, const Warning& rhs) const {
if (lhs.offender != rhs.offender) {
return lhs.offender < rhs.offender;
}
else {
return std::underlying_type_t<Warning::Reason>(lhs.reason) <
std::underlying_type_t<Warning::Reason>(rhs.reason);
}
// Structure used to make offenses unique
struct OffenseCompare {
using Offense = openspace::documentation::TestResult::Offense;
bool operator()(const Offense& lhs, const Offense& rhs) const {
if (lhs.offender != rhs.offender) {
return lhs.offender < rhs.offender;
}
};
else {
return std::underlying_type_t<Offense::Reason>(lhs.reason) <
std::underlying_type_t<Offense::Reason>(rhs.reason);
}
}
};
struct WarningCompare {
using Warning = openspace::documentation::TestResult::Warning;
bool operator()(const Warning& lhs, const Warning& rhs) const {
if (lhs.offender != rhs.offender) {
return lhs.offender < rhs.offender;
}
else {
return std::underlying_type_t<Warning::Reason>(lhs.reason) <
std::underlying_type_t<Warning::Reason>(rhs.reason);
}
}
};
} // namespace

View File

@@ -225,10 +225,19 @@ TestResult ReferencingVerifier::operator()(const ghoul::Dictionary& dictionary,
[this](const Documentation& doc) { return doc.id == identifier; }
);
ghoul_assert(
it != docs.end(),
"Did not find referencing identifier '" + identifier + "'"
);
if (it == docs.end()) {
res.offenses.push_back({
key,
TestResult::Offense::Reason::UnknownIdentifier
});
res.success = false;
return res;
}
//ghoul_assert(
// it != docs.end(),
// "Did not find referencing identifier '" + identifier + "'"
//);
ghoul::Dictionary d = dictionary.value<ghoul::Dictionary>(key);
TestResult r = testSpecification(*it, d);