Update readme

This commit is contained in:
Adam Gu
2018-05-09 17:07:58 +08:00
parent 662b7c4112
commit 81ed82a302
27 changed files with 438 additions and 238 deletions
+14 -2
View File
@@ -2,6 +2,9 @@
#include <iostream>
#include "boost/lexical_cast.hpp"
// Set to 0 to test our own calculator server created with webcc.
#define ACCESS_PARASOFT 0
CalcClient::CalcClient() {
Init();
}
@@ -19,13 +22,22 @@ bool CalcClient::Multiply(double x, double y, double* result) {
}
bool CalcClient::Divide(double x, double y, double* result) {
// ParaSoft's Calculator Service uses different parameter names for Divide.
#if ACCESS_PARASOFT
return Calc("divide", "numerator", "denominator", x, y, result);
#else
return Calc("divide", "x", "y", x, y, result);
#endif
}
// Set to 0 to test our own calculator server created with webcc.
#define ACCESS_PARASOFT 0
bool CalcClient::NotExist(double x, double y, double* result) {
return Calc("notexist", "x", "y", x, y, result);
}
void CalcClient::Init() {
// Override the default timeout.
timeout_seconds_ = 5;
#if ACCESS_PARASOFT
url_ = "/glue/calculator";
host_ = "ws1.parasoft.com";
+3
View File
@@ -16,6 +16,9 @@ public:
bool Divide(double x, double y, double* result);
// For testing purpose.
bool NotExist(double x, double y, double* result);
protected:
void Init();
+5 -2
View File
@@ -12,7 +12,6 @@ int main() {
printf("add: %.1f\n", result);
}
#if 0
if (calc.Subtract(x, y, &result)) {
printf("subtract: %.1f\n", result);
}
@@ -24,7 +23,11 @@ int main() {
if (calc.Divide(x, y, &result)) {
printf("divide: %.1f\n", result);
}
#endif
// Try to call a non-existing operation.
if (calc.NotExist(x, y, &result)) {
printf("notexist: %.1f\n", result);
}
return 0;
}