diff --git a/modules/c++/CMakeLists.txt b/modules/c++/CMakeLists.txt index 3cd8d662a0..7ca6fdffa3 100644 --- a/modules/c++/CMakeLists.txt +++ b/modules/c++/CMakeLists.txt @@ -2,15 +2,9 @@ set(TARGET_LANGUAGE c++) # turn on warnings as errors if (MSVC) - add_compile_options(/WX /W4) + add_compile_options(/WX /W4) # /Wall elseif (UNIX) - # still building with older GCC :-( - #add_compile_options(-Werror) - add_compile_options(-Wall) - #add_compile_options(-Wpedantic -Wextra) - add_compile_options(-Wno-deprecated-copy) - add_compile_options(-Wno-expansion-to-defined -Wno-type-limits) - add_compile_options(-Wno-unused-parameter) + add_compile_options(-Werror -Wall -Wpedantic -Wextra) endif() # add an interface library for unittests diff --git a/modules/c++/config/include/config/disable_compiler_warnings.h b/modules/c++/config/include/config/disable_compiler_warnings.h new file mode 100644 index 0000000000..a87d281089 --- /dev/null +++ b/modules/c++/config/include/config/disable_compiler_warnings.h @@ -0,0 +1,43 @@ +/* ========================================================================= + * This file is part of config-c++ + * ========================================================================= + * + * (C) Copyright 2023, Maxar Technologies, Inc. + * + * config-c++ is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; If not, + * see . + * + */ +#ifndef CODA_OSS_config_disable_compiler_warnings_h_INCLUDED_ +#define CODA_OSS_config_disable_compiler_warnings_h_INCLUDED_ +#pragma once + +#include "compiler_extensions.h" + +#if _MSC_VER +// We don't care about any padding added to structs +#pragma warning(disable: 4820) // '...': '...' bytes padding added after data member '...' + +// Assume any unreferenced functions will be used in other code +#pragma warning(disable: 4514) // '...': unreferenced inline function has been removed + +// ??? +#pragma warning(disable: 4668) // '...' is not defined as a preprocessor macro, replacing with '...' for '...' + +// ??? +#pragma warning(disable: 5045) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified + +#endif // _MSC_VER + +#endif // CODA_OSS_config_disable_compiler_warnings_h_INCLUDED_ diff --git a/modules/c++/except/include/except/Context.h b/modules/c++/except/include/except/Context.h index cef7af1763..83f80acee3 100644 --- a/modules/c++/except/include/except/Context.h +++ b/modules/c++/except/include/except/Context.h @@ -29,6 +29,7 @@ #include #include "config/Exports.h" +#include "config/disable_compiler_warnings.h" /*! * \file diff --git a/modules/c++/except/include/except/Error.h b/modules/c++/except/include/except/Error.h index 76823bfe49..56fcdb78ca 100644 --- a/modules/c++/except/include/except/Error.h +++ b/modules/c++/except/include/except/Error.h @@ -46,13 +46,13 @@ _Name##Error_(const except::Throwable& t, const except::Context& c) : _Base(t, c){} \ _Name##Error_(const except::ThrowableEx& t, const except::Context& c) : _Base(t, c){} \ std::string getType() const noexcept override { return #_Name; } \ - }; + } #define DECLARE_EXTENDED_ERROR(_Name, _Base) DECLARE_EXTENDED_ERROR_(_Name, Error, _Base) #define DECLARE_EXTENDED_ERROREX(_Name, _Base) DECLARE_EXTENDED_ERROR_(_Name, ErrorEx, _Base) // Need to keep this around for existing code #define DECLARE_ERROR(_Name) \ - DECLARE_EXTENDED_ERROR(_Name, except::Error); \ + DECLARE_EXTENDED_ERROR(_Name, except::Error); \ DECLARE_EXTENDED_ERROREX(_Name, except::ErrorEx) namespace except diff --git a/modules/c++/except/include/except/Exception.h b/modules/c++/except/include/except/Exception.h index 12cedcc07c..33a8563632 100644 --- a/modules/c++/except/include/except/Exception.h +++ b/modules/c++/except/include/except/Exception.h @@ -63,7 +63,7 @@ _Name##Exception_(const except::ThrowableEx& t, const except::Context& c) : _Base(t, c){} \ CODA_OSS_except_Exception_suppress_26447_BEGIN_ \ std::string getType() const noexcept override { return #_Name #Exception_; } \ - CODA_OSS_except_Exception_suppress_26447_END_ }; + CODA_OSS_except_Exception_suppress_26447_END_ } #define DECLARE_EXTENDED_EXCEPTION(_Name, _Base) DECLARE_EXTENDED_EXCEPTION_(_Name, Exception, _Base) #define DECLARE_EXTENDED_EXCEPTIONEX(_Name, _Base) DECLARE_EXTENDED_EXCEPTION_(_Name, ExceptionEx, _Base) diff --git a/modules/c++/except/include/except/Throwable.h b/modules/c++/except/include/except/Throwable.h index 0f3427ed45..84fe4d0385 100644 --- a/modules/c++/except/include/except/Throwable.h +++ b/modules/c++/except/include/except/Throwable.h @@ -34,6 +34,7 @@ #include "config/Exports.h" #include "config/compiler_extensions.h" +#include "config/disable_compiler_warnings.h" #include "except/Trace.h" /* Determine whether except::Throwable derives from std::exception. diff --git a/modules/c++/except/source/Backtrace.cpp b/modules/c++/except/source/Backtrace.cpp index 3131668082..6b8e24a622 100644 --- a/modules/c++/except/source/Backtrace.cpp +++ b/modules/c++/except/source/Backtrace.cpp @@ -28,6 +28,8 @@ #include #include +#include "config/disable_compiler_warnings.h" + #if !CODA_OSS_except_Backtrace static std::string getBacktrace_(bool& supported, std::vector&) diff --git a/modules/c++/hdf5.lite/include/hdf5/lite/SpanRC.h b/modules/c++/hdf5.lite/include/hdf5/lite/SpanRC.h index 7d6582124d..9392890bb2 100644 --- a/modules/c++/hdf5.lite/include/hdf5/lite/SpanRC.h +++ b/modules/c++/hdf5.lite/include/hdf5/lite/SpanRC.h @@ -105,8 +105,8 @@ struct SpanRC final } private: - types::RowCol rc_; coda_oss::span s_; + types::RowCol rc_; }; } diff --git a/modules/c++/hdf5.lite/unittests/test_hdf5write.cpp b/modules/c++/hdf5.lite/unittests/test_hdf5write.cpp index 0d99d11050..2d0dde8502 100644 --- a/modules/c++/hdf5.lite/unittests/test_hdf5write.cpp +++ b/modules/c++/hdf5.lite/unittests/test_hdf5write.cpp @@ -47,6 +47,8 @@ TEST_CASE(test_hdf5Create) // https://www.mathworks.com/help/matlab/ref/h5write.html hdf5::lite::createFile(path, "/DS1", {10, 20}); + + TEST_ASSERT_TRUE(true); // need to use hidden "testName" parameter } TEST_CASE(test_hdf5Write) diff --git a/modules/c++/io/source/InputStream.cpp b/modules/c++/io/source/InputStream.cpp index a6e8c01523..3fd81e2f6c 100644 --- a/modules/c++/io/source/InputStream.cpp +++ b/modules/c++/io/source/InputStream.cpp @@ -65,7 +65,9 @@ sys::SSize_T InputStream::streamTo(OutputStream& soi, sys::SSize_T bytesToPipe) sys::SSize_T bytesRead = 0; sys::SSize_T totalBytesTransferred = 0; - sys::SSize_T sizeOfVec = (bytesToPipe <= DEFAULT_CHUNK_SIZE) ? (bytesToPipe) : (DEFAULT_CHUNK_SIZE); + constexpr auto defaultChunkSize = static_cast(DEFAULT_CHUNK_SIZE); + + sys::SSize_T sizeOfVec = (bytesToPipe <= defaultChunkSize) ? bytesToPipe : defaultChunkSize; sys::byte vec[DEFAULT_CHUNK_SIZE]; memset(vec, 0, DEFAULT_CHUNK_SIZE); @@ -79,8 +81,8 @@ sys::SSize_T InputStream::streamTo(OutputStream& soi, sys::SSize_T bytesToPipe) soi.write(vec, bytesRead); totalBytesTransferred += bytesRead; memset(vec, 0, DEFAULT_CHUNK_SIZE); - sizeOfVec = (bytesToPipe - totalBytesTransferred <= DEFAULT_CHUNK_SIZE) ? - (bytesToPipe - totalBytesTransferred) : (DEFAULT_CHUNK_SIZE); + sizeOfVec = (bytesToPipe - totalBytesTransferred <= defaultChunkSize) ? + (bytesToPipe - totalBytesTransferred) : defaultChunkSize; } // Return the number of bytes we piped return totalBytesTransferred; diff --git a/modules/c++/logging/include/logging/Enums.h b/modules/c++/logging/include/logging/Enums.h index 9dd89b63ef..95d7edeae7 100644 --- a/modules/c++/logging/include/logging/Enums.h +++ b/modules/c++/logging/include/logging/Enums.h @@ -40,7 +40,7 @@ namespace logging * * Enumeration used to represent LogLevels */ -struct LogLevel +struct LogLevel final { //! The enumerations allowed enum @@ -124,7 +124,7 @@ struct LogLevel } //! destructor - ~LogLevel(){} + ~LogLevel() = default; //! Returns string representation of the value std::string toString() const @@ -149,14 +149,10 @@ struct LogLevel } //! assignment operator - LogLevel& operator=(const LogLevel& o) - { - if (&o != this) - { - value = o.value; - } - return *this; - } + LogLevel& operator=(const LogLevel&) = default; + LogLevel(const LogLevel&) = default; + LogLevel& operator=(LogLevel&&) = default; + LogLevel(LogLevel&&) = default; bool operator==(const LogLevel& o) const { return value == o.value; } bool operator!=(const LogLevel& o) const { return value != o.value; } diff --git a/modules/c++/logging/include/logging/LogRecord.h b/modules/c++/logging/include/logging/LogRecord.h index 9423dc7468..df81ba04b8 100644 --- a/modules/c++/logging/include/logging/LogRecord.h +++ b/modules/c++/logging/include/logging/LogRecord.h @@ -50,7 +50,7 @@ class LogRecord std::string file, std::string function, int lineNum, std::string timestamp) : mName(name), mMsg(msg), mLevel(level), mFile(file), mFunction(function), mLineNum(lineNum), mTimestamp(timestamp){} - virtual ~LogRecord(){} + virtual ~LogRecord() = default; LogLevel getLevel() const { return mLevel; } std::string getLevelName() const; diff --git a/modules/c++/logging/source/Setup.cpp b/modules/c++/logging/source/Setup.cpp index 99cc8309a5..e1a7e6491e 100644 --- a/modules/c++/logging/source/Setup.cpp +++ b/modules/c++/logging/source/Setup.cpp @@ -19,6 +19,10 @@ * see . * */ +#include "logging/Setup.h" + +#include +#include #include @@ -28,8 +32,6 @@ #include "logging/StandardFormatter.h" #include "logging/XMLFormatter.h" -#include "logging/Setup.h" - std::unique_ptr logging::setupLogger(const std::filesystem::path& program_, const std::string& logLevel, @@ -69,9 +71,14 @@ logging::setupLogger(const std::filesystem::path& program_, logHandler.reset(new logging::StreamHandler()); else { + // Existing code was checking whether a 'size_t' was <0; that of course can't + // ever happen because 'size_t' is an unsigned type. But, in the spirit of + // the existing code, assume that somebody thought such a check was meaningful + // ... using the value of a 32-bit integer (we now only build on 64-bit platforms). + // create a rotating logger - logCount = (logCount < 0) ? 0 : logCount; - logBytes = (logBytes < 0) ? 0 : logBytes; + logCount = logCount > std::numeric_limits::max() ? 0 : logCount; // logCount = (logCount < 0) ? 0 : logCount; + logBytes = logBytes > std::numeric_limits::max() ? 0 : logBytes; // logBytes = (logBytes < 0) ? 0 : logBytes; if (logBytes > 0) { logHandler.reset(new logging::RotatingFileHandler(logFile, diff --git a/modules/c++/logging/unittests/test_exception_logger.cpp b/modules/c++/logging/unittests/test_exception_logger.cpp index 55250b3607..375b4b5f47 100644 --- a/modules/c++/logging/unittests/test_exception_logger.cpp +++ b/modules/c++/logging/unittests/test_exception_logger.cpp @@ -121,7 +121,8 @@ TEST_CASE(testExceptionWithBacktrace) } catch (const except::Throwable& t) { - TEST_ASSERT_GREATER(t.getBacktrace().size(), static_cast(0)); + const auto backtraceSize = static_cast(t.getBacktrace().size()); + TEST_ASSERT_GREATER(backtraceSize, 0); s = t.toString(true /*includeBacktrace*/); what = t.what(); } diff --git a/modules/c++/math.linear/unittests/test_lin.cpp b/modules/c++/math.linear/unittests/test_lin.cpp index 3dc706ea9e..cc46d74a5d 100644 --- a/modules/c++/math.linear/unittests/test_lin.cpp +++ b/modules/c++/math.linear/unittests/test_lin.cpp @@ -81,6 +81,7 @@ TEST_CASE(testSTLVectorAssign) TEST_CASE(testEmptyDim) { math::linear::Matrix2D AScale(3, 0); + TEST_ASSERT_TRUE(true); // need to use hidden "testName" parameter } TEST_CASE(testPtrDecorator) @@ -100,6 +101,7 @@ TEST_CASE(testPtrAdopt) { // valgrind to ensure that we don't have a leak math::linear::Matrix2D AScale(3, 3, new double[9], true); + TEST_ASSERT_TRUE(true); // need to use hidden "testName" parameter } TEST_CASE(testArithmetic) @@ -216,4 +218,4 @@ TEST_MAIN( std::cout << cross(v3, y) << std::endl; */ -) \ No newline at end of file +) diff --git a/modules/c++/mt/unittests/Runnable1DTest.cpp b/modules/c++/mt/unittests/Runnable1DTest.cpp index 61ad49ae8f..14a419d782 100644 --- a/modules/c++/mt/unittests/Runnable1DTest.cpp +++ b/modules/c++/mt/unittests/Runnable1DTest.cpp @@ -69,6 +69,7 @@ TEST_CASE(DoRunnable1DTest) const AddOp op; std::cout << "Calling run1D\n"; mt::run1D(10, 16, op); + TEST_ASSERT_TRUE(true); // need to use hidden "testName" parameter } TEST_CASE(Runnable1DWithCopiesTest) @@ -79,6 +80,7 @@ TEST_CASE(Runnable1DWithCopiesTest) const LocalStorage op; std::cout << "Calling run1D\n"; mt::run1DWithCopies(47, 16, op); + TEST_ASSERT_TRUE(true); // need to use hidden "testName" parameter } TEST_CASE(transform_async_test) diff --git a/modules/c++/net/include/net/URL.h b/modules/c++/net/include/net/URL.h index 55fa55b52e..ea9b4f8fe7 100644 --- a/modules/c++/net/include/net/URL.h +++ b/modules/c++/net/include/net/URL.h @@ -46,7 +46,7 @@ class URLParams typedef std::list ParamValues; typedef std::map Params; - URLParams(const std::string paramString = ""); + URLParams(std::string paramString = ""); bool contains(std::string key) const; ParamValues& get(std::string key); @@ -68,17 +68,18 @@ class URL { public: - URL(const std::string url = ""); + URL(std::string url = ""); /*! * Copy constructor. * \param url A right-hand-side URL */ - URL(const URL& url); + URL(const URL&); + URL& operator=(const URL&); + URL(URL&&) = default; + URL& operator=(URL&&) = default; - virtual ~URL() - { - } + virtual ~URL() = default; void set(std::string url); @@ -106,7 +107,7 @@ class URL friend class URLBuilder; std::string mProtocol; std::string mHost; - int mPort; + int mPort = -1; std::string mPath; URLParams mParams; std::string mFragment; diff --git a/modules/c++/net/source/URL.cpp b/modules/c++/net/source/URL.cpp index a14219f7e6..881a4b8547 100644 --- a/modules/c++/net/source/URL.cpp +++ b/modules/c++/net/source/URL.cpp @@ -24,21 +24,28 @@ #include #include -net::URL::URL(const std::string url) : - mPort(-1) +net::URL::URL(std::string url) { if (!url.empty()) set(url); } -net::URL::URL(const net::URL& url) +net::URL& net::URL::operator=(const URL& url) { + if (this != &url) + { mProtocol = url.getProtocol(); mHost = url.getHost(); setPort(url.getPort()); mPath = url.getPath(); mFragment = url.getFragment(); mParams = net::URLParams(url.getParams().toString()); + } + return *this; +} +net::URL::URL(const URL& url) +{ + *this = url; } void net::URL::set(std::string url) @@ -122,7 +129,7 @@ bool net::URL::operator==(const net::URL& url) const return toString() == url.toString(); } -net::URLParams::URLParams(const std::string paramString) +net::URLParams::URLParams(std::string paramString) { if (!paramString.empty()) { diff --git a/modules/c++/str/unittests/test_base_convert.cpp b/modules/c++/str/unittests/test_base_convert.cpp index 26ab0ece7b..358fa6827a 100644 --- a/modules/c++/str/unittests/test_base_convert.cpp +++ b/modules/c++/str/unittests/test_base_convert.cpp @@ -362,6 +362,8 @@ static void test_wide_(const std::string& testName, const char* pStr, std::u16st const std::string std_str(static_cast(wide_str)); // UTF-16 -> Windows-1252 TEST_ASSERT_EQ(encoded.native(), std_str); TEST_ASSERT_EQ(std_str, pStr); + #else + pUtf16 = pUtf16; // avoid unused-parameter warning #endif } @@ -436,6 +438,8 @@ TEST_CASE(test_Windows1252_WIN32) constexpr auto w1252_unassigned = "\x81\x8d\x8f\x90\x9d"; constexpr auto u16_w1252_unassigned = u"\x81\x8d\x8f\x90\x9d"; test_Windows1252_(testName, w1252_unassigned, u16_w1252_unassigned); + #else + TEST_ASSERT_TRUE(true); // need to use hidden "testName" parameter #endif } @@ -613,4 +617,4 @@ TEST_MAIN( TEST_CHECK(test_Windows1252); TEST_CHECK(test_EncodedStringView); TEST_CHECK(test_EncodedString); - ) \ No newline at end of file + ) diff --git a/modules/c++/sys/include/sys/Conf.h b/modules/c++/sys/include/sys/Conf.h index e910f51356..ad5a1e4c99 100644 --- a/modules/c++/sys/include/sys/Conf.h +++ b/modules/c++/sys/include/sys/Conf.h @@ -38,9 +38,21 @@ #ifndef _WIN32 #include #endif -#define CODA_OSS_POSIX_SOURCE (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 1)) -#define CODA_OSS_POSIX2001_SOURCE CODA_OSS_POSIX_SOURCE && (_POSIX_C_SOURCE >= 200112L) -#define CODA_OSS_POSIX2008_SOURCE CODA_OSS_POSIX2001_SOURCE && (_POSIX_C_SOURCE >= 200809L) + +#undef CODA_OSS_POSIX_SOURCE +#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 1) +#define CODA_OSS_POSIX_SOURCE _POSIX_C_SOURCE +#endif + +#undef CODA_OSS_POSIX2001_SOURCE +#if defined(CODA_OSS_POSIX_SOURCE) && (_POSIX_C_SOURCE >= 200112L) +#define CODA_OSS_POSIX2001_SOURCE _POSIX_C_SOURCE +#endif + +#undef CODA_OSS_POSIX2008_SOURCE +#if defined(CODA_OSS_POSIX2001_SOURCE) && (_POSIX_C_SOURCE >= 200809L) +#define CODA_OSS_POSIX2008_SOURCE _POSIX_C_SOURCE +#endif #include #include @@ -312,13 +324,13 @@ namespace sys void* p = nullptr; #ifdef _WIN32 p = _aligned_malloc(size, alignment); -#elif CODA_OSS_POSIX2001_SOURCE +#elif defined(CODA_OSS_POSIX2001_SOURCE) // https://linux.die.net/man/3/posix_memalign if (posix_memalign(&p, alignment, size) != 0) { p = nullptr; } -#elif CODA_OSS_POSIX_SOURCE +#elif defined(CODA_OSS_POSIX_SOURCE) // https://linux.die.net/man/3/posix_memalign // "The functions memalign(), ... have been available in all Linux libc libraries." p = memalign(alignment, size); diff --git a/modules/c++/sys/include/sys/DateTime.h b/modules/c++/sys/include/sys/DateTime.h index 38b7424a77..5ca7db4459 100644 --- a/modules/c++/sys/include/sys/DateTime.h +++ b/modules/c++/sys/include/sys/DateTime.h @@ -31,6 +31,7 @@ #include #include "config/Exports.h" +#include "config/disable_compiler_warnings.h" namespace sys { diff --git a/modules/c++/sys/include/sys/Dbg.h b/modules/c++/sys/include/sys/Dbg.h index 90d87546ed..96bfb098f0 100644 --- a/modules/c++/sys/include/sys/Dbg.h +++ b/modules/c++/sys/include/sys/Dbg.h @@ -27,6 +27,7 @@ #pragma once #include "config/Exports.h" +#include "config/disable_compiler_warnings.h" // A "debug" build has debugging symbols, detailed call stacks, minimal optimization, STL validation, etc. // A "release" build is likely to "run fast" and be "shipped;" it might lack much of what is in a "debug" build. diff --git a/modules/c++/sys/include/sys/OS.h b/modules/c++/sys/include/sys/OS.h index d126d7d674..6ea40c83fb 100644 --- a/modules/c++/sys/include/sys/OS.h +++ b/modules/c++/sys/include/sys/OS.h @@ -54,7 +54,7 @@ namespace sys //MacOS }; - #if _WIN32 + #ifdef _WIN32 constexpr auto Platform = PlatformType::Windows; #else constexpr auto Platform = PlatformType::Linux; diff --git a/modules/c++/sys/unittests/test_NaN_testing.cpp b/modules/c++/sys/unittests/test_NaN_testing.cpp index b651af471c..82df405095 100644 --- a/modules/c++/sys/unittests/test_NaN_testing.cpp +++ b/modules/c++/sys/unittests/test_NaN_testing.cpp @@ -47,6 +47,7 @@ TEST_CASE(testNaNIsNotAlmostEqualToNumber) TEST_ASSERT_ALMOST_EQ_EPS(std::numeric_limits::quiet_NaN(), 5, 3); */ + TEST_ASSERT_TRUE(true); // need to use hidden "testName" parameter } TEST_CASE(testIsNaN) diff --git a/modules/c++/sys/unittests/test_os.cpp b/modules/c++/sys/unittests/test_os.cpp index 278a67f8a6..d4265494bc 100644 --- a/modules/c++/sys/unittests/test_os.cpp +++ b/modules/c++/sys/unittests/test_os.cpp @@ -162,7 +162,7 @@ TEST_CASE(testSplitEnv) std::vector paths; bool result = os.splitEnv(pathEnvVar, paths); TEST_ASSERT_TRUE(result); - TEST_ASSERT_GREATER(paths.size(), static_cast(0)); + TEST_ASSERT_FALSE(paths.empty()); for (const auto& path : paths) { TEST_ASSERT_TRUE(std::filesystem::exists(path)); @@ -183,7 +183,7 @@ TEST_CASE(testSplitEnv) paths.clear(); result = os.splitEnv(pathEnvVar, paths, std::filesystem::file_type::directory); TEST_ASSERT_TRUE(result); - TEST_ASSERT_GREATER(paths.size(), static_cast(0)); + TEST_ASSERT_FALSE(paths.empty()); paths.clear(); result = os.splitEnv(pathEnvVar, paths, std::filesystem::file_type::regular); TEST_ASSERT_FALSE(result); @@ -389,14 +389,14 @@ TEST_CASE(testFsFileSize) const sys::OS os; { const std::filesystem::path argv0(os.getSpecialEnv("ARGV0")); - const auto size = file_size(argv0); - TEST_ASSERT_GREATER(size, static_cast(0)); + const int64_t size = static_cast(file_size(argv0)); + TEST_ASSERT_GREATER(size, 0); } { // We always have sys::filesystem, even if it's not used. const sys::filesystem::path argv0(os.getSpecialEnv("ARGV0")); - const auto size = file_size(argv0); - TEST_ASSERT_GREATER(size, static_cast(0)); + const int64_t size = static_cast(file_size(argv0)); + TEST_ASSERT_GREATER(size, 0); } } diff --git a/modules/c++/sys/unittests/test_path.cpp b/modules/c++/sys/unittests/test_path.cpp index 42e79af8e3..ab838d0275 100644 --- a/modules/c++/sys/unittests/test_path.cpp +++ b/modules/c++/sys/unittests/test_path.cpp @@ -53,7 +53,7 @@ TEST_CASE(testPathMerge) std::vector paths; const auto splitResult = os.splitEnv("PATH", paths); TEST_ASSERT_TRUE(splitResult); - TEST_ASSERT_GREATER(paths.size(), static_cast(0)); + TEST_ASSERT_FALSE(paths.empty()); auto path = find_directory(paths); TEST_ASSERT_TRUE(coda_oss::filesystem::is_directory(path)); @@ -65,7 +65,7 @@ TEST_CASE(testPathMerge) bool isAbsolute; auto components = sys::Path::separate(path, isAbsolute); - TEST_ASSERT_GREATER(components.size(), static_cast(0)); + TEST_ASSERT_FALSE(components.empty()); auto result = sys::Path::merge(components, isAbsolute); TEST_ASSERT_EQ(result, path); TEST_ASSERT_TRUE(coda_oss::filesystem::is_directory(result)); diff --git a/modules/c++/xml.lite/unittests/test_soapelements.cpp b/modules/c++/xml.lite/unittests/test_soapelements.cpp index 21ecbfdd86..6be98e7d46 100644 --- a/modules/c++/xml.lite/unittests/test_soapelements.cpp +++ b/modules/c++/xml.lite/unittests/test_soapelements.cpp @@ -43,6 +43,7 @@ struct SOAP final : public xml::lite::Document std::string characterData = "") override { const xml::lite::QName asQName(uri, qname); xml::lite::Element* elem = new SOAPBody(asQName); + elem->setCharacterData(characterData); // avoid unused parameter warning elem->setCharacterData(test_text); return elem; } diff --git a/modules/c++/xml.lite/unittests/test_xmlparser.cpp b/modules/c++/xml.lite/unittests/test_xmlparser.cpp index 994ea52d85..6a4ff8bf18 100644 --- a/modules/c++/xml.lite/unittests/test_xmlparser.cpp +++ b/modules/c++/xml.lite/unittests/test_xmlparser.cpp @@ -145,6 +145,7 @@ TEST_CASE(testXml_setCharacterData) xml::lite::MinidomParser xmlParser; auto& a = testXmlUtf8_(xmlParser); a.setCharacterData(utf8Text8); + TEST_ASSERT_TRUE(true); // need to use hidden "testName" parameter } static std::string testXmlPrint_(std::string& expected, const std::string& characterData)