mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 19:50:03 -06:00
Renaming Offence to Offense
Renaming TestResult::offenders to TestResult::offenses
This commit is contained in:
@@ -39,8 +39,13 @@ namespace documentation {
|
||||
using Optional = ghoul::Boolean;
|
||||
using Exhaustive = ghoul::Boolean;
|
||||
|
||||
/**
|
||||
* The TestResult structure returns the information from the #testSpecification method. It
|
||||
* contains the information whether test specification test was successful
|
||||
* (TestResult::success) and a list of Offence%s
|
||||
*/
|
||||
struct TestResult {
|
||||
struct Offence {
|
||||
struct Offense {
|
||||
enum class Reason {
|
||||
MissingKey,
|
||||
ExtraKey,
|
||||
@@ -51,7 +56,7 @@ struct TestResult {
|
||||
Reason reason;
|
||||
};
|
||||
bool success;
|
||||
std::vector<Offence> offenders;
|
||||
std::vector<Offense> offenses;
|
||||
};
|
||||
|
||||
struct SpecificationError : public ghoul::RuntimeError {
|
||||
|
||||
@@ -40,11 +40,11 @@ TestResult TemplateVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
return{ true, {} };
|
||||
}
|
||||
else {
|
||||
return { false, { { key, TestResult::Offence::Reason::WrongType } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::WrongType } } };
|
||||
}
|
||||
}
|
||||
else {
|
||||
return { false, { { key, TestResult::Offence::Reason::MissingKey } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::MissingKey } } };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ TestResult OperatorVerifier<T, Op>::operator()(const ghoul::Dictionary& dict,
|
||||
return { true, {} };
|
||||
}
|
||||
else {
|
||||
return { false, { { key, TestResult::Offence::Reason::Verification }}};
|
||||
return { false, { { key, TestResult::Offense::Reason::Verification }}};
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -141,7 +141,7 @@ TestResult InListVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
return { true, {} };
|
||||
}
|
||||
else {
|
||||
return { false, { { key, TestResult::Offence::Reason::Verification } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::Verification } } };
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -183,7 +183,7 @@ TestResult NotInListVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
return { true, {} };
|
||||
}
|
||||
else {
|
||||
return { false, { { key, TestResult::Offence::Reason::Verification } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::Verification } } };
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -228,7 +228,7 @@ TestResult InRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
return { true, {} };
|
||||
}
|
||||
else {
|
||||
return { false, { { key, TestResult::Offence::Reason::Verification } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::Verification } } };
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -258,7 +258,7 @@ TestResult NotInRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
typename T::Type val = dict.value<typename T::Type>(key);
|
||||
|
||||
if (val >= lower && val <= upper) {
|
||||
return { false, { { key, TestResult::Offence::Reason::Verification } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::Verification } } };
|
||||
}
|
||||
else {
|
||||
return { true, {} };
|
||||
|
||||
@@ -31,16 +31,16 @@ namespace {
|
||||
const std::string Wildcard = "*";
|
||||
|
||||
// Structure used to make offences unique
|
||||
struct OffenceCompare {
|
||||
using Offence = openspace::documentation::TestResult::Offence;
|
||||
bool operator()(const Offence& lhs, const Offence& rhs) const
|
||||
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<Offence::Reason>(lhs.reason) <
|
||||
std::underlying_type_t<Offence::Reason>(rhs.reason);
|
||||
return std::underlying_type_t<Offense::Reason>(lhs.reason) <
|
||||
std::underlying_type_t<Offense::Reason>(rhs.reason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ TestResult testSpecification(const Documentation& d, const ghoul::Dictionary& di
|
||||
TestResult res = verifier(dictionary, key);
|
||||
if (!res.success) {
|
||||
result.success = false;
|
||||
result.offenders.insert(
|
||||
result.offenders.end(),
|
||||
res.offenders.begin(),
|
||||
res.offenders.end()
|
||||
result.offenses.insert(
|
||||
result.offenses.end(),
|
||||
res.offenses.begin(),
|
||||
res.offenses.end()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -106,10 +106,10 @@ TestResult testSpecification(const Documentation& d, const ghoul::Dictionary& di
|
||||
TestResult res = verifier(dictionary, p.key);
|
||||
if (!res.success) {
|
||||
result.success = false;
|
||||
result.offenders.insert(
|
||||
result.offenders.end(),
|
||||
res.offenders.begin(),
|
||||
res.offenders.end()
|
||||
result.offenses.insert(
|
||||
result.offenses.end(),
|
||||
res.offenses.begin(),
|
||||
res.offenses.end()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -135,8 +135,8 @@ TestResult testSpecification(const Documentation& d, const ghoul::Dictionary& di
|
||||
|
||||
if (it == d.entries.end()) {
|
||||
result.success = false;
|
||||
result.offenders.push_back(
|
||||
{ key, TestResult::Offence::Reason::ExtraKey }
|
||||
result.offenses.push_back(
|
||||
{ key, TestResult::Offense::Reason::ExtraKey }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -144,10 +144,10 @@ TestResult testSpecification(const Documentation& d, const ghoul::Dictionary& di
|
||||
|
||||
// Remove duplicate offenders that might occur if multiple rules apply to a single
|
||||
// key and more than one of these rules are broken
|
||||
std::set<TestResult::Offence, OffenceCompare> uniqueOffenders(
|
||||
result.offenders.begin(), result.offenders.end()
|
||||
std::set<TestResult::Offense, OffenseCompare> uniqueOffenders(
|
||||
result.offenses.begin(), result.offenses.end()
|
||||
);
|
||||
result.offenders = std::vector<TestResult::Offence>(
|
||||
result.offenses = std::vector<TestResult::Offense>(
|
||||
uniqueOffenders.begin(), uniqueOffenders.end()
|
||||
);
|
||||
|
||||
|
||||
@@ -103,16 +103,16 @@ TestResult IntVerifier::operator()(const ghoul::Dictionary & dict,
|
||||
return { true,{} };
|
||||
}
|
||||
else {
|
||||
return { false, { { key, TestResult::Offence::Reason::WrongType } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::WrongType } } };
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If we don't have a double value, we cannot have an int value
|
||||
return { false, { { key, TestResult::Offence::Reason::WrongType } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::WrongType } } };
|
||||
}
|
||||
}
|
||||
else {
|
||||
return { false, { {key, TestResult::Offence::Reason::MissingKey }}};
|
||||
return { false, { {key, TestResult::Offense::Reason::MissingKey }}};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ TestResult TableVerifier::operator()(const ghoul::Dictionary& dict,
|
||||
ghoul::Dictionary d = dict.value<ghoul::Dictionary>(key);
|
||||
TestResult res = testSpecification({ "", doc, exhaustive }, d);
|
||||
|
||||
for (TestResult::Offence& s : res.offenders) {
|
||||
for (TestResult::Offense& s : res.offenses) {
|
||||
s.offender = key + "." + s.offender;
|
||||
}
|
||||
|
||||
@@ -145,11 +145,11 @@ TestResult TableVerifier::operator()(const ghoul::Dictionary& dict,
|
||||
}
|
||||
else {
|
||||
if (dict.hasKey(key)) {
|
||||
return { false, { { key, TestResult::Offence::Reason::WrongType } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::WrongType } } };
|
||||
|
||||
}
|
||||
else {
|
||||
return { false, { { key, TestResult::Offence::Reason::MissingKey } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::MissingKey } } };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ TestResult AndVerifier::operator()(const ghoul::Dictionary& dict,
|
||||
return { true, {} };
|
||||
}
|
||||
else {
|
||||
return { false, { { key, TestResult::Offence::Reason::Verification } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::Verification } } };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ TestResult OrVerifier::operator()(const ghoul::Dictionary& dict,
|
||||
return { true, {} };
|
||||
}
|
||||
else {
|
||||
return { false, { { key, TestResult::Offence::Reason::Verification } } };
|
||||
return { false, { { key, TestResult::Offense::Reason::Verification } } };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user