diff --git a/test/unit/test_persistence.cpp b/test/unit/test_persistence.cpp index 7cdf820..b347bb8 100644 --- a/test/unit/test_persistence.cpp +++ b/test/unit/test_persistence.cpp @@ -54,8 +54,8 @@ TEST_CASE("persistence", "[persistence]") { dcp per_; void* handle_; + void* context = dynamic_cast(&per_); - void* context = static_cast(&per_); dcp::persistence_open(&handle_, CLIENT_ID, SERVER_URI, context); // Put no buffer @@ -69,13 +69,14 @@ TEST_CASE("persistence", "[persistence]") SECTION("test persistence open") { dcp per; void* handle = nullptr; + void* context = dynamic_cast(&per); REQUIRE(MQTTCLIENT_PERSISTENCE_ERROR == dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, nullptr)); REQUIRE(MQTTASYNC_SUCCESS == - dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, &per)); - REQUIRE(handle == static_cast(&per)); + dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, context)); + REQUIRE(handle == context); } @@ -89,11 +90,11 @@ TEST_CASE("persistence", "[persistence]") REQUIRE(MQTTCLIENT_PERSISTENCE_ERROR == dcp::persistence_close(nullptr)); - void* context = static_cast(&per); + void* context = dynamic_cast(&per); void* handle = nullptr; dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, context); - REQUIRE(MQTTASYNC_SUCCESS == dcp::persistence_close(handle)); + REQUIRE(MQTTASYNC_SUCCESS == dcp::persistence_close(handle)); } // ---------------------------------------------------------------------- @@ -103,7 +104,7 @@ TEST_CASE("persistence", "[persistence]") SECTION("test persistence put 0 buffer") { dcp per; void* handle; - dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, &per); + dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, dynamic_cast(&per)); // Put no buffer int bufcount = 0; @@ -118,7 +119,7 @@ TEST_CASE("persistence", "[persistence]") SECTION("persistence put 1 buffer") { dcp per; void* handle; - dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, &per); + dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, dynamic_cast(&per)); // Put no buffer int bufcount = 1; @@ -137,7 +138,7 @@ TEST_CASE("persistence", "[persistence]") SECTION("test persistence put 2 buffers") { dcp per; void* handle; - dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, &per); + dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, dynamic_cast(&per)); // Put no buffer int bufcount = 2; @@ -163,8 +164,8 @@ TEST_CASE("persistence", "[persistence]") SECTION("test persistence put empty buffers") { dcp per; void* handle; - dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, &per); - + dcp::persistence_open(&handle, CLIENT_ID, SERVER_URI, dynamic_cast(&per)); + // Put three empty buffers int bufcount = 3; const char* buffers[] = { "", "", "" }; @@ -250,5 +251,3 @@ TEST_CASE("persistence", "[persistence]") dcp::persistence_clear(handle_); dcp::persistence_close(handle_); } - - diff --git a/test/unit/unit_tests.cpp b/test/unit/unit_tests.cpp index 1d47e8e..2b8de0f 100644 --- a/test/unit/unit_tests.cpp +++ b/test/unit/unit_tests.cpp @@ -4,7 +4,7 @@ // /******************************************************************************* - * Copyright (c) 2019 Frank Pagliughi + * Copyright (c) 2019-2023 Frank Pagliughi * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -19,10 +19,6 @@ * Frank Pagliughi - initial implementation *******************************************************************************/ -// This tells Catch to provide a main() - only do this in one cpp file -//#define CATCH_CONFIG_MAIN -//#include "catch2_version.h" - // This seems to be required, at least for MSVS 2015 on Win7, // using Catch2 v2.9.2 #if defined(_WIN32)