Commit 574f0816 authored by Patrick Chen's avatar Patrick Chen

add example test program

parent 0b058194
......@@ -29,6 +29,8 @@ XSTEST_HDRS=$(INCLUDE_DIR)/test/Config.h $(INCLUDE_DIR)/test/Service.h $(INCLUDE
XSTEST_SRCS=$(SRC_DIR)/xs-test.cc $(SRC_DIR)/test/Config.cc $(SRC_DIR)/test/Service.cc $(SRC_DIR)/test/Tester.cc
XSTEST_OBJS=$(subst $(REPO_DIR),$(BUILD_DIR),$(XSTEST_SRCS:.cc=.o))
HELLO_WORLD_SRCS=$(REPO_DIR)/example/hello-world.cc
HELLO_WORLD_OBJS=$(subst $(REPO_DIR),$(BUILD_DIR),$(HELLO_WORLD_SRCS:.cc=.o))
all: $(BUILD_DIR)/xs-test
......@@ -39,9 +41,16 @@ $(BUILD_DIR)/%.o: $(REPO_DIR)/%.cc $(XSTEST_HDRS)
mkdir -p $(dir $@)
$(CXX) -o $@ -c $(CXX_FLAGS) $<
example: $(BUILD_DIR)/hello-word
$(BUILD_DIR)/hello-word: $(HELLO_WORLD_OBJS)
$(CXX) -o $@ $(HELLO_WORLD_OBJS) $(LD_FLAGS)
clean:
rm -rf $(BUILD_DIR)/xs-test
rm -rf $(BUILD_DIR)/hello-world
rm -rf $(XSTEST_OBJS)
rm -rf $(HELLO_WORLD_OBJS)
print-var:
echo $(XSTEST_OBJS)
#include "positivegrid/exchange_server.h"
#include <chrono>
#include <string>
#include <thread>
int main()
{
xs::ExchangeServer server("hello-world", {}, {}, 0, nullptr);
server.onCmd(
"GetGreetingMessage",
[&server](const std::string&, const std::string&) {
const auto name = server.runCmd("GetName", "");
return "Hello, " + name + "!";
}
);
using namespace std::chrono_literals;
for (;;) {
std::this_thread::sleep_for(1s);
}
}
{
"mockData": [
{
"command": "GetName",
"response": "Patrick"
}
],
"script": [
{
"command": "GetGreetingMessage",
"expect": "Hello, Patrick!"
}
]
}
{
"mockData": [
{
"command": "aaa",
"response": "123"
},
{
"event" : "bbb",
"response" : { "value": 456 }
}
]
}
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