test: add test case for performance

This commit is contained in:
Nick Peng
2023-03-19 14:26:46 +08:00
parent 455dca9ae4
commit aa6f6fd519
10 changed files with 307 additions and 55 deletions

View File

@@ -1,3 +1,21 @@
/*************************************************************************
*
* Copyright (C) 2018-2023 Ruilin Peng (Nick) <pymumu@gmail.com>.
*
* smartdns is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* smartdns is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "client.h"
#include "include/utils.h"
#include "server.h"
@@ -21,9 +39,8 @@ TEST(MockServer, soa)
{
smartdns::MockServer server;
smartdns::Client client;
server.Start("udp://0.0.0.0:7053", [](struct smartdns::ServerRequestContext *request) {
return smartdns::SERVER_REQUEST_SOA;
});
server.Start("udp://0.0.0.0:7053",
[](struct smartdns::ServerRequestContext *request) { return smartdns::SERVER_REQUEST_SOA; });
ASSERT_TRUE(client.Query("example.com", 7053));
std::cout << client.GetResult() << std::endl;
@@ -34,9 +51,8 @@ TEST(MockServer, noerror)
{
smartdns::MockServer server;
smartdns::Client client;
server.Start("udp://0.0.0.0:7053", [](struct smartdns::ServerRequestContext *request) {
return smartdns::SERVER_REQUEST_OK;
});
server.Start("udp://0.0.0.0:7053",
[](struct smartdns::ServerRequestContext *request) { return smartdns::SERVER_REQUEST_OK; });
ASSERT_TRUE(client.Query("example.com", 7053));
std::cout << client.GetResult() << std::endl;