Skip to content

Commit

Permalink
fix memory leak in UT
Browse files Browse the repository at this point in the history
  • Loading branch information
lidaobing committed May 31, 2024
1 parent b27ef58 commit 3c99cd1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/iptux-core/internal/UdpDataServiceTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "gtest/gtest.h"

#include <memory>

#include "iptux-core/TestHelper.h"
#include "iptux-core/internal/UdpDataService.h"
#include "iptux-utils/utils.h"
Expand All @@ -9,13 +11,13 @@ using namespace iptux;

TEST(UdpDataService, process) {
auto core = newCoreThread();
auto service = new UdpDataService(*core.get());
auto service = make_unique<UdpDataService>(*core.get());
service->process(inAddrFromString("127.0.0.1"), 1234, "", 0, true);
}

TEST(UdpDataService, SomeoneEntry) {
auto core = newCoreThread();
auto service = new UdpDataService(*core.get());
auto service = std::make_unique<UdpDataService>(*core.get());
const char* data = "iptux 0.8.0:1:lidaobing:lidaobing.lan:257:lidaobing";
service->process(inAddrFromString("127.0.0.1"), 1234, data, strlen(data),
true);
Expand All @@ -28,7 +30,7 @@ TEST(UdpDataService, CreatePalInfo) {
"1_iptux "
"0.8.0-b1:6:lidaobing:LIs-MacBook-Pro.local:259:中\xe4\xb8\x00\x00icon-"
"tux.png\x00utf-8\x00";
auto service = new UdpDataService(*core.get());
auto service = make_unique<UdpDataService>(*core.get());
auto udp = service->process(inAddrFromString("127.0.0.1"), 1234, data,
strlen(data), false);
auto pal = udp->CreatePalInfo();
Expand All @@ -43,7 +45,7 @@ TEST(UdpDataService, CreatePalInfo) {
"1_iptux "
"0.8.0-b1:6:中\xe4\xb8:LIs-MacBook-Pro.local:259:"
"\xe4\xb8\x00\x00icon-tux.png\x00utf-8\x00";
auto service = new UdpDataService(*core.get());
auto service = make_unique<UdpDataService>(*core.get());
auto udp = service->process(inAddrFromString("127.0.0.1"), 1234, data,
strlen(data), false);
auto pal = udp->CreatePalInfo();
Expand Down

0 comments on commit 3c99cd1

Please sign in to comment.