1
0
mirror of https://github.com/eclipse/paho.mqtt.cpp.git synced 2025-05-09 03:11:23 +08:00

#313 Fixed persistence unit tests on Windows w/ MSVC

This commit is contained in:
fpagliughi 2023-11-11 16:15:04 -05:00
parent 509da56afc
commit f45bc093e5
2 changed files with 12 additions and 17 deletions

View File

@ -54,8 +54,8 @@ TEST_CASE("persistence", "[persistence]")
{
dcp per_;
void* handle_;
void* context = dynamic_cast<iclient_persistence*>(&per_);
void* context = static_cast<void*>(&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<iclient_persistence*>(&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<void*>(&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<void*>(&per);
void* context = dynamic_cast<iclient_persistence*>(&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<iclient_persistence*>(&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<iclient_persistence*>(&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<iclient_persistence*>(&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<iclient_persistence*>(&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_);
}

View File

@ -4,7 +4,7 @@
//
/*******************************************************************************
* Copyright (c) 2019 Frank Pagliughi <fpagliughi@mindspring.com>
* Copyright (c) 2019-2023 Frank Pagliughi <fpagliughi@mindspring.com>
*
* 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)