test: add test framework
This commit is contained in:
17
test/cases/test-mock-server.cc
Normal file
17
test/cases/test-mock-server.cc
Normal 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");
|
||||
}
|
||||
Reference in New Issue
Block a user