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 ...@@ -32,7 +32,7 @@ namespace xs { namespace test
public: public:
std::string name_; std::string name_;
boost::optional<nlohmann::json> condition_; boost::optional<nlohmann::json> request_;
boost::optional<nlohmann::json> response_; boost::optional<nlohmann::json> response_;
}; };
} } } }
......
...@@ -15,8 +15,8 @@ namespace xs { namespace test ...@@ -15,8 +15,8 @@ namespace xs { namespace test
if (object.count("command")) { if (object.count("command")) {
response_ = object["response"]; response_ = object["response"];
if (object.count("condition")) { if (object.count("param")) {
condition_ = object["condition"]; request_ = object["param"];
} }
} }
} }
...@@ -31,8 +31,8 @@ namespace xs { namespace test ...@@ -31,8 +31,8 @@ namespace xs { namespace test
return object.is_string() || object.is_object(); return object.is_string() || object.is_object();
}; };
if (object.count("command")) { if (object.count("command")) {
if (object.count("condition")) { if (object.count("param")) {
if (!isStringOrObject(object["condition"])) { if (!isStringOrObject(object["param"])) {
return false; return false;
} }
} }
......
...@@ -99,22 +99,22 @@ std::string Tester::onCommand(const std::string& name, const std::string& params ...@@ -99,22 +99,22 @@ std::string Tester::onCommand(const std::string& name, const std::string& params
continue; continue;
} }
if (!handler.condition_) { if (!handler.request_) {
receivedCommandCount_[name]++; receivedCommandCount_[name]++;
return detail::toString(*handler.response_); return detail::toString(*handler.response_);
} }
auto& receiveCount = receivedCommandCount_[name]; auto& receiveCount = receivedCommandCount_[name];
const auto& condition = *handler.condition_; const auto& request = *handler.request_;
const bool isString = condition.is_string(); const bool isString = request.is_string();
if (isString) { if (isString) {
if (params == condition.get<std::string>()) { if (params == request.get<std::string>()) {
receiveCount++; receiveCount++;
return detail::toString(*handler.response_); return detail::toString(*handler.response_);
} }
} else { } else {
if (nlohmann::json::parse(params) == condition) { if (nlohmann::json::parse(params) == request) {
receiveCount++; receiveCount++;
return detail::toString(*handler.response_); 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