Cavoke  1.1.0
A Platform for creating and hosting multiplayer turn-based board games
Loading...
Searching...
No Matches
test_main.cc
1#define DROGON_TEST_MAIN
2#include <drogon/drogon.h>
3#include <drogon/drogon_test.h>
4
5DROGON_TEST(BasicTest) {
6 // Add your tests here
7}
8
9int main(int argc, char **argv) {
10 using namespace drogon;
11
12 std::promise<void> p1;
13 std::future<void> f1 = p1.get_future();
14
15 // Start the main loop on another thread
16 std::thread thr([&]() {
17 // Queues the promise to be fulfilled after starting the loop
18 app().getLoop()->queueInLoop([&p1]() { p1.set_value(); });
19 app().run();
20 });
21
22 // The future is only satisfied after the event loop started
23 f1.get();
24 int status = test::run(argc, argv);
25
26 // Ask the event loop to shutdown and wait
27 app().getLoop()->queueInLoop([]() { app().quit(); });
28 thr.join();
29 return status;
30}