test: add test framework

This commit is contained in:
Nick Peng
2023-03-14 00:08:59 +08:00
parent 1c605938e0
commit 81ab3f413a
15 changed files with 1075 additions and 8 deletions

View File

@@ -0,0 +1,17 @@
#include "client.h"
#include "include/utils.h"
#include "server.h"
#include "gtest/gtest.h"
TEST(server, mock)
{
smartdns::MockServer server;
smartdns::Client client;
server.Start("udp://0.0.0.0:7053", [](struct smartdns::ServerRequestContext *request) {
request->response_data_len = 0;
return false;
});
ASSERT_TRUE(client.Query("example.com", 7053));
EXPECT_EQ(client.GetStatus(), "SERVFAIL");
}