45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
#include <future>
|
|
#include <gmock/gmock.h>
|
|
#include <gtest/gtest.h>
|
|
#include <glog/logging.h>
|
|
#include "cloud_point_rpc/rpc_server.hpp"
|
|
#include "test_api.h"
|
|
#include "server_api.h"
|
|
class TestCApi : public ::testing::Test {
|
|
protected:
|
|
void SetUp() override {
|
|
EXPECT_NO_THROW(crpc_test_init());
|
|
}
|
|
|
|
void TearDown() override {
|
|
crpc_test_deinit();
|
|
}
|
|
};
|
|
|
|
TEST_F(TestCApi, Base) {
|
|
FLAGS_logtostderr = 1;
|
|
rpc_string name;
|
|
name.s = "test";
|
|
static std::promise<bool> task;
|
|
std::future<bool> called = task.get_future();
|
|
LOG(INFO) << "Test";
|
|
crpc_test_add_method(+[](rpc_string*)-> rpc_string* {
|
|
static bool installed = false;
|
|
DLOG(INFO) << "Trying to do something";
|
|
if(!installed){
|
|
LOG(INFO) << "Trying to install";
|
|
installed = true;
|
|
task.set_value(installed);
|
|
}
|
|
DLOG(INFO) << "Go out";
|
|
return crpc_str_create("res", sizeof("res"));
|
|
}, &name);
|
|
|
|
using namespace std::chrono_literals;
|
|
called.wait_for(500ms);
|
|
|
|
EXPECT_EQ(called.valid(), true);
|
|
EXPECT_EQ(called.get(), true);
|
|
|
|
LOG(INFO) << "DONE";
|
|
} |