Skip to content
Snippets Groups Projects
Commit 436c5c0d authored by Sylvester Joosten's avatar Sylvester Joosten
Browse files

treat 'weight' as optional variable, initialized to 1

parent ef72a933
No related branches found
No related tags found
1 merge request!17Aggregate benchmark results
......@@ -69,17 +69,20 @@ struct test_definition_error : exception {
// - result: pass/fail/error
struct test {
test(nlohmann::json definition) : json{std::move(definition)} {
json["weight"] = 1.0;
// initialize with error (as we don't have a value yet)
error();
// Check that all required fields are present
for (const auto& field : {"name", "title", "description", "quantity",
"target", "value", "weight", "result"}) {
"target", "value", "result"}) {
if (json.find(field) == json.end()) {
throw test_definition_error{
fmt::format("Error in test definition: field '{}' missing", field)};
}
}
// Default "weight" to 1 if not set
if (json.find("weight") == json.end()) {
json["weight"] = 1.0;
}
}
// Set this test to pass/fail/error
void pass(double value) { update_result("pass", value); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment