using SpecificErrorType = int;
namespace TestToolBox
{
inline std::string MakeReturnValue(
SpecificErrorType& out_retVal,
bool in_simulateFailure,
std::string const & in_methodName,
TTB::SimulatedObjectBase const * in_pObject)
{
out_retVal = SpecificErrorType();
if (in_simulateFailure) out_retVal = -1;
return "";
};
}
class SomeSimulatedObject : public TTB::RegisteredSimulatedObject
{
public:
SomeSimulatedObject(std::string const & in_name)
: TTB::RegisteredSimulatedObject(in_name, TTB_CLASS_NAME)
{}
void DoSomething()
{
bool xValDefined = _IsOptionSet("xVal", TTB_FUNC_NAME);
double xVal = _GetOptionValue<double>("xVal", TTB_FUNC_NAME);
TTB_METHOD_CALL1(" xVal=" << xVal << (xValDefined ? "" : " (xVal not defined)"));
}
void DoSomethingElse() const
{
double xVal = _GetOptionValue<double>("xVal", TTB_FUNC_NAME);
TTB_METHOD_CALL1("xVal=" << xVal);
}
void DoSomethingWithAccessToCommandLine() const
{
auto yVal = TestToolBox::TheEnvironment()->GetCommandLineOptionVal<double>("-yVal");
TTB_METHOD_CALL1("yVal=" << yVal);
}
SpecificErrorType CalculateSomething(int in_val, int& out_val)
{
return TTB_METHOD_CALL_RET3(SpecificErrorType, "in_val=" << in_val,
{
if (_WasError("CalculateSomething"))
out_val = -99;
else
out_val = 2 * in_val;
return TTB_STRING_S("out_val=" << out_val);
});
}
};