finished rework of suite
parent
33d8e6827d
commit
fb87c61e86
|
@ -29,7 +29,7 @@ class JSON_Loader
|
||||||
// return as a JSONCPP serialized object
|
// return as a JSONCPP serialized object
|
||||||
// deprecated -- these aren't really used.
|
// deprecated -- these aren't really used.
|
||||||
// Json::Value as_serialized();
|
// Json::Value as_serialized();
|
||||||
// std::string as_string();
|
std::string as_string();
|
||||||
|
|
||||||
// safely handle deserialized type retrieval (if we want it to be safe)
|
// safely handle deserialized type retrieval (if we want it to be safe)
|
||||||
int get_serialized(Json::Value &input, std::string key, bool verbose);
|
int get_serialized(Json::Value &input, std::string key, bool verbose);
|
||||||
|
|
|
@ -55,11 +55,10 @@ void Suite::load_units_file( std::string filename, bool verbose )
|
||||||
|
|
||||||
/// Suite::get_unit - returns a contained Unit identified by name attribute.
|
/// Suite::get_unit - returns a contained Unit identified by name attribute.
|
||||||
///
|
///
|
||||||
|
/// \param result - the unit type receiving the unit's value
|
||||||
/// \param provided_name - The name of the unit being fetched.
|
/// \param provided_name - The name of the unit being fetched.
|
||||||
/// \return - The unit being fetched.
|
void Suite::get_unit(Unit & result, std::string provided_name)
|
||||||
Unit Suite::get_unit(std::string provided_name)
|
|
||||||
{
|
{
|
||||||
Unit * returnable;
|
|
||||||
bool foundMatch = false;
|
bool foundMatch = false;
|
||||||
|
|
||||||
for ( int i = 0; i < this->units.size(); i++ )
|
for ( int i = 0; i < this->units.size(); i++ )
|
||||||
|
@ -67,16 +66,16 @@ Unit Suite::get_unit(std::string provided_name)
|
||||||
std::string unit_name = this->units[i].get_name();
|
std::string unit_name = this->units[i].get_name();
|
||||||
if ( unit_name == provided_name )
|
if ( unit_name == provided_name )
|
||||||
{
|
{
|
||||||
returnable = & this->units[i];
|
result = this->units[i];
|
||||||
foundMatch = true;
|
foundMatch = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! foundMatch )
|
if (! foundMatch )
|
||||||
{
|
{
|
||||||
std::cerr << "Unit name \"" << provided_name << "\" was referenced but not defined!" << std::endl;
|
std::cerr << "Unit name \"" << provided_name << "\" was referenced but not defined!" << std::endl;
|
||||||
throw Suite_InvalidUnitMember();
|
throw Suite_InvalidUnitMember();
|
||||||
}
|
}
|
||||||
return * returnable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class Suite: public JSON_Loader
|
||||||
void load_units_file( std::string filename, bool verbose );
|
void load_units_file( std::string filename, bool verbose );
|
||||||
|
|
||||||
// returns the unit identified by name
|
// returns the unit identified by name
|
||||||
// void get_unit(Unit & result, std::string provided_name);
|
void get_unit(Unit & result, std::string provided_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //FTESTS_UNITS_H
|
#endif //FTESTS_UNITS_H
|
||||||
|
|
Loading…
Reference in New Issue