Commit 5001e7da authored by Patrick Chen's avatar Patrick Chen

rename variable 'condition_' to 'request_'

parent 977e708e
......@@ -32,7 +32,7 @@ namespace xs { namespace test
public:
std::string name_;
boost::optional<nlohmann::json> condition_;
boost::optional<nlohmann::json> request_;
boost::optional<nlohmann::json> response_;
};
} }
......
......@@ -15,8 +15,8 @@ namespace xs { namespace test
if (object.count("command")) {
response_ = object["response"];
if (object.count("condition")) {
condition_ = object["condition"];
if (object.count("param")) {
request_ = object["param"];
}
}
}
......@@ -31,8 +31,8 @@ namespace xs { namespace test
return object.is_string() || object.is_object();
};
if (object.count("command")) {
if (object.count("condition")) {
if (!isStringOrObject(object["condition"])) {
if (object.count("param")) {
if (!isStringOrObject(object["param"])) {
return false;
}
}
......
......@@ -99,22 +99,22 @@ std::string Tester::onCommand(const std::string& name, const std::string& params
continue;
}
if (!handler.condition_) {
if (!handler.request_) {
receivedCommandCount_[name]++;
return detail::toString(*handler.response_);
}
auto& receiveCount = receivedCommandCount_[name];
const auto& condition = *handler.condition_;
const bool isString = condition.is_string();
const auto& request = *handler.request_;
const bool isString = request.is_string();
if (isString) {
if (params == condition.get<std::string>()) {
if (params == request.get<std::string>()) {
receiveCount++;
return detail::toString(*handler.response_);
}
} else {
if (nlohmann::json::parse(params) == condition) {
if (nlohmann::json::parse(params) == request) {
receiveCount++;
return detail::toString(*handler.response_);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment