summaryrefslogtreecommitdiffstats
path: root/tests/HTTP
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2018-02-20 18:08:46 +0100
committerGitHub <noreply@github.com>2018-02-20 18:08:46 +0100
commit1ea36298d2677733f36bae1cc6f72196c6395a4e (patch)
treebc07ed3758b8b3ec834b8d557cd710ea1e7ba270 /tests/HTTP
parentcBlockInfo: Deprecate direct access to variables. (#4184) (diff)
downloadcuberite-1ea36298d2677733f36bae1cc6f72196c6395a4e.tar
cuberite-1ea36298d2677733f36bae1cc6f72196c6395a4e.tar.gz
cuberite-1ea36298d2677733f36bae1cc6f72196c6395a4e.tar.bz2
cuberite-1ea36298d2677733f36bae1cc6f72196c6395a4e.tar.lz
cuberite-1ea36298d2677733f36bae1cc6f72196c6395a4e.tar.xz
cuberite-1ea36298d2677733f36bae1cc6f72196c6395a4e.tar.zst
cuberite-1ea36298d2677733f36bae1cc6f72196c6395a4e.zip
Diffstat (limited to 'tests/HTTP')
-rw-r--r--tests/HTTP/UrlClientTest.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/HTTP/UrlClientTest.cpp b/tests/HTTP/UrlClientTest.cpp
index f4a6f8f10..e86ad9156 100644
--- a/tests/HTTP/UrlClientTest.cpp
+++ b/tests/HTTP/UrlClientTest.cpp
@@ -6,6 +6,11 @@
+namespace
+{
+
+/** Track number of cCallbacks instances alive. */
+std::atomic<int> g_ActiveCallbacks{ 0 };
/** Simple callbacks that dump the events to the console and signalize a cEvent when the request is finished. */
class cCallbacks:
@@ -15,12 +20,14 @@ public:
cCallbacks(cEvent & a_Event):
m_Event(a_Event)
{
+ ++g_ActiveCallbacks;
LOGD("Created a cCallbacks instance at %p", reinterpret_cast<void *>(this));
}
virtual ~cCallbacks() override
{
+ --g_ActiveCallbacks;
LOGD("Deleting the cCallbacks instance at %p", reinterpret_cast<void *>(this));
}
@@ -102,7 +109,7 @@ protected:
-static int TestRequest1()
+int TestRequest1()
{
LOG("Running test 1");
cEvent evtFinished;
@@ -126,7 +133,7 @@ static int TestRequest1()
-static int TestRequest2()
+int TestRequest2()
{
LOG("Running test 2");
cEvent evtFinished;
@@ -148,7 +155,7 @@ static int TestRequest2()
-static int TestRequest3()
+int TestRequest3()
{
LOG("Running test 3");
cEvent evtFinished;
@@ -172,7 +179,7 @@ static int TestRequest3()
-static int TestRequest4()
+int TestRequest4()
{
LOG("Running test 4");
cEvent evtFinished;
@@ -194,7 +201,7 @@ static int TestRequest4()
-static int TestRequests()
+int TestRequests()
{
std::function<int(void)> tests[] =
{
@@ -215,6 +222,8 @@ static int TestRequests()
return 0;
}
+} // namespace (anonymous)
+
@@ -231,6 +240,11 @@ int main()
LOGD("Terminating cNetwork...");
cNetworkSingleton::Get().Terminate();
+
+ // No leaked callback instances
+ LOGD("cCallback instances still alive: %d", g_ActiveCallbacks.load());
+ assert_test(g_ActiveCallbacks == 0);
+
LOGD("cUrlClient test finished");
return res;