diff --git a/externals/coda-oss/.github/workflows/build_unittest.yml b/externals/coda-oss/.github/workflows/build_unittest.yml index 04b2f3fae3..b96a17a63e 100644 --- a/externals/coda-oss/.github/workflows/build_unittest.yml +++ b/externals/coda-oss/.github/workflows/build_unittest.yml @@ -36,8 +36,7 @@ jobs: cd .. cd target-Debug cmake --build . --config Debug -j - - name: test - # should run w/o install + - name: test # should run w/o install run: | cd target-Release ctest -C Release --output-on-failure @@ -52,17 +51,43 @@ jobs: cd target-Debug cmake --build . --config Debug --target install cd .. + + build-msbuild-windows: + strategy: + matrix: + os: [windows-latest] + platform: [x64] + configuration: [Debug] # Debug turns on more compiler warnings + name: ${{ matrix.os }}-msbuild + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + - name: configure + run: | + ls env: + mkdir out + cd out + cmake .. -DCMAKE_INSTALL_PREFIX=install\${{ matrix.platform }}-${{ matrix.configuration }} -DENABLE_PYTHON=OFF + - name: build + run: | + cd out + cmake --build . --config ${{ matrix.configuration }} -j + cmake --build . --config ${{ matrix.configuration }} --target install - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.1 + uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild with: msbuild-architecture: x64 - name: msbuild run: | - msbuild coda-oss.sln /p:configuration=Release - msbuild coda-oss.sln /p:configuration=Debug - #- name: mstest - # run: | - # mstest /testcontainer:${RUNNER_WORKSPACE}\coda-oss\x64\Debug\UnitTest.dll + msbuild coda-oss.sln /p:configuration=${{ matrix.configuration }} + # Can't figure out how to make this work :-( + #- name: vstest + # uses: microsoft/vstest-action@v1.0.0 # https://github.com/marketplace/actions/vstest-action + # with: + # testAssembly: UnitTest.dll + # searchFolder: D:\a\nitro\nitro\${{ matrix.platform }}\${{ matrix.configuration }} + # runInParallel: true build-linux-cmake: strategy: diff --git a/externals/coda-oss/ReleaseNotes.md b/externals/coda-oss/ReleaseNotes.md index bf8f97f3af..c54bdadcbc 100644 --- a/externals/coda-oss/ReleaseNotes.md +++ b/externals/coda-oss/ReleaseNotes.md @@ -18,16 +18,16 @@ * wrap common "file open" routines (e.g., `fopen()`) to support `sys::expandEnvironmentVariables()`. * add header-only [HighFive](https://github.com/BlueBrain/HighFive) HDF5-wrapper library. * Added a handful of [HighFive](https://github.com/BlueBrain/HighFive) utility routines. -* `mt::transform_async()` removed, it doesn't match C++17 techniques.' +* `mt::transform_async()` removed, it doesn't match C++17 techniques. * Revamp `sys::byteSwap()` for improved type-safety and [better performance](https://devblogs.microsoft.com/cppblog/a-tour-of-4-msvc-backend-improvements/). - * Added case-insensitive string comparison utilties: `str::eq()` and `str::ne()`; + * Added case-insensitive string comparison utilities: `str::eq()` and `str::ne()`; `xml::lite::Uri`s compare case-insensitive. ## [Release 2022-12-14](https://github.com/mdaus/coda-oss/releases/tag/2022-12-14) * removed remaining vestiges of `std::auto_ptr`, provide `mem::AutoPtr` for the tiny handful of places (e.g., SWIG bindings) that still need copying. -* `xml::lite::Element` overloads to make creting new XML documents easier; see unittests for examples. +* `xml::lite::Element` overloads to make creating new XML documents easier; see unittests for examples. * try even harder to find unittest files in various scenarios. * build *hdf5.lite* with **waf**. * New `--optz=fastest-possible` (**waf** only) which adds @@ -40,8 +40,8 @@ * The [HDFGroup](https://hdfgroup.org/)s [HDF5 library](https://github.com/HDFGroup/hdf5) is built and installed; a simple (and very incomplete!) wrapper is provided, this is at the "hello world!" stage. * A few **cli** routines have been tweaked to make unit-testing easier. -* Utilitiy routines for finding various files when unit-testing. -* Removed C++14 work-arounds needed in C++11. Legacy C++ exception specificatons removed. +* Utility routines for finding various files when unit-testing. +* Removed C++14 work-arounds needed in C++11. Legacy C++ exception specifications removed. * Rebuild `waf` for FIPS error; added more debug options. ## [Release 2022-08-30](https://github.com/mdaus/coda-oss/releases/tag/2022-08-30) diff --git a/externals/coda-oss/UnitTest/CppUnitTestAssert.cpp b/externals/coda-oss/UnitTest/CppUnitTestAssert.cpp index fdcf5f92b5..5bea8da590 100644 --- a/externals/coda-oss/UnitTest/CppUnitTestAssert.cpp +++ b/externals/coda-oss/UnitTest/CppUnitTestAssert.cpp @@ -1,43 +1,5 @@ #include "pch.h" #include "TestCase.h" -#include "str/EncodedStringView.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -// EQUALS_MESSAGE() wants ToString() specializations (or overloads) for our types, which is a nusiance. -// This hooks up our existing str::toString() into the VC++ unit-test infrastructure - -// C++ hack to call private methods -// https://stackoverflow.com/a/71578383/8877 - -using FailOnCondition_t = void(bool condition, const unsigned short* message, const __LineInfo* pLineInfo); // declare method's type -using GetAssertMessage_t = std::wstring(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message); // declare method's type -template -struct caller final // helper structure to inject call() code -{ - friend void FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo) - { - fFailOnCondition(condition, message, pLineInfo); - } - - friend std::wstring GetAssertMessage(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message) - { - return fGetAssertMessage(equality, expected, actual, message); - } -}; -template struct caller<&Assert::FailOnCondition, &Assert::GetAssertMessage>; // even instantiation of the helper - -void FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo); // declare caller -void test::Assert::FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo) -{ - ::FailOnCondition(condition, message, pLineInfo); // and call! -} - -std::wstring GetAssertMessage(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message); // declare caller -std::wstring test::Assert::GetAssertMessage(bool equality, const std::string& expected, const std::string& actual, const wchar_t *message) -{ - const str::EncodedStringView vExpected(expected); - const str::EncodedStringView vActual(actual); - return ::GetAssertMessage(equality, vExpected.wstring(), vActual.wstring(), message); // and call! -} +// Can't get this to build in the **coda-oss** project. +#include "sys/source/CppUnitTestAssert_.cpp_" diff --git a/externals/coda-oss/UnitTest/TestCase.h b/externals/coda-oss/UnitTest/TestCase.h index f4438821f1..e769f584fc 100644 --- a/externals/coda-oss/UnitTest/TestCase.h +++ b/externals/coda-oss/UnitTest/TestCase.h @@ -1,138 +1,3 @@ #pragma once -#include -#include - -#include "CppUnitTest.h" -#include -#include - -#undef TEST_CHECK -#undef TEST_ASSERT -#undef TEST_ASSERT_NULL -#undef TEST_ASSERT_NOT_NULL -#undef TEST_ASSERT_TRUE -#undef TEST_ASSERT_FALSE -#undef TEST_MAIN -#undef TEST_CASE -#define TEST_CHECK(X) -#define TEST_MAIN(X) -#define TEST_ASSERT_NULL(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsNull(X) -#define TEST_ASSERT_NOT_NULL(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsNotNull(X) -#define TEST_ASSERT_TRUE(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(X) -#define TEST_ASSERT_FALSE(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsFalse(X) -#define TEST_ASSERT(X) TEST_ASSERT_TRUE(X) -#define CODA_OSS_testMethod_(X) testMethod ## _ ## X -#define TEST_CASE(X) TEST_METHOD(X) { CODA_OSS_testMethod_(X)(#X); } void CODA_OSS_testMethod_(X)(std::string testName) - -namespace test -{ - struct Assert final - { - static void FailOnCondition(bool condition, const unsigned short* message, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo); - static std::wstring GetAssertMessage(bool equality, const std::string& expected, const std::string& actual, const wchar_t *message); - }; -#define CODA_OSS_equals_message_(expected, actual, message) reinterpret_cast(test::Assert::GetAssertMessage(true, test::toString(expected), test::toString(actual), message).c_str()) -#define CODA_OSS_not_equals_message_(notExpected, actual, message) reinterpret_cast(test::Assert::GetAssertMessage(false, test::toString(notExpected), test::toString(actual), message).c_str()) -#define CODA_OSS_message_(message) reinterpret_cast(test::Assert::GetAssertMessage(false, "", "", message).c_str()) - -// see Assert::AreEqual<> -template -inline void diePrintf_eq(const TExpected& expected, const TActual& actual, - const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) -{ - Assert::FailOnCondition(expected == actual, CODA_OSS_equals_message_(expected, actual, message), pLineInfo); -} - -// see Assert::AreNotEqual<> -template -inline void diePrintf_ne(const TExpected& notExpected, const TActual& actual, - const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) -{ - Assert::FailOnCondition(notExpected != actual, CODA_OSS_not_equals_message_(notExpected, actual, message), pLineInfo); -} - -template -inline void diePrintf_ge(const TX1& X1, const TX2& X2, - const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) -{ - Assert::FailOnCondition(X1 >= X2, CODA_OSS_message_(message), pLineInfo); -} -template -inline void diePrintf_gt(const TX1& X1, const TX2& X2, - const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) -{ - Assert::FailOnCondition(X1 > X2, CODA_OSS_message_(message), pLineInfo); -} -template -inline void diePrintf_le(const TX1& X1, const TX2& X2, - const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) -{ - Assert::FailOnCondition(X1 <= X2, CODA_OSS_message_(message), pLineInfo); -} -template -inline void diePrintf_lt(const TX1& X1, const TX2& X2, - const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) -{ - Assert::FailOnCondition(X1 < X2, CODA_OSS_message_(message), pLineInfo); -} - -} -#undef CODA_OSS_test_diePrintf_eq_ -#undef CODA_OSS_test_diePrintf_not_eq_ -#define CODA_OSS_test_diePrintf_eq_(X1, X2) testName, ::test::diePrintf_eq(X1, X2) -#define CODA_OSS_test_diePrintf_not_eq_(X1, X2) testName, ::test::diePrintf_ne(X1, X2) - -#undef CODA_OSS_test_diePrintf_greater_eq_ -#undef CODA_OSS_test_diePrintf_greater_ -#undef CODA_OSS_test_diePrintf_lesser_eq_ -#undef CODA_OSS_test_diePrintf_lesser_ -#define CODA_OSS_test_diePrintf_greater_eq_(X1, X2) testName, ::test::diePrintf_ge(X1, X2) -#define CODA_OSS_test_diePrintf_greater_(X1, X2) testName, ::test::diePrintf_gt(X1, X2) -#define CODA_OSS_test_diePrintf_lesser_eq_(X1, X2) testName, ::test::diePrintf_le(X1, X2) -#define CODA_OSS_test_diePrintf_lesser_(X1, X2) testName, ::test::diePrintf_lt(X1, X2) - -template -inline void test_assert_greater_(const TX1& X1, const TX2& X2) -{ - Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(X1 > X2); -} -#undef TEST_ASSERT_GREATER -#define TEST_ASSERT_GREATER(X1, X2) testName, test_assert_greater_(X1, X2) - -#undef TEST_ASSERT_ALMOST_EQ_EPS -#define TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS) { (void)testName; Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(X1, X2, EPS); Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(X2, X1, EPS); } -namespace test -{ -inline void assert_almost_eq(const std::string& testName, float X1, float X2) -{ - constexpr auto EPS = static_cast(0.0001); - TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS); -} -inline void assert_almost_eq(const std::string& testName, double X1, double X2) -{ - constexpr auto EPS = static_cast(0.0001); - TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS); -} -inline void assert_almost_eq(const std::string& testName, long double X1, long double X2) -{ - assert_almost_eq(testName, static_cast(X1), static_cast(X2)); -} -} - -#undef TEST_ASSERT_ALMOST_EQ -#define TEST_ASSERT_ALMOST_EQ(X1, X2) test::assert_almost_eq(testName, X1, X2) - -#undef TEST_ASSERT_EQ_MSG -#define TEST_ASSERT_EQ_MSG(msg, X1, X2) testName, Microsoft::VisualStudio::CppUnitTestFramework::Logger::WriteMessage(msg.c_str()); TEST_ASSERT_EQ(X1, X2) - -#undef TEST_FAIL_MSG -#define TEST_FAIL_MSG(msg) { (void)testName; const str::EncodedStringView vw(msg); Microsoft::VisualStudio::CppUnitTestFramework::Assert::Fail(vw.wstring().c_str()); } - -#undef TEST_EXCEPTION -#undef TEST_THROWS -#undef TEST_SPECIFIC_EXCEPTION -#define TEST_EXCEPTION(X) (void)testName; try{ (X); TEST_FAIL(#X " should have thrown."); } CODA_OSS_TEST_EXCEPTION_catch_ -#define TEST_THROWS(X) (void)testName; try{ (X); TEST_FAIL(#X " should have thrown."); } catch (...){ TEST_ASSERT_TRUE(true); } -#define TEST_SPECIFIC_EXCEPTION(X, Y) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::ExpectException([&](){(X);}) - +#include diff --git a/externals/coda-oss/UnitTest/UnitTest.vcxproj b/externals/coda-oss/UnitTest/UnitTest.vcxproj index 65b3ca3225..835f574dca 100644 --- a/externals/coda-oss/UnitTest/UnitTest.vcxproj +++ b/externals/coda-oss/UnitTest/UnitTest.vcxproj @@ -57,7 +57,7 @@ Use Level4 true - $(VCInstallDir)UnitTest\include;$(ProjectDir);$(SolutionDir)modules\c++\;$(SolutionDir)modules\c++\avx\include\;$(SolutionDir)modules\c++\cli\include\;$(SolutionDir)modules\c++\config\include\;$(SolutionDir)modules\c++\coda_oss\include\;$(SolutionDir)modules\c++\gsl\include\;$(SolutionDir)modules\c++\hdf5.lite\include\;$(SolutionDir)modules\c++\io\include\;$(SolutionDir)modules\c++\std\include\;$(SolutionDir)modules\c++\str\include\;$(SolutionDir)modules\c++\sys\include\;$(SolutionDir)modules\c++\except\include\;$(SolutionDir)modules\c++\logging\include\;$(SolutionDir)modules\c++\math\include\;$(SolutionDir)modules\c++\math.linear\include\;$(SolutionDir)modules\c++\math.poly\include\;$(SolutionDir)modules\c++\mem\include\;$(SolutionDir)modules\c++\mt\include\;$(SolutionDir)modules\c++\polygon\include\;$(SolutionDir)modules\c++\re\include\;$(SolutionDir)modules\c++\types\include\;$(SolutionDir)modules\c++\units\include\;$(SolutionDir)modules\c++\xml.lite\include\;$(SolutionDir)modules\c++\zip\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\;%(AdditionalIncludeDirectories) + $(VCInstallDir)UnitTest\include;$(ProjectDir);$(SolutionDir)modules\c++\;$(SolutionDir)modules\c++\avx\include;$(SolutionDir)modules\c++\cli\include;$(SolutionDir)modules\c++\config\include;$(SolutionDir)modules\c++\coda_oss\include;$(SolutionDir)modules\c++\gsl\include;$(SolutionDir)modules\c++\hdf5.lite\include;$(SolutionDir)modules\c++\io\include;$(SolutionDir)modules\c++\std\include;$(SolutionDir)modules\c++\str\include;$(SolutionDir)modules\c++\sys\include;$(SolutionDir)modules\c++\except\include;$(SolutionDir)modules\c++\logging\include;$(SolutionDir)modules\c++\math\include;$(SolutionDir)modules\c++\math.linear\include;$(SolutionDir)modules\c++\math.poly\include;$(SolutionDir)modules\c++\mem\include;$(SolutionDir)modules\c++\mt\include;$(SolutionDir)modules\c++\polygon\include;$(SolutionDir)modules\c++\re\include;$(SolutionDir)modules\c++\types\include;$(SolutionDir)modules\c++\units\include;$(SolutionDir)modules\c++\xml.lite\include;$(SolutionDir)modules\c++\zip\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;%(AdditionalIncludeDirectories) _DEBUG;%(PreprocessorDefinitions);MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 true pch.h @@ -65,7 +65,6 @@ true Guard ProgramDatabase - true true true true @@ -75,7 +74,7 @@ Windows - $(SolutionDir)\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\lib\;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) @@ -85,13 +84,12 @@ true true true - $(VCInstallDir)UnitTest\include;$(ProjectDir);$(SolutionDir)modules\c++\;$(SolutionDir)modules\c++\avx\include\;$(SolutionDir)modules\c++\cli\include\;$(SolutionDir)modules\c++\config\include\;$(SolutionDir)modules\c++\coda_oss\include\;$(SolutionDir)modules\c++\gsl\include\;$(SolutionDir)modules\c++\hdf5.lite\include\;$(SolutionDir)modules\c++\io\include\;$(SolutionDir)modules\c++\std\include\;$(SolutionDir)modules\c++\str\include\;$(SolutionDir)modules\c++\sys\include\;$(SolutionDir)modules\c++\except\include\;$(SolutionDir)modules\c++\logging\include\;$(SolutionDir)modules\c++\math\include\;$(SolutionDir)modules\c++\math.linear\include\;$(SolutionDir)modules\c++\math.poly\include\;$(SolutionDir)modules\c++\mem\include\;$(SolutionDir)modules\c++\mt\include\;$(SolutionDir)modules\c++\polygon\include\;$(SolutionDir)modules\c++\re\include\;$(SolutionDir)modules\c++\types\include\;$(SolutionDir)modules\c++\units\include\;$(SolutionDir)modules\c++\xml.lite\include\;$(SolutionDir)modules\c++\zip\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\;%(AdditionalIncludeDirectories) + $(VCInstallDir)UnitTest\include;$(ProjectDir);$(SolutionDir)modules\c++\;$(SolutionDir)modules\c++\avx\include;$(SolutionDir)modules\c++\cli\include;$(SolutionDir)modules\c++\config\include;$(SolutionDir)modules\c++\coda_oss\include;$(SolutionDir)modules\c++\gsl\include;$(SolutionDir)modules\c++\hdf5.lite\include;$(SolutionDir)modules\c++\io\include;$(SolutionDir)modules\c++\std\include;$(SolutionDir)modules\c++\str\include;$(SolutionDir)modules\c++\sys\include;$(SolutionDir)modules\c++\except\include;$(SolutionDir)modules\c++\logging\include;$(SolutionDir)modules\c++\math\include;$(SolutionDir)modules\c++\math.linear\include;$(SolutionDir)modules\c++\math.poly\include;$(SolutionDir)modules\c++\mem\include;$(SolutionDir)modules\c++\mt\include;$(SolutionDir)modules\c++\polygon\include;$(SolutionDir)modules\c++\re\include;$(SolutionDir)modules\c++\types\include;$(SolutionDir)modules\c++\units\include;$(SolutionDir)modules\c++\xml.lite\include;$(SolutionDir)modules\c++\zip\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;%(AdditionalIncludeDirectories) NDEBUG;%(PreprocessorDefinitions);MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 true pch.h true Guard - true true true true @@ -103,7 +101,7 @@ Windows true true - $(SolutionDir)\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\lib\;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) diff --git a/externals/coda-oss/coda-oss.sln b/externals/coda-oss/coda-oss.sln index 5583590dd7..cea89c6f03 100644 --- a/externals/coda-oss/coda-oss.sln +++ b/externals/coda-oss/coda-oss.sln @@ -15,6 +15,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "UnitTest\UnitTest.vcxproj", "{34A31B3F-47C5-441D-AB22-3C85B3C5314E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github-workflows", ".github-workflows", "{E0FA1194-0806-4A6B-A331-33CB43C0C946}" + ProjectSection(SolutionItems) = preProject + .github\workflows\build_unittest.yml = .github\workflows\build_unittest.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -33,6 +38,9 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {E0FA1194-0806-4A6B-A331-33CB43C0C946} = {DEB848DD-4285-4BFA-9B2F-60FA46200205} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3CAB4AC9-7865-44AD-8623-57905729A559} EndGlobalSection diff --git a/externals/coda-oss/modules/c++/coda-oss.vcxproj b/externals/coda-oss/modules/c++/coda-oss.vcxproj index b0c706116b..cd74689659 100644 --- a/externals/coda-oss/modules/c++/coda-oss.vcxproj +++ b/externals/coda-oss/modules/c++/coda-oss.vcxproj @@ -60,6 +60,7 @@ + @@ -146,6 +147,7 @@ + @@ -526,6 +528,10 @@ + + true + true + 16.0 @@ -574,27 +580,27 @@ true _DEBUG;_LIB;%(PreprocessorDefinitions);CODA_OSS_EXPORTS;CODA_OSS_DLL;MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 pch.h - cli\include\;coda_oss\include;config\include\;dbi\include\;except\include\;gsl\include\;hdf5.lite\include\;io\include\;logging\include\;math\include\;math.linear\include\;math.poly\include\;mem\include\;mt\include\;net\include\;net.ssl\include\;plugin\include\;polygon\include\;re\include\;sio.lite\include\;std\include\;str\include\;sys\include\;tiff\include;types\include\;unique\include\;units\include\;xml.lite\include\;zip\include\;$(ProjectDir)..\..\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\ + cli\include;coda_oss\include;config\include;dbi\include;except\include;gsl\include;hdf5.lite\include;io\include;logging\include;math\include;math.linear\include;math.poly\include;mem\include;mt\include;net\include;net.ssl\include;plugin\include;polygon\include;re\include;sio.lite\include;std\include;str\include;sys\include;tiff\include;types\include;unique\include;units\include;xml.lite\include;zip\include;$(ProjectDir)include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\$(ProjectName)\out\install\$(Platform)-$(Configuration)\include Use pch.h true Guard ProgramDatabase - true true true true /Zc:__cplusplus %(AdditionalOptions) true AdvancedVectorExtensions2 + MultiThreadedDebugDLL true true - $(ProjectDir)..\..\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\lib\ - hdf5-c++.lib;z.lib;minizip.lib;xerces-c.lib;rpcrt4.lib;%(AdditionalDependencies) + $(SolutionDir)\out\install\$(Platform)-$(Configuration)\lib;$(SolutionDir)\externals\$(ProjectName)\out\install\$(Platform)-$(Configuration)\lib + rpcrt4.lib;%(AdditionalDependencies) @@ -605,12 +611,11 @@ true NDEBUG;_LIB;%(PreprocessorDefinitions);CODA_OSS_EXPORTS;CODA_OSS_DLL;MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 pch.h - cli\include\;coda_oss\include;config\include\;dbi\include\;except\include\;gsl\include\;hdf5.lite\include\;io\include\;logging\include\;math\include\;math.linear\include\;math.poly\include\;mem\include\;mt\include\;net\include\;net.ssl\include\;plugin\include\;polygon\include\;re\include\;sio.lite\include\;std\include\;str\include\;sys\include\;tiff\include;types\include\;unique\include\;units\include\;xml.lite\include\;zip\include\;$(ProjectDir)..\..\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\ + cli\include;coda_oss\include;config\include;dbi\include;except\include;gsl\include;hdf5.lite\include;io\include;logging\include;math\include;math.linear\include;math.poly\include;mem\include;mt\include;net\include;net.ssl\include;plugin\include;polygon\include;re\include;sio.lite\include;std\include;str\include;sys\include;tiff\include;types\include;unique\include;units\include;xml.lite\include;zip\include;$(ProjectDir)include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\$(ProjectName)\out\install\$(Platform)-$(Configuration)\include Use pch.h true Guard - true true true true @@ -623,8 +628,8 @@ true true true - $(ProjectDir)..\..\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\lib\ - hdf5-c++.lib;z.lib;minizip.lib;xerces-c.lib;rpcrt4.lib;%(AdditionalDependencies) + $(SolutionDir)\out\install\$(Platform)-$(Configuration)\lib;$(SolutionDir)\externals\$(ProjectName)\out\install\$(Platform)-$(Configuration)\lib + rpcrt4.lib;%(AdditionalDependencies) diff --git a/externals/coda-oss/modules/c++/coda-oss.vcxproj.filters b/externals/coda-oss/modules/c++/coda-oss.vcxproj.filters index 2b1f013080..adb5a57f71 100644 --- a/externals/coda-oss/modules/c++/coda-oss.vcxproj.filters +++ b/externals/coda-oss/modules/c++/coda-oss.vcxproj.filters @@ -963,6 +963,12 @@ hdf5.lite + + mt + + + include + @@ -1586,5 +1592,8 @@ std + + sys + \ No newline at end of file diff --git a/externals/coda-oss/modules/c++/dbi/source/MySQLConnection.cpp b/externals/coda-oss/modules/c++/dbi/source/MySQLConnection.cpp index 9f0e6aae36..49c01f3044 100644 --- a/externals/coda-oss/modules/c++/dbi/source/MySQLConnection.cpp +++ b/externals/coda-oss/modules/c++/dbi/source/MySQLConnection.cpp @@ -38,7 +38,7 @@ bool dbi::MySQLConnection::connect(const std::string& database, if (!mysql_real_connect(&mDBHandle, host.c_str(), user.c_str(), pass.c_str(), database.c_str(), port, - NULL, 0)) + nullptr, 0)) { return false; } diff --git a/externals/coda-oss/modules/c++/dbi/source/OracleConnection.cpp b/externals/coda-oss/modules/c++/dbi/source/OracleConnection.cpp index 66ff79cb50..a03203e4f9 100644 --- a/externals/coda-oss/modules/c++/dbi/source/OracleConnection.cpp +++ b/externals/coda-oss/modules/c++/dbi/source/OracleConnection.cpp @@ -80,7 +80,7 @@ const std::string dbi::OracleConnection::getLastErrorMessage() char errbuf[100]; memset(errbuf, 0, 100); int errcode; - OCIErrorGet((dvoid *)mErrorHandle, (ub4) 1, (text *) NULL, &errcode, + OCIErrorGet((dvoid *)mErrorHandle, (ub4) 1, (text *) nullptr, &errcode, (OraText*)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR); if (strlen(errbuf) > 0) return std::string(errbuf); @@ -117,7 +117,7 @@ dbi::pResultSet dbi::OracleConnection::query(const std::string& q) OCIStmtPrepare(countHandle, mErrorHandle, (const OraText*)countq.c_str(), (ub4)countq.length(), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT); OCIStmtExecute(mContextHandle, countHandle, mErrorHandle, (ub4)val, (ub4)0, - (CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_DEFAULT); + (CONST OCISnapshot *) nullptr, (OCISnapshot *) nullptr, OCI_DEFAULT); OCIDefine * defineHandle = nullptr; OCIDefineByPos(countHandle, &defineHandle, mErrorHandle, 1, &rowCount, sizeof(rowCount), SQLT_UIN, 0, 0, 0, OCI_DEFAULT); @@ -126,7 +126,7 @@ dbi::pResultSet dbi::OracleConnection::query(const std::string& q) /* Execute the SQL statment */ OCIStmtExecute(mContextHandle, sqlHandle, mErrorHandle, (ub4) val, (ub4) 0, - (CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_DEFAULT); + (CONST OCISnapshot *) nullptr, (OCISnapshot *) nullptr, OCI_DEFAULT); return dbi::pResultSet(new dbi::OracleResultSet(sqlHandle, mErrorHandle, rowCount)); } @@ -229,8 +229,8 @@ dbi::Row dbi::OracleResultSet::fetchRow() ub4 bufferSize = 9; OCIDateToText(mErrorHandle, (const OCIDate*)fields[i].value, - NULL, 0, - NULL, 0, &bufferSize, (text*)buffer); + nullptr, 0, + nullptr, 0, &bufferSize, (text*)buffer); memset(fields[i].value, '\0', sizeof(OCIDate)); strncpy(fields[i].value, buffer, bufferSize); } diff --git a/externals/coda-oss/modules/c++/dbi/source/PgSQLConnection.cpp b/externals/coda-oss/modules/c++/dbi/source/PgSQLConnection.cpp index 5e9519dd7e..fc5a86a97f 100644 --- a/externals/coda-oss/modules/c++/dbi/source/PgSQLConnection.cpp +++ b/externals/coda-oss/modules/c++/dbi/source/PgSQLConnection.cpp @@ -97,7 +97,7 @@ dbi::pResultSet dbi::PgSQLConnection::query(const std::string& q) throw dbi::SQLException(Ctxt(errorMessage)); } - return dbi::pResultSet(new PgSQLResultSet(NULL)); + return dbi::pResultSet(new PgSQLResultSet(nullptr)); } dbi::Row dbi::PgSQLResultSet::fetchRow() diff --git a/externals/coda-oss/modules/c++/except/include/except/Throwable.h b/externals/coda-oss/modules/c++/except/include/except/Throwable.h index 84fe4d0385..2a7deecbb7 100644 --- a/externals/coda-oss/modules/c++/except/include/except/Throwable.h +++ b/externals/coda-oss/modules/c++/except/include/except/Throwable.h @@ -165,7 +165,9 @@ class CODA_OSS_API Throwable const Trace& t = getTrace(); if (t.getSize() > 0) s << ": " << t; - return s.str(); + + std::string retval(s.str().c_str()); // truncate to first '\0' + return retval; } const std::vector& getBacktrace() const noexcept @@ -265,7 +267,7 @@ class ThrowableEx : public Throwable // "ThrowableEx" = "Throwable exception" ThrowableEx(const Throwable& t, const Context& ctx) : Throwable(t, ctx) {} #if !CODA_OSS_except_Throwable_ISA_std_exception - const char* what() const noexcept final // derived classes override toString() + const char* what() const noexcept override final // derived classes override toString() { const Throwable* pThrowable = this; return pThrowable->what(); diff --git a/externals/coda-oss/modules/c++/except/source/Trace.cpp b/externals/coda-oss/modules/c++/except/source/Trace.cpp index 926f321b40..a40645d718 100644 --- a/externals/coda-oss/modules/c++/except/source/Trace.cpp +++ b/externals/coda-oss/modules/c++/except/source/Trace.cpp @@ -26,12 +26,9 @@ namespace except { std::ostream& operator<<(std::ostream& os, const Trace& t) { - const std::list& stack = t.getStack(); - - for (std::list::const_iterator it = stack.begin(); - it != stack.end(); ++it) + for (auto&& trace : t.getStack()) { - os << *it << std::endl; + os << trace << "\n"; } return os; } diff --git a/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/H5_.h b/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/H5_.h index 74ebc436cb..cd470aef24 100644 --- a/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/H5_.h +++ b/externals/coda-oss/modules/c++/hdf5.lite/include/hdf5/lite/H5_.h @@ -28,6 +28,7 @@ CODA_OSS_disable_warning_system_header_push #if _MSC_VER +#pragma warning(disable: 6313) // Incorrect operator. Use an equality test to check for zero-valued flags. #pragma warning(disable: 26493) // Don't use C-style casts (type.4). #pragma warning(disable: 26494) // Variable '...' is uninitialized. Always initialize an object (type.5). #pragma warning(disable: 26451) // Arithmetic overflow: Using operator '...' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '...' to avoid overflow (io.2). @@ -56,6 +57,8 @@ CODA_OSS_disable_warning(-Wzero-as-null-pointer-constant) #include #include +#include +#include #include #include #include diff --git a/externals/coda-oss/modules/c++/hdf5.lite/source/H5.h b/externals/coda-oss/modules/c++/hdf5.lite/source/H5.h index 24b0d8cfc1..ecfe293d18 100644 --- a/externals/coda-oss/modules/c++/hdf5.lite/source/H5.h +++ b/externals/coda-oss/modules/c++/hdf5.lite/source/H5.h @@ -20,17 +20,16 @@ * */ +#pragma once #ifndef CODA_OSS_hdf5_lite_H5_h_INCLUDED_ #define CODA_OSS_hdf5_lite_H5_h_INCLUDED_ -#pragma once #include -// see https://docs.hdfgroup.org/archive/support/HDF5/doc1.8/cpplus_RM/readdata_8cpp-example.html -#include - #include "types/RowCol.h" +#include "hdf5/lite/H5_.h" + // Utility routines for INTERNAL use! namespace hdf5 diff --git a/externals/coda-oss/modules/c++/hdf5.lite/source/hdf5.lite.h b/externals/coda-oss/modules/c++/hdf5.lite/source/hdf5.lite.h index fce6fb7c0d..29617ac235 100644 --- a/externals/coda-oss/modules/c++/hdf5.lite/source/hdf5.lite.h +++ b/externals/coda-oss/modules/c++/hdf5.lite/source/hdf5.lite.h @@ -20,18 +20,17 @@ * */ +#pragma once #ifndef CODA_OSS_hdf5_lite_hdf5_lite_h_INCLUDED_ #define CODA_OSS_hdf5_lite_hdf5_lite_h_INCLUDED_ -#pragma once #include #include #include -// see https://docs.hdfgroup.org/archive/support/HDF5/doc1.8/cpplus_RM/readdata_8cpp-example.html -#include - #include "except/Exception.h" + +#include "hdf5/lite/H5_.h" #include "hdf5/lite/HDF5Exception.h" // Utility routines for INTERNAL use! diff --git a/externals/coda-oss/modules/c++/hdf5.lite/unittests/test_highfive.cpp b/externals/coda-oss/modules/c++/hdf5.lite/unittests/test_highfive.cpp index 14e9f8af23..b506e49484 100644 --- a/externals/coda-oss/modules/c++/hdf5.lite/unittests/test_highfive.cpp +++ b/externals/coda-oss/modules/c++/hdf5.lite/unittests/test_highfive.cpp @@ -29,12 +29,8 @@ #include "types/RowCol.h" #include "mem/ComplexView.h" -#include "highfive/H5Easy.hpp" -#include "highfive/H5DataSet.hpp" -#include "highfive/H5File.hpp" - -#include "hdf5/lite/SpanRC.h" #include "hdf5/lite/highfive.h" +#include "hdf5/lite/SpanRC.h" static std::filesystem::path find_unittest_file(const std::filesystem::path& name) { diff --git a/externals/coda-oss/modules/c++/include/TestCase.h b/externals/coda-oss/modules/c++/include/TestCase.h index a433140047..5a091dd9be 100644 --- a/externals/coda-oss/modules/c++/include/TestCase.h +++ b/externals/coda-oss/modules/c++/include/TestCase.h @@ -211,6 +211,7 @@ inline int main(TFunc f) #define CODA_OSS_test_eq(X1, X2) (CODA_OSS_test_eq_(X1, X2) && !CODA_OSS_test_ne_(X1, X2)) #define TEST_ASSERT_EQ(X1, X2) if (!CODA_OSS_test_eq((X1), (X2))) { CODA_OSS_test_diePrintf_eq_(X1, X2); } #define TEST_ASSERT_EQ_MSG(msg, X1, X2) if (!CODA_OSS_test_eq((X1), (X2))) { CODA_OSS_test_diePrintf_eq_msg_(msg, X1, X2); } +#define TEST_ASSERT_EQ_STR(X1, X2) TEST_ASSERT_EQ(std::string(X1), std::string(X2)) #define TEST_ASSERT_NOT_EQ(X1, X2) if (!CODA_OSS_test_ne((X1), (X2))) { CODA_OSS_test_diePrintf_not_eq_(X1, X2); } #define TEST_ASSERT_NOT_EQ_MSG(msg, X1, X2) if (!CODA_OSS_test_ne((X1), (X2))) { CODA_OSS_test_diePrintf_not_eq_msg_(msg, X1, X2); } diff --git a/externals/coda-oss/modules/c++/include/UnitTest.h b/externals/coda-oss/modules/c++/include/UnitTest.h new file mode 100644 index 0000000000..751843c1f0 --- /dev/null +++ b/externals/coda-oss/modules/c++/include/UnitTest.h @@ -0,0 +1,143 @@ +#pragma once + +#include +#include + +#include "TestCase.h" +#include "str/EncodedStringView.h" + +#if !_MSC_VER +#error "This file is for use with a Visual Studio 'UnitTest' project." +#endif + +// Use our various TEST macros with a Visual Studio "UnitTest" project. +#include + +#undef TEST_CHECK +#undef TEST_ASSERT +#undef TEST_ASSERT_NULL +#undef TEST_ASSERT_NOT_NULL +#undef TEST_ASSERT_TRUE +#undef TEST_ASSERT_FALSE +#undef TEST_MAIN +#undef TEST_CASE +#define TEST_CHECK(X) +#define TEST_MAIN(X) +#define TEST_ASSERT_NULL(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsNull(X) +#define TEST_ASSERT_NOT_NULL(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsNotNull(X) +#define TEST_ASSERT_TRUE(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(X) +#define TEST_ASSERT_FALSE(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsFalse(X) +#define TEST_ASSERT(X) TEST_ASSERT_TRUE(X) +#define CODA_OSS_testMethod_(X) testMethod ## _ ## X +#define TEST_CASE(X) TEST_METHOD(X) { CODA_OSS_testMethod_(X)(#X); } void CODA_OSS_testMethod_(X)(std::string testName) + +namespace test +{ + struct Assert final + { + static void FailOnCondition(bool condition, const unsigned short* message, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo); + static std::wstring GetAssertMessage(bool equality, const std::string& expected, const std::string& actual, const wchar_t *message); + }; +#define CODA_OSS_equals_message_(expected, actual, message) reinterpret_cast(test::Assert::GetAssertMessage(true, test::toString(expected), test::toString(actual), message).c_str()) +#define CODA_OSS_not_equals_message_(notExpected, actual, message) reinterpret_cast(test::Assert::GetAssertMessage(false, test::toString(notExpected), test::toString(actual), message).c_str()) +#define CODA_OSS_message_(message) reinterpret_cast(test::Assert::GetAssertMessage(false, "", "", message).c_str()) + +// see Assert::AreEqual<> +template +inline void diePrintf_eq(const TExpected& expected, const TActual& actual, + const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) +{ + Assert::FailOnCondition(expected == actual, CODA_OSS_equals_message_(expected, actual, message), pLineInfo); +} + +// see Assert::AreNotEqual<> +template +inline void diePrintf_ne(const TExpected& notExpected, const TActual& actual, + const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) +{ + Assert::FailOnCondition(notExpected != actual, CODA_OSS_not_equals_message_(notExpected, actual, message), pLineInfo); +} + +template +inline void diePrintf_ge(const TX1& X1, const TX2& X2, + const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) +{ + Assert::FailOnCondition(X1 >= X2, CODA_OSS_message_(message), pLineInfo); +} +template +inline void diePrintf_gt(const TX1& X1, const TX2& X2, + const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) +{ + Assert::FailOnCondition(X1 > X2, CODA_OSS_message_(message), pLineInfo); +} +template +inline void diePrintf_le(const TX1& X1, const TX2& X2, + const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) +{ + Assert::FailOnCondition(X1 <= X2, CODA_OSS_message_(message), pLineInfo); +} +template +inline void diePrintf_lt(const TX1& X1, const TX2& X2, + const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) +{ + Assert::FailOnCondition(X1 < X2, CODA_OSS_message_(message), pLineInfo); +} + +} +#undef CODA_OSS_test_diePrintf_eq_ +#undef CODA_OSS_test_diePrintf_not_eq_ +#define CODA_OSS_test_diePrintf_eq_(X1, X2) testName, ::test::diePrintf_eq(X1, X2) +#define CODA_OSS_test_diePrintf_not_eq_(X1, X2) testName, ::test::diePrintf_ne(X1, X2) + +#undef CODA_OSS_test_diePrintf_greater_eq_ +#undef CODA_OSS_test_diePrintf_greater_ +#undef CODA_OSS_test_diePrintf_lesser_eq_ +#undef CODA_OSS_test_diePrintf_lesser_ +#define CODA_OSS_test_diePrintf_greater_eq_(X1, X2) testName, ::test::diePrintf_ge(X1, X2) +#define CODA_OSS_test_diePrintf_greater_(X1, X2) testName, ::test::diePrintf_gt(X1, X2) +#define CODA_OSS_test_diePrintf_lesser_eq_(X1, X2) testName, ::test::diePrintf_le(X1, X2) +#define CODA_OSS_test_diePrintf_lesser_(X1, X2) testName, ::test::diePrintf_lt(X1, X2) + +template +inline void test_assert_greater_(const TX1& X1, const TX2& X2) +{ + Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(X1 > X2); +} +#undef TEST_ASSERT_GREATER +#define TEST_ASSERT_GREATER(X1, X2) testName, test_assert_greater_(X1, X2) + +#undef TEST_ASSERT_ALMOST_EQ_EPS +#define TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS) { (void)testName; Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(X1, X2, EPS); Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(X2, X1, EPS); } +namespace test +{ +inline void assert_almost_eq(const std::string& testName, float X1, float X2) +{ + constexpr auto EPS = static_cast(0.0001); + TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS); +} +inline void assert_almost_eq(const std::string& testName, double X1, double X2) +{ + constexpr auto EPS = static_cast(0.0001); + TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS); +} +inline void assert_almost_eq(const std::string& testName, long double X1, long double X2) +{ + assert_almost_eq(testName, static_cast(X1), static_cast(X2)); +} +} + +#undef TEST_ASSERT_ALMOST_EQ +#define TEST_ASSERT_ALMOST_EQ(X1, X2) test::assert_almost_eq(testName, X1, X2) + +#undef TEST_ASSERT_EQ_MSG +#define TEST_ASSERT_EQ_MSG(msg, X1, X2) testName, Microsoft::VisualStudio::CppUnitTestFramework::Logger::WriteMessage(msg.c_str()); TEST_ASSERT_EQ(X1, X2) + +#undef TEST_FAIL_MSG +#define TEST_FAIL_MSG(msg) { (void)testName; Microsoft::VisualStudio::CppUnitTestFramework::Assert::Fail(str::EncodedStringView(msg).wstring().c_str()); } + +#undef TEST_EXCEPTION +#undef TEST_THROWS +#undef TEST_SPECIFIC_EXCEPTION +#define TEST_EXCEPTION(X) (void)testName; try{ (X); TEST_FAIL(#X " should have thrown."); } CODA_OSS_TEST_EXCEPTION_catch_ +#define TEST_THROWS(X) (void)testName; try{ (X); TEST_FAIL(#X " should have thrown."); } catch (...){ TEST_ASSERT_TRUE(true); } +#define TEST_SPECIFIC_EXCEPTION(X, Y) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::ExpectException([&](){(X);}) diff --git a/externals/coda-oss/modules/c++/math/tests/complexBenchmark.cpp b/externals/coda-oss/modules/c++/math/tests/complexBenchmark.cpp index 2de00abbcc..9484150c96 100644 --- a/externals/coda-oss/modules/c++/math/tests/complexBenchmark.cpp +++ b/externals/coda-oss/modules/c++/math/tests/complexBenchmark.cpp @@ -217,7 +217,7 @@ void loopingBenchmark(size_t size, std::vector > arr(size); //fill the vector based on a random number - srand(static_cast(time(NULL))); + srand(static_cast(time(nullptr))); auto real = static_cast(rand() % 100 + 1); auto imag = static_cast(rand() % 100 + 1); @@ -321,7 +321,7 @@ void singlePassBenchmark(size_t size, std::vector > arr; arr.reserve(endSize); - srand(static_cast(time(NULL))); + srand(static_cast(time(nullptr))); auto real = static_cast(rand() % 100 + 1); auto imag = static_cast(rand() % 100 + 1); diff --git a/externals/coda-oss/modules/c++/math/tests/complexMultiplyBenchmark.cpp b/externals/coda-oss/modules/c++/math/tests/complexMultiplyBenchmark.cpp index 3f7b19ac9c..12ea426199 100644 --- a/externals/coda-oss/modules/c++/math/tests/complexMultiplyBenchmark.cpp +++ b/externals/coda-oss/modules/c++/math/tests/complexMultiplyBenchmark.cpp @@ -199,7 +199,7 @@ void loopingBenchmark(size_t size, std::vector > arr(size); //fill the vector based on a random number - srand(static_cast(time(NULL))); + srand(static_cast(time(nullptr))); auto real = static_cast(rand() % 100 + 1); auto imag = static_cast(rand() % 100 + 1); @@ -297,7 +297,7 @@ void singlePassBenchmark(size_t size, std::vector > arr; arr.reserve(endSize); - srand(static_cast(time(NULL))); + srand(static_cast(time(nullptr))); auto real = static_cast(rand() % 100 + 1); auto imag = static_cast(rand() % 100 + 1); diff --git a/externals/coda-oss/modules/c++/mem/tests/ScratchVisualization.cpp b/externals/coda-oss/modules/c++/mem/tests/ScratchVisualization.cpp index 20974a659c..791964c72b 100644 --- a/externals/coda-oss/modules/c++/mem/tests/ScratchVisualization.cpp +++ b/externals/coda-oss/modules/c++/mem/tests/ScratchVisualization.cpp @@ -72,7 +72,7 @@ class Visualizer mHTMLFile(htmlFile), mCSSFile(cssFile) { - mStartPtr = NULL; + mStartPtr = nullptr; mColors.push_back("lightgrey"); mColors.push_back("lightblue"); mColors.push_back("lightcyan"); diff --git a/externals/coda-oss/modules/c++/mem/unittests/test_scratch_memory.cpp b/externals/coda-oss/modules/c++/mem/unittests/test_scratch_memory.cpp index 8ef51ee4fd..5186e8956c 100644 --- a/externals/coda-oss/modules/c++/mem/unittests/test_scratch_memory.cpp +++ b/externals/coda-oss/modules/c++/mem/unittests/test_scratch_memory.cpp @@ -617,7 +617,7 @@ TEST_CASE(testScratchMemory) TEST_EXCEPTION(scratch.setup(smallBuffer)); // calling setup with invalid external buffer should throw - mem::BufferView invalidBuffer(NULL, buffer.size); + mem::BufferView invalidBuffer(nullptr, buffer.size); TEST_EXCEPTION(scratch.setup(invalidBuffer)); } diff --git a/externals/coda-oss/modules/c++/mem/unittests/test_shared_ptr.cpp b/externals/coda-oss/modules/c++/mem/unittests/test_shared_ptr.cpp index 866df1eb7a..1441f47235 100644 --- a/externals/coda-oss/modules/c++/mem/unittests/test_shared_ptr.cpp +++ b/externals/coda-oss/modules/c++/mem/unittests/test_shared_ptr.cpp @@ -69,19 +69,19 @@ size_t cpp11Function(std::shared_ptr foo) TEST_CASE(testNullCopying) { mem::SharedPtr ptr1; - TEST_ASSERT_EQ(ptr1.get(), static_cast(NULL)); + TEST_ASSERT_EQ(ptr1.get(), static_cast(nullptr)); // Copy construction const mem::SharedPtr ptr2(ptr1); - TEST_ASSERT_EQ(ptr2.get(), static_cast(NULL)); + TEST_ASSERT_EQ(ptr2.get(), static_cast(nullptr)); // Assignment operator mem::SharedPtr ptr3; ptr3 = ptr1; - TEST_ASSERT_EQ(ptr3.get(), static_cast(NULL)); + TEST_ASSERT_EQ(ptr3.get(), static_cast(nullptr)); ptr1.reset(); - TEST_ASSERT_EQ(ptr1.get(), static_cast(NULL)); + TEST_ASSERT_EQ(ptr1.get(), static_cast(nullptr)); } TEST_CASE(testAutoPtrConstructor) @@ -90,7 +90,7 @@ TEST_CASE(testAutoPtrConstructor) std::unique_ptr autoPtr(rawPtr); const mem::SharedPtr ptr(autoPtr.release()); TEST_ASSERT_EQ(ptr.get(), rawPtr); - TEST_ASSERT_EQ(autoPtr.get(), static_cast(NULL)); + TEST_ASSERT_EQ(autoPtr.get(), static_cast(nullptr)); //TEST_ASSERT_EQ(ptr.getCount(), 1); TEST_ASSERT_EQ(ptr.use_count(), 1); TEST_ASSERT_EQ(getCount(ptr), 1); @@ -287,7 +287,7 @@ TEST_CASE(testCasting) std::unique_ptr autoBar(rawBar); const mem::SharedPtr fooPtr(autoBar.release()); TEST_ASSERT_EQ(fooPtr.get(), rawBar); - TEST_ASSERT_EQ(autoBar.get(), static_cast(NULL)); + TEST_ASSERT_EQ(autoBar.get(), static_cast(nullptr)); //TEST_ASSERT_EQ(fooPtr.getCount(), 1); TEST_ASSERT_EQ(fooPtr.use_count(), 1); TEST_ASSERT_EQ(getCount(fooPtr), 1); diff --git a/externals/coda-oss/modules/c++/mt/include/import/mt.h b/externals/coda-oss/modules/c++/mt/include/import/mt.h index 10caa17e6f..2a35e189ca 100644 --- a/externals/coda-oss/modules/c++/mt/include/import/mt.h +++ b/externals/coda-oss/modules/c++/mt/include/import/mt.h @@ -21,8 +21,14 @@ */ -#ifndef __IMPORT_MT_H__ -#define __IMPORT_MT_H__ +#pragma once +#ifndef CODA_OSS_mt_import_mt_h_h_INCLUDED_ +#define CODA_OSS_mt_import_mt_h_h_INCLUDED_ + +#if _MSC_VER +#pragma warning(push) +#pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to 'extern "C"' function under - EHc.Undefined behavior may occur if this function throws an exception. +#endif // _MSC_VER #include "mt/RequestQueue.h" #include "mt/ThreadPoolException.h" @@ -45,4 +51,8 @@ #include "mt/CPUAffinityThreadInitializer.h" #include "mt/Algorithm.h" -#endif +#if _MSC_VER +#pragma warning(pop) +#endif // _MSC_VER + +#endif // CODA_OSS_mt_import_mt_h_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/net.ssl/source/SSLConnection.cpp b/externals/coda-oss/modules/c++/net.ssl/source/SSLConnection.cpp index 75c7f5e031..903fa077dc 100644 --- a/externals/coda-oss/modules/c++/net.ssl/source/SSLConnection.cpp +++ b/externals/coda-oss/modules/c++/net.ssl/source/SSLConnection.cpp @@ -45,11 +45,11 @@ net::ssl::SSLConnection::SSLConnection(std::unique_ptr&& socket, net::ssl::SSLConnection::~SSLConnection() { - if(mSSL != NULL) + if(mSSL != nullptr) { SSL_shutdown(mSSL); } - if(mSSL != NULL) + if(mSSL != nullptr) { SSL_free(mSSL); } diff --git a/externals/coda-oss/modules/c++/net/tests/AckMulticastSender.cpp b/externals/coda-oss/modules/c++/net/tests/AckMulticastSender.cpp index a5c97008a0..e02d527524 100644 --- a/externals/coda-oss/modules/c++/net/tests/AckMulticastSender.cpp +++ b/externals/coda-oss/modules/c++/net/tests/AckMulticastSender.cpp @@ -143,8 +143,8 @@ template class AckMulticastSender //FD_SET(mAckChannel->getHandle(), &writers); assert(FD_ISSET(mAckChannel->getHandle(), &readers)); //int rv = 1; - int rv = ::select(mAckChannel->getHandle() + 1, &readers, NULL, - NULL, &tv); + int rv = ::select(mAckChannel->getHandle() + 1, &readers, nullptr, + nullptr, &tv); if (rv < 0) { throw sys::SocketException(Ctxt("Select failed")); diff --git a/externals/coda-oss/modules/c++/net/tests/NetConnectionServerTest.cpp b/externals/coda-oss/modules/c++/net/tests/NetConnectionServerTest.cpp index bcbb46ac10..ed72a907ba 100644 --- a/externals/coda-oss/modules/c++/net/tests/NetConnectionServerTest.cpp +++ b/externals/coda-oss/modules/c++/net/tests/NetConnectionServerTest.cpp @@ -76,7 +76,7 @@ int main(int argc, char **argv) if (argc < 2) throw Exception(FmtX("Usage: %s (-mt|-st|-tp)", argv[0])); - net::AllocStrategy* strategy = NULL; + net::AllocStrategy* strategy = nullptr; if (argc == 3) { diff --git a/externals/coda-oss/modules/c++/net/tests/TCPClientTest.cpp b/externals/coda-oss/modules/c++/net/tests/TCPClientTest.cpp index 47a9c10a0c..0ca69b2761 100644 --- a/externals/coda-oss/modules/c++/net/tests/TCPClientTest.cpp +++ b/externals/coda-oss/modules/c++/net/tests/TCPClientTest.cpp @@ -60,7 +60,7 @@ int main(int argc, char** argv) std::unique_ptr socket = TCPClientSocketFactory().create(sa); my_packet_t packet; packet.packet_no = 1; - packet.time_stamp = time(NULL); + packet.time_stamp = time(nullptr); socket->send(&packet, sizeof(my_packet_t)); int rv; socket->recv(&rv, sizeof(int)); diff --git a/externals/coda-oss/modules/c++/net/tests/UDPClientTest.cpp b/externals/coda-oss/modules/c++/net/tests/UDPClientTest.cpp index 76fed33726..ae2e28ba23 100644 --- a/externals/coda-oss/modules/c++/net/tests/UDPClientTest.cpp +++ b/externals/coda-oss/modules/c++/net/tests/UDPClientTest.cpp @@ -66,7 +66,7 @@ int main(int argc, char** argv) std::unique_ptr socket = UDPClientSocketFactory().create(sa); my_packet_t packet; packet.packet_no = 1; - packet.time_stamp = time(NULL); + packet.time_stamp = time(nullptr); socket->send((const char*)&packet, sizeof(my_packet_t)); int rv; socket->recv((char*)&rv, sizeof(int)); diff --git a/externals/coda-oss/modules/c++/numpyutils/include/numpyutils/numpyutils.h b/externals/coda-oss/modules/c++/numpyutils/include/numpyutils/numpyutils.h index fec9e9e64a..4632913dd5 100644 --- a/externals/coda-oss/modules/c++/numpyutils/include/numpyutils/numpyutils.h +++ b/externals/coda-oss/modules/c++/numpyutils/include/numpyutils/numpyutils.h @@ -20,14 +20,40 @@ * */ +#pragma once #ifndef __NUMPYUTILS_NUMPYUTILS_H__ #define __NUMPYUTILS_NUMPYUTILS_H__ #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include -#include CODA_OSS_disable_warning_system_header_push +#if _MSC_VER +#pragma warning(disable: 26493) // Don't use C-style casts (type.4). +#pragma warning(disable: 26494) // Variable '...' is uninitialized. Always initialize an object (type.5). +#pragma warning(disable: 26451) // Arithmetic overflow: Using operator '...' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '...' to avoid overflow (io.2). +#pragma warning(disable: 26814) // The const variable '...' can be computed at compile-time. Consider using constexpr (con.5). +#pragma warning(disable: 26447) // The function is declared '...' but calls function '...' which may throw exceptions (f.6). +#pragma warning(disable: 26455) // Default constructor should not throw. Declare it '...' (f.6). +#pragma warning(disable: 26440) // Function '...' can be declared '...' (f.6). +#pragma warning(disable: 26496) // The variable '...' does not change after construction, mark it as const (con.4). +#pragma warning(disable: 26462) // The value pointed to by '...' is assigned only once, mark it as a pointer to const (con.4). +#pragma warning(disable: 26435) // Function '...' should specify exactly one of '...', '...', or '...' (c.128). +#pragma warning(disable: 26433) // Function '...' should be marked with '...' (c.128). +#pragma warning(disable: 26497) // You can attempt to make '...' constexpr unless it contains any undefined behavior (f.4). +#pragma warning(disable: 26433) // Function '...' should be marked with '...' (c.128). +#pragma warning(disable: 26456) // Operator '...' hides a non-virtual operator '...' (c.128). +#pragma warning(disable: 26446) // Prefer to use gsl::at() instead of unchecked subscript operator (bounds.4). +#pragma warning(disable: 26477) // Use '...' rather than 0 or NULL(es .47). +#pragma warning(disable: 26457) // (void) should not be used to ignore return values, use '...' instead (es.48). +#pragma warning(disable: 26813) // Use '...' to check if a flag is set. +#else +CODA_OSS_disable_warning(-Wshadow) +CODA_OSS_disable_warning(-Wsuggest-override) +CODA_OSS_disable_warning(-Wzero-as-null-pointer-constant) +#endif + +#include #include CODA_OSS_disable_warning_pop diff --git a/externals/coda-oss/modules/c++/numpyutils/source/numpyutils.cpp b/externals/coda-oss/modules/c++/numpyutils/source/numpyutils.cpp index 53b8b97b17..31a2452c22 100644 --- a/externals/coda-oss/modules/c++/numpyutils/source/numpyutils.cpp +++ b/externals/coda-oss/modules/c++/numpyutils/source/numpyutils.cpp @@ -25,6 +25,9 @@ #ifndef _MSC_VER CODA_OSS_disable_warning(-Wold-style-cast) +CODA_OSS_disable_warning(-Wshadow) +CODA_OSS_disable_warning(-Wsuggest-override) +CODA_OSS_disable_warning(-Wzero-as-null-pointer-constant) #endif #include #include @@ -36,18 +39,12 @@ CODA_OSS_disable_warning(-Wold-style-cast) * https://mail.scipy.org/pipermail/numpy-discussion/2010-December/054350.html * for the source and some discussion */ -#if PY_MAJOR_VERSION >= 3 +static_assert(PY_MAJOR_VERSION >= 3, "Python 3.x required"); void* init_numpy() { import_array(); return nullptr; } -#else -void init_numpy() -{ - import_array(); -} -#endif /* Numpy uses some static variables which are per-compilation * unit and if import_arrays is not called, will segfault on using any of diff --git a/externals/coda-oss/modules/c++/pch.h b/externals/coda-oss/modules/c++/pch.h index f39484bc24..18067f14df 100644 --- a/externals/coda-oss/modules/c++/pch.h +++ b/externals/coda-oss/modules/c++/pch.h @@ -33,32 +33,29 @@ CODA_OSS_disable_warning_pop #include #include +#pragma comment(lib, "z.lib") +#pragma comment(lib, "minizip.lib") + #include #pragma warning(disable: 4251) // '...': class '...' needs to have dll-interface to be used by clients of class '...' #pragma warning(disable: 4365) // '...': conversion from '...' to '...', signed/unsigned mismatch #pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to '...' function under -EHc. Undefined behavior may occur if this function throws an exception. -#pragma warning(disable: 6326) // Potential comparison of a constant with another constant. #pragma warning(disable: 6054) // String '...' might not be zero-terminated. #pragma warning(disable: 6387) // '...' could be '...'. #pragma warning(disable: 6305) // Potential mismatch between sizeof and countof quantities. Use sizeof() to scale byte sizes. -#pragma warning(disable: 6288) // Incorrect operator. Did you intend to use || instead? -#pragma warning(disable: 6011) // Dereferencing NULL pointer '...'. -#pragma warning(disable: 6313) // Incorrect operator. Use an equality test to check for zero-valued flags. #pragma warning(disable: 6389) // Move '...' to anonymous namespace or put a forward declaration in a common header included in this file. +#pragma warning(disable: 26822) // Dereferencing a null pointer '...' (lifetime.1). #pragma warning(disable: 26432) // If you define or delete any default operation in the type '...', define or delete them all (c.21). #pragma warning(disable: 26429) // Symbol '...' is never tested for nullness, it can be marked as not_null (f.23). #pragma warning(disable: 26455) // Default constructor should not throw. Declare it '...' (f.6). #pragma warning(disable: 26440) // Function '...' can be declared '...' (f.6). #pragma warning(disable: 26447) // The function is declared '...' but calls function '...' which may throw exceptions (f.6). -#pragma warning(disable: 26446) // Prefer to use gsl::at() instead of unchecked subscript operator (bounds.4). -#pragma warning(disable: 26481) // Don't use pointer arithmetic. Use span instead (bounds.1). #pragma warning(disable: 26496) // The variable '...' does not change after construction, mark it as const (con.4). #pragma warning(disable: 26462) // The value pointed to by '...' is assigned only once, mark it as a pointer to const (con.4). #pragma warning(disable: 26409) // Avoid calling new and delete explicitly, use std::make_unique instead (r.11). #pragma warning(disable: 26401) // Do not delete a raw pointer that is not an owner (i.11). -#pragma warning(disable: 26482) // Only index into arrays using constant expressions (bounds.2). #pragma warning(disable: 26472) // Don't use a static_cast for arithmetic conversions. Use brace initialization, gsl::narrow_cast or gsl::narrow (type.1). #pragma warning(disable: 26485) // Expression '...': No array to pointer decay (bounds.3). #pragma warning(disable: 26493) // Don't use C-style casts (type.4). @@ -96,8 +93,10 @@ CODA_OSS_disable_warning_pop #pragma warning(disable: 26823) // Dereferencing a possibly null pointer '...' (lifetime.1). #pragma warning(disable: 26487) // Don't return a pointer '...' that may be invalid (lifetime.4). #pragma warning(disable: 26812) // The enum type '...' is unscoped. Prefer '...' over '...' (Enum.3). -#pragma warning(disable: 26822) // Dereferencing a null pointer '...' (lifetime.1). +#pragma warning(disable: 26446) // Prefer to use gsl::at() instead of unchecked subscript operator (bounds.4). #pragma warning(disable: 26458) // Prefer to use gsl::at() instead of unchecked subscript operator (bounds.4). +#pragma warning(disable: 26482) // Only index into arrays using constant expressions (bounds.2). +#pragma warning(disable: 26481) // Don't use pointer arithmetic. Use span instead (bounds.1). // Yes, these are our files ... but they don't change very often, and if they do // change we want to rebuild everything anyway. @@ -107,7 +106,11 @@ CODA_OSS_disable_warning_pop #include "sys/Conf.h" #include "sys/filesystem.h" #include "mem/SharedPtr.h" + #include "xml/lite/xerces_.h" +#pragma comment(lib, "xerces-c") + #include "hdf5/lite/H5_.h" +#pragma comment(lib, "hdf5-c++.lib") #endif //CODA_OSS_pch_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/re/include/re/Regex.h b/externals/coda-oss/modules/c++/re/include/re/Regex.h index d7dd55dd21..e4338972a8 100644 --- a/externals/coda-oss/modules/c++/re/include/re/Regex.h +++ b/externals/coda-oss/modules/c++/re/include/re/Regex.h @@ -214,7 +214,7 @@ class CODA_OSS_API Regex size_t& end); //! The pcre object - pcre2_code* mPCRE; + pcre2_code* mPCRE = nullptr; #endif }; } diff --git a/externals/coda-oss/modules/c++/re/source/RegexPCRE.cpp b/externals/coda-oss/modules/c++/re/source/RegexPCRE.cpp index 479d1fac72..d70885e3e8 100644 --- a/externals/coda-oss/modules/c++/re/source/RegexPCRE.cpp +++ b/externals/coda-oss/modules/c++/re/source/RegexPCRE.cpp @@ -55,9 +55,9 @@ class ScopedMatchData // to do. ScopedMatchData(const pcre2_code* code) : mCode(code), - mMatchData(pcre2_match_data_create_from_pattern(code, NULL)) + mMatchData(pcre2_match_data_create_from_pattern(code, nullptr)) { - if (mMatchData == NULL) + if (mMatchData == nullptr) { throw re::RegexException(Ctxt( "pcre2_match_data_create_from_pattern() failed to " @@ -95,7 +95,7 @@ class ScopedMatchData startOffset, options, mMatchData, - NULL); // Match context + nullptr); // Match context if (returnCode == PCRE2_ERROR_NOMATCH) { @@ -156,7 +156,7 @@ class ScopedMatchData namespace re { Regex::Regex(const std::string& pattern) : - mPattern(pattern), mPCRE(NULL) + mPattern(pattern), mPCRE(nullptr) { if (!mPattern.empty()) { @@ -166,10 +166,10 @@ Regex::Regex(const std::string& pattern) : void Regex::destroy() { - if (mPCRE != NULL) + if (mPCRE != nullptr) { pcre2_code_free(mPCRE); - mPCRE = NULL; + mPCRE = nullptr; } } @@ -179,7 +179,7 @@ Regex::~Regex() } Regex::Regex(const Regex& rhs) : - mPattern(rhs.mPattern), mPCRE(NULL) + mPattern(rhs.mPattern), mPCRE(nullptr) { compile(mPattern); } @@ -218,9 +218,9 @@ Regex& Regex::compile(const std::string& pattern) FLAGS, &errorCode, &errorOffset, - NULL); // Use default compile context + nullptr); // Use default compile context - if (mPCRE == NULL) + if (mPCRE == nullptr) { std::ostringstream ostr; ostr << "PCRE compilation failed at offset " << errorOffset diff --git a/externals/coda-oss/modules/c++/str/source/EncodedStringView.cpp b/externals/coda-oss/modules/c++/str/source/EncodedStringView.cpp index 385293601e..6bd00eef4d 100644 --- a/externals/coda-oss/modules/c++/str/source/EncodedStringView.cpp +++ b/externals/coda-oss/modules/c++/str/source/EncodedStringView.cpp @@ -85,26 +85,29 @@ static std::string to_native(str::W1252string::const_pointer p, size_t sz) throw std::logic_error("Unknown platform."); } -template -inline coda_oss::span make_span(const CharT* s, size_t c) +template +inline auto make_span(const Char8T* s, size_t c) { - return coda_oss::span(s, c); + static_assert(sizeof(Char8T) == sizeof(char), "sizeof(Char8T) != sizeof(char)"); + return coda_oss::span(s, c); } -template -inline coda_oss::span make_span(const CharT* s) +template +inline auto make_span(const Char8T* s) { - auto s_ = str::cast(s); + auto const s_ = str::cast(s); return make_span(s, strlen(s_)); } -template -inline coda_oss::span make_span(const std::basic_string& s) +template +inline auto make_span(const std::basic_string& s) { - return make_span(s.c_str(), s.size()); + assert(strlen(str::c_str(s)) == s.length()); + return make_span(s.c_str(), s.length()); } -template -inline coda_oss::span make_span(coda_oss::span s) +template +inline auto make_span(coda_oss::span s) { - auto s_ = str::cast(s.data()); + auto const s_ = str::cast(s.data()); + assert(strlen(s_) == s.size()); return coda_oss::span(s_, s.size()); } diff --git a/externals/coda-oss/modules/c++/sys/include/sys/OS.h b/externals/coda-oss/modules/c++/sys/include/sys/OS.h index 6ea40c83fb..7a16c53e58 100644 --- a/externals/coda-oss/modules/c++/sys/include/sys/OS.h +++ b/externals/coda-oss/modules/c++/sys/include/sys/OS.h @@ -21,10 +21,12 @@ */ -#ifndef __SYS_OS_H__ -#define __SYS_OS_H__ +#pragma once +#ifndef CODA_OSS_sys_OS_h_INCLUDED_ +#define CODA_OSS_sys_OS_h_INCLUDED_ #include "sys/AbstractOS.h" +#include "sys/Conf.h" #ifdef _WIN32 # include "sys/OSWin32.h" @@ -47,19 +49,34 @@ typedef DirectoryUnix Directory; // and also squelches compiler-warnings about unused local functions. namespace sys { - enum class PlatformType - { - Windows, - Linux, - //MacOS - }; +enum class PlatformType +{ + Windows, + Linux, + // MacOS +}; - #ifdef _WIN32 - constexpr auto Platform = PlatformType::Windows; - #else - constexpr auto Platform = PlatformType::Linux; - #endif +#if defined(_WIN32) +constexpr auto Platform = PlatformType::Windows; +#elif defined(CODA_OSS_POSIX2008_SOURCE) +constexpr auto Platform = PlatformType::Linux; +#else +#error "Unknown platform." +#endif + +template +inline std::string platformName(); +template <> +inline std::string platformName() +{ + return "Windows"; +} +template <> +inline std::string platformName() +{ + return "linux-gnu"; } -#endif +} +#endif // CODA_OSS_sys_OS_h_INCLUDED_ \ No newline at end of file diff --git a/externals/coda-oss/modules/c++/sys/source/AbstractOS.cpp b/externals/coda-oss/modules/c++/sys/source/AbstractOS.cpp index e32b44d879..d1cd33306f 100644 --- a/externals/coda-oss/modules/c++/sys/source/AbstractOS.cpp +++ b/externals/coda-oss/modules/c++/sys/source/AbstractOS.cpp @@ -480,14 +480,7 @@ std::string AbstractOS::getSpecialEnv(const std::string& envVar) const if (envVar == "OSTYPE") { - // TODO: Mac - return sys::Platform == sys::PlatformType::Linux ? " linux-gnu" : "Windows"; - } - - if (envVar == "OSTYPE") - { - // TODO: Mac - return sys::Platform == sys::PlatformType::Linux ? " linux-gnu" : "Windows"; + return sys::platformName(); } // should explicitly handle all env. vars in some way diff --git a/externals/coda-oss/modules/c++/sys/source/ConditionVarPosix.cpp b/externals/coda-oss/modules/c++/sys/source/ConditionVarPosix.cpp index 505a17634b..d1e2886293 100644 --- a/externals/coda-oss/modules/c++/sys/source/ConditionVarPosix.cpp +++ b/externals/coda-oss/modules/c++/sys/source/ConditionVarPosix.cpp @@ -32,7 +32,7 @@ sys::ConditionVarPosix::ConditionVarPosix() : mMutexOwned(std::make_unique()), mMutex(mMutexOwned.get()) { - if ( ::pthread_cond_init(&mNative, NULL) != 0) + if ( ::pthread_cond_init(&mNative, nullptr) != 0) throw SystemException("ConditionVar initialization failed"); } @@ -41,7 +41,7 @@ sys::ConditionVarPosix::ConditionVarPosix(MutexPosix* theLock, bool isOwner, std if (isOwner) mMutexOwned.reset(theLock); - if (::pthread_cond_init(&mNative, NULL) != 0) + if (::pthread_cond_init(&mNative, nullptr) != 0) throw SystemException("ConditionVar initialization failed"); } sys::ConditionVarPosix::ConditionVarPosix(sys::MutexPosix* theLock, bool isOwner) : ConditionVarPosix(theLock, isOwner, nullptr) @@ -87,7 +87,7 @@ void sys::ConditionVarPosix::wait(double seconds) if ( seconds > 0 ) { timespec tout; - tout.tv_sec = time(NULL) + gsl::narrow_cast(seconds); + tout.tv_sec = time(nullptr) + gsl::narrow_cast(seconds); tout.tv_nsec = gsl::narrow_cast((seconds - gsl::narrow_cast(seconds)) * 1e9); if (::pthread_cond_timedwait(&mNative, &(mMutex->getNative()), diff --git a/externals/coda-oss/modules/c++/sys/source/CppUnitTestAssert_.cpp_ b/externals/coda-oss/modules/c++/sys/source/CppUnitTestAssert_.cpp_ new file mode 100644 index 0000000000..fdcf5f92b5 --- /dev/null +++ b/externals/coda-oss/modules/c++/sys/source/CppUnitTestAssert_.cpp_ @@ -0,0 +1,43 @@ +#include "pch.h" +#include "TestCase.h" + +#include "str/EncodedStringView.h" + +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + +// EQUALS_MESSAGE() wants ToString() specializations (or overloads) for our types, which is a nusiance. +// This hooks up our existing str::toString() into the VC++ unit-test infrastructure + +// C++ hack to call private methods +// https://stackoverflow.com/a/71578383/8877 + +using FailOnCondition_t = void(bool condition, const unsigned short* message, const __LineInfo* pLineInfo); // declare method's type +using GetAssertMessage_t = std::wstring(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message); // declare method's type +template +struct caller final // helper structure to inject call() code +{ + friend void FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo) + { + fFailOnCondition(condition, message, pLineInfo); + } + + friend std::wstring GetAssertMessage(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message) + { + return fGetAssertMessage(equality, expected, actual, message); + } +}; +template struct caller<&Assert::FailOnCondition, &Assert::GetAssertMessage>; // even instantiation of the helper + +void FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo); // declare caller +void test::Assert::FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo) +{ + ::FailOnCondition(condition, message, pLineInfo); // and call! +} + +std::wstring GetAssertMessage(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message); // declare caller +std::wstring test::Assert::GetAssertMessage(bool equality, const std::string& expected, const std::string& actual, const wchar_t *message) +{ + const str::EncodedStringView vExpected(expected); + const str::EncodedStringView vActual(actual); + return ::GetAssertMessage(equality, vExpected.wstring(), vActual.wstring(), message); // and call! +} diff --git a/externals/coda-oss/modules/c++/sys/source/DLLUnix.cpp b/externals/coda-oss/modules/c++/sys/source/DLLUnix.cpp index f43457e69a..6ef817453a 100644 --- a/externals/coda-oss/modules/c++/sys/source/DLLUnix.cpp +++ b/externals/coda-oss/modules/c++/sys/source/DLLUnix.cpp @@ -66,7 +66,7 @@ DLL_FUNCTION_PTR sys::DLL::retrieve(const std::string& functionName) { // Check to make sure we have a library - if ( mLib != NULL ) + if ( mLib != nullptr ) { // Now we get a ptr DLL_FUNCTION_PTR ptr = dlsym( mLib , functionName.c_str()); diff --git a/externals/coda-oss/modules/c++/sys/source/DateTime.cpp b/externals/coda-oss/modules/c++/sys/source/DateTime.cpp index e0f411d5bc..a79b9bb8c0 100644 --- a/externals/coda-oss/modules/c++/sys/source/DateTime.cpp +++ b/externals/coda-oss/modules/c++/sys/source/DateTime.cpp @@ -394,7 +394,7 @@ static double getNowInMillis() return (now.tv_sec + 1.0e-9 * now.tv_nsec) * 1000; #elif CODA_OSS_POSIX_SOURCE struct timeval now; - gettimeofday(&now,NULL); + gettimeofday(&now,nullptr); return (now.tv_sec + 1.0e-6 * now.tv_usec) * 1000; #elif _WIN32 // Getting time twice may be inefficient but is quicker diff --git a/externals/coda-oss/modules/c++/sys/source/ExecUnix.cpp b/externals/coda-oss/modules/c++/sys/source/ExecUnix.cpp index 24ea231038..a31bd60232 100644 --- a/externals/coda-oss/modules/c++/sys/source/ExecUnix.cpp +++ b/externals/coda-oss/modules/c++/sys/source/ExecUnix.cpp @@ -104,7 +104,7 @@ FILE* ExecPipe::openPipe(const std::string& command, // command the user specified execl("/bin/sh", "sh", "-c", command.c_str(), - static_cast(NULL)); + static_cast(nullptr)); //! exit the subprocess once it has completed exit(127); diff --git a/externals/coda-oss/modules/c++/sys/source/FileFinder.cpp b/externals/coda-oss/modules/c++/sys/source/FileFinder.cpp index 6b47dda795..b33cc47c48 100644 --- a/externals/coda-oss/modules/c++/sys/source/FileFinder.cpp +++ b/externals/coda-oss/modules/c++/sys/source/FileFinder.cpp @@ -208,6 +208,17 @@ std::vector sys::FileFinder::search( return files; } +static fs::path parent_path(const fs::path& p) +{ + // If the parent_path() is the same, we've reached to root. + const auto retval = p.parent_path(); + if (retval.empty() || (retval == p)) + { + throw std::runtime_error("At root of filesystem: " + p.string()); + } + return retval; +} + static fs::path findFirst(const sys::FilePredicate& pred, const fs::path& startingDirectory) { auto dir = startingDirectory; @@ -228,7 +239,8 @@ static fs::path findFirst(const sys::FilePredicate& pred, const fs::path& starti { throw std::logic_error("Won't traverse above .git directory at: " + dir.string()); } - dir = dir.parent_path(); + + dir = parent_path(dir); } } fs::path sys::findFirstFile(const fs::path& startingDirectory, const fs::path& filename) @@ -297,7 +309,7 @@ fs::path sys::test::findRootDirectory(const fs::path& p, const std::string& root // Once we're at a .git directory, we have to go down, not up ... or fail. if (!is_directory(p / ".git")) { - return findRootDirectory(p.parent_path(), rootName, isRoot); + return findRootDirectory(parent_path(p), rootName, isRoot); } // TODO: since we're in the "FileFinder" module, maybe try a bit harder to find "rootName"? @@ -316,7 +328,7 @@ static inline std::string Platform() static fs::path findCMakeRoot(const fs::path& path, const fs::path& dir) { - static const auto platform_and_configuration = ::Platform() + "-" + ::Configuration(); // "x64-Debug" + static const auto platform_and_configuration = ::Platform() + "-" + ::Configuration(); // "x64-Debug" const auto pred = [&](const fs::path& p) { if (p.filename() == platform_and_configuration) @@ -338,7 +350,7 @@ static fs::path findCMakeRoot(const fs::path& path, const fs::path& dir) return false; }; - return sys::test::findRootDirectory(path, "", pred); + return sys::test::findRootDirectory(path, "", pred); } fs::path findCMake_Root(const fs::path& path, @@ -404,13 +416,8 @@ static fs::path find_dotGITDirectory_(const fs::path& p, const fs::path& initial { return p; } - - auto parent = p.parent_path(); - if (parent.empty()) - { - throw std::invalid_argument("Can't find .git/ anywhere in: " + initial.string()); - } - return find_dotGITDirectory_(parent, initial); + + return find_dotGITDirectory_(parent_path(p), initial); } fs::path sys::test::find_dotGITDirectory(const fs::path& p) { diff --git a/externals/coda-oss/modules/c++/sys/source/MutexPosix.cpp b/externals/coda-oss/modules/c++/sys/source/MutexPosix.cpp index f28ce93be2..d284184448 100644 --- a/externals/coda-oss/modules/c++/sys/source/MutexPosix.cpp +++ b/externals/coda-oss/modules/c++/sys/source/MutexPosix.cpp @@ -28,7 +28,7 @@ sys::MutexPosix::MutexPosix() { - if (::pthread_mutex_init(&mNative, NULL) != 0) + if (::pthread_mutex_init(&mNative, nullptr) != 0) throw sys::SystemException("Mutex initialization failed"); } diff --git a/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp b/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp index e2b96cf18c..c9241b639f 100644 --- a/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp +++ b/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp @@ -308,7 +308,7 @@ std::string sys::OSUnix::getEnv(const std::string& s) const bool sys::OSUnix::isEnvSet(const std::string& s) const { const char* envVal = getenv(s.c_str()); - return (envVal != NULL); + return envVal != nullptr; } void sys::OSUnix::setEnv(const std::string& var, diff --git a/externals/coda-oss/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp b/externals/coda-oss/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp index 2b7fbc8445..e409b3b03f 100644 --- a/externals/coda-oss/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp +++ b/externals/coda-oss/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp @@ -64,7 +64,7 @@ void ScopedCPUMaskUnix::initialize(int numCPUs) ScopedCPUMaskUnix::~ScopedCPUMaskUnix() { - if (mMask != NULL) + if (mMask != nullptr) { CPU_FREE(mMask); } diff --git a/externals/coda-oss/modules/c++/sys/source/ThreadPosix.cpp b/externals/coda-oss/modules/c++/sys/source/ThreadPosix.cpp index 4ee1f24112..c399b5c83d 100644 --- a/externals/coda-oss/modules/c++/sys/source/ThreadPosix.cpp +++ b/externals/coda-oss/modules/c++/sys/source/ThreadPosix.cpp @@ -80,7 +80,7 @@ void *sys::ThreadPosix::__start(void *v) delete runnable; */ - pthread_exit(NULL); + pthread_exit(nullptr); return nullptr; } @@ -94,7 +94,7 @@ void sys::ThreadPosix::kill() } void sys::ThreadPosix::join() { - if (::pthread_join(mNative, NULL) != 0) + if (::pthread_join(mNative, nullptr) != 0) throw sys::SystemException("pthread_join()"); } void sys::ThreadPosix::yield() diff --git a/externals/coda-oss/modules/c++/sys/tests/DateTimeTest.cpp b/externals/coda-oss/modules/c++/sys/tests/DateTimeTest.cpp index f47fc33870..b2c5597f0f 100644 --- a/externals/coda-oss/modules/c++/sys/tests/DateTimeTest.cpp +++ b/externals/coda-oss/modules/c++/sys/tests/DateTimeTest.cpp @@ -54,7 +54,7 @@ int main(int, char**) sys::CPUStopWatch csw; //std::cout << "CPS: " << CLOCKS_PER_SEC << std::endl; std::cout << "clock(): " << clock() / CLOCKS_PER_SEC << std::endl; - std::cout << "time(): " << time(NULL) << std::endl; + std::cout << "time(): " << time(nullptr) << std::endl; std::cout << "RTStart: " << sw.start() << std::endl; std::cout << "CStart: " << csw.start() << std::endl; int x = 0; @@ -82,7 +82,7 @@ int main(int, char**) } std::cout << "Finish Loop 3" << std::endl; std::cout << "clock(): " << clock() / CLOCKS_PER_SEC << std::endl; - std::cout << "time(): " << time(NULL) << std::endl; + std::cout << "time(): " << time(nullptr) << std::endl; std::cout << "RTStop: " << std::setprecision(50) << sw.stop() << std::endl; std::cout << "CStop: " << std::setprecision(50) << csw.stop() diff --git a/externals/coda-oss/modules/c++/sys/tests/OSTest.cpp b/externals/coda-oss/modules/c++/sys/tests/OSTest.cpp index f8ee1ea5a0..330493eb76 100644 --- a/externals/coda-oss/modules/c++/sys/tests/OSTest.cpp +++ b/externals/coda-oss/modules/c++/sys/tests/OSTest.cpp @@ -110,7 +110,7 @@ int main(int argc, char **argv) } os.remove("TEST_DIRECTORY"); - std::cout << "Time Now: " << time(NULL) << std::endl; + std::cout << "Time Now: " << time(nullptr) << std::endl; sys::RealTimeStopWatch sw; //std::cout << "CPS: " << CLOCKS_PER_SEC << std::endl; // std::cout << "Clock: " << clock() << std::endl; @@ -137,7 +137,7 @@ int main(int argc, char **argv) std::cout << "Finish Loop 3" << std::endl; std::cout << "Stop: " << std::setprecision(50) << sw.stop() << std::endl; - std::cout << "Time Now: " << time(NULL) << std::endl; + std::cout << "Time Now: " << time(nullptr) << std::endl; // std::cout << "Clock: " << clock() << std::endl; } diff --git a/externals/coda-oss/modules/c++/tiff/source/IFDEntry.cpp b/externals/coda-oss/modules/c++/tiff/source/IFDEntry.cpp index 1ac612aeac..d9f5447dd8 100644 --- a/externals/coda-oss/modules/c++/tiff/source/IFDEntry.cpp +++ b/externals/coda-oss/modules/c++/tiff/source/IFDEntry.cpp @@ -120,8 +120,7 @@ void tiff::IFDEntry::deserialize(io::InputStream& input, const bool reverseBytes { auto elementSize = tiff::Const::sizeOf(mType); sys::Uint32_T numElements = mCount; - if (mType == tiff::Const::Type::RATIONAL && mType - == tiff::Const::Type::SRATIONAL) + if ((mType == tiff::Const::Type::RATIONAL) || (mType == tiff::Const::Type::SRATIONAL)) { elementSize = tiff::Const::sizeOf(mType) / 2; numElements = mCount * 2; diff --git a/externals/coda-oss/modules/c++/types/include/types/Complex.h b/externals/coda-oss/modules/c++/types/include/types/Complex.h index 46daa0f853..8b2218ff4b 100644 --- a/externals/coda-oss/modules/c++/types/include/types/Complex.h +++ b/externals/coda-oss/modules/c++/types/include/types/Complex.h @@ -221,9 +221,9 @@ static_assert(sizeof(std::complex) == sizeof(Complex), "sizeof(siz static_assert(std::is_same, ComplexReal>::value, "should be std::complex"); // Convenient aliases -using zfloat = ComplexReal; // std::complex -using zdouble = ComplexReal; // std::complex -//using zlong_double = ComplexReal; // std::complex +using zfloat = ComplexReal; // i.e., std::complex +using zdouble = ComplexReal; // i.e., std::complex +//using zlong_double = ComplexReal; // i.e., std::complex using zint8_t = ComplexInteger; // Complex using zint16_t = ComplexInteger; // Complex using zint32_t = ComplexInteger; // Complex diff --git a/externals/coda-oss/modules/c++/xml.lite/include/import/xml/lite.h b/externals/coda-oss/modules/c++/xml.lite/include/import/xml/lite.h index 477e27c800..b7b66bca81 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/import/xml/lite.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/import/xml/lite.h @@ -20,39 +20,9 @@ * */ +#pragma once #ifndef CODA_OSS_xml_lite_import_lite_h_INCLUDED_ #define CODA_OSS_xml_lite_import_lite_h_INCLUDED_ -#pragma once - -#if _MSC_VER -#pragma warning(push) -// these are from Xerces -#pragma warning(disable: 5219) // implicit conversion from '...' to '...', possible loss of data -#pragma warning(disable: 4365) // '...': conversion from '...' to '...', signed / unsigned mismatch -#pragma warning(disable: 26477) // Use 'nullptr' rather than 0 or NULL (es.47). -#pragma warning(disable: 26493) // Don't use C-style casts (type.4). -#pragma warning(disable: 26814) // The const variable '...' can be computed at compile-time. Consider using constexpr (con.5). -#pragma warning(disable: 26496) // The variable '...' does not change after construction, mark it as const (con.4). -#pragma warning(disable: 26497) // The function '...' could be marked constexpr if compile-time evaluation is desired (f.4). -#pragma warning(disable: 26475) // Do not use function style casts (es.49). Prefer '...' over '...'. -#pragma warning(disable: 26495) // Variable '...' is uninitialized. Always initialize a member variable (type.6). -#pragma warning(disable: 26461) // The pointer argument '...' for function '...' can be marked as a pointer to const (con.3). -#pragma warning(disable: 26462) // The value pointed to by '...' is assigned only once, mark it as a pointer to const (con.4). -#pragma warning(disable: 26494) // Variable '...' is uninitialized. Always initialize an object (type.5). -#pragma warning(disable: 26489) // Don't dereference a pointer that may be invalid: '...'. '...' may have been invalidated at line ... (lifetime.1). -#pragma warning(disable: 26488) // Do not dereference a potentially null pointer : ...'. '...' was null at line ... (lifetime.1). -#pragma warning(disable: 26447) // The function is declared '...' but calls function '..' which may throw exceptions (f.6). -#pragma warning(disable: 26485) // Expression '...': No array to pointer decay (bounds.3). -#pragma warning(disable: 26457) // (void) should not be used to ignore return values, use '...' instead (es.48). -#pragma warning(disable: 26487) // Don't return a pointer '...' that may be invalid (lifetime.4). -#pragma warning(disable: 26451) // Arithmetic overflow : Using operator '...' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '...' to avoid overflow (io.2). -#pragma warning(disable: 26455) // Default constructor may not throw.Declare it 'noexcept' (f.6). -#pragma warning(disable: 26409) // Avoid calling new and delete explicitly, use std::make_unique instead (r.11). -#pragma warning(disable: 26429) // Symbol '...' is never tested for nullness, it can be marked as not_null(f.23). -#pragma warning(disable: 26400) // Do not assign the result of an allocation or a function call with an owner return value to a raw pointer, use owner instead(i.11). -#pragma warning(disable: 26467) // Converting from floating point to unsigned integral types results in non-portable code if the double/float has a negative value. Use gsl::narrow_cast or gsl::narrow instead to guard against undefined behavior and potential data loss (es.46). -#pragma warning(disable: 26823) // Dereferencing a possibly null pointer '...' (lifetime.1). -#endif // _MSC_VER #include "xml/lite/ContentHandler.h" #include "xml/lite/Attributes.h" @@ -67,16 +37,6 @@ #include "xml/lite/Serializable.h" #include "xml/lite/Validator.h" -#if _MSC_VER -#pragma warning(pop) - -#pragma comment(lib, "xml.lite-c++.lib") - -#if defined(USE_XERCES) -#pragma comment(lib, "xerces-c") -#endif -#endif - /*! * \file lite.h * diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/xerces_.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/xerces_.h index 51d2ca436f..b35fc47147 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/xerces_.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/xerces_.h @@ -54,6 +54,11 @@ CODA_OSS_disable_warning_system_header_push CODA_OSS_disable_warning(-Wshadow) CODA_OSS_disable_warning(-Wsuggest-override) CODA_OSS_disable_warning(-Wzero-as-null-pointer-constant) +CODA_OSS_disable_warning(-Wmisleading-indentation) +CODA_OSS_disable_warning(-Wsign-compare) +CODA_OSS_disable_warning(-Wformat-overflow=) +CODA_OSS_disable_warning(-Wunused-value) +CODA_OSS_disable_warning(-Walloc-size-larger-than=) #endif #include diff --git a/externals/coda-oss/modules/c++/xml.lite/source/Serializable.cpp b/externals/coda-oss/modules/c++/xml.lite/source/Serializable.cpp index d5f55479ce..27cb7aaf02 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/Serializable.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/Serializable.cpp @@ -26,8 +26,10 @@ void xml::lite::Serializable::serialize(io::OutputStream& os) { xml::lite::Element *root = getDocument()->getRootElement(); if (root != nullptr) + { os.write("\n"); - root->print(os); + root->print(os); + } } void xml::lite::Serializable::deserialize(io::InputStream& is) diff --git a/externals/coda-oss/modules/c++/zip/source/ZipOutputStream.cpp b/externals/coda-oss/modules/c++/zip/source/ZipOutputStream.cpp index f4e09e34c6..2b9bd903ee 100644 --- a/externals/coda-oss/modules/c++/zip/source/ZipOutputStream.cpp +++ b/externals/coda-oss/modules/c++/zip/source/ZipOutputStream.cpp @@ -48,9 +48,9 @@ void ZipOutputStream::createFileInZip(const std::string& pathname, mZip, pathname.c_str(), &zipFileInfo, - NULL, + nullptr, 0, - NULL, + nullptr, 0, comment.empty() ? nullptr : comment.c_str(), Z_DEFLATED, diff --git a/externals/nitro/.github/workflows/frequent_check.yml b/externals/nitro/.github/workflows/frequent_check.yml index 1a05c1c661..aa0c3d30d6 100644 --- a/externals/nitro/.github/workflows/frequent_check.yml +++ b/externals/nitro/.github/workflows/frequent_check.yml @@ -8,6 +8,8 @@ jobs: strategy: matrix: os: [windows-latest] + platform: [x64] + configuration: [Release] name: ${{ matrix.os }}-CMake runs-on: ${{ matrix.os }} @@ -19,29 +21,63 @@ jobs: python-version: '3.7' - name: configure run: | - mkdir target-Release - cd target-Release - cmake -DCMAKE_INSTALL_PREFIX=install${{ matrix.os }}CMake-Github -DPYTHON_VERSION="3.7" .. + mkdir out + cd out + cmake .. -DCMAKE_INSTALL_PREFIX=install\${{ matrix.platform }}-${{ matrix.configuration }} -DPYTHON_VERSION="3.7" - name: make run: | - cd target-Release - cmake --build . --config Release -j - cmake --build . --config Release --target install + cd out + cmake --build . --config ${{ matrix.configuration }} -j + cmake --build . --config ${{ matrix.configuration }} --target install - name: test run: | - cd target-Release - ctest -C Release --output-on-failure + cd out + ctest -C ${{ matrix.configuration }} --output-on-failure + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild + with: + msbuild-architecture: x64 + - name: msbuild + run: | + msbuild nitro.sln /p:configuration=${{ matrix.configuration }} + + build-msbuild-windows: + strategy: + matrix: + os: [windows-latest] + platform: [x64] + configuration: [Debug] # Debug turns on more compiler warnings + name: ${{ matrix.os }}-msbuild + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - name: configure CODA-OSS + run: | + mkdir externals\coda-oss\out + cd externals\coda-oss\out + cmake .. -DCMAKE_INSTALL_PREFIX=install\${{ matrix.platform }}-${{ matrix.configuration }} -DENABLE_PYTHON=OFF + - name: make CODA-OSS + run: | + cd externals\coda-oss\out + cmake --build . --config ${{ matrix.configuration }} -j + cmake --build . --config ${{ matrix.configuration }} --target install - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.1 + uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild with: msbuild-architecture: x64 - name: msbuild run: | - msbuild nitro.sln /p:configuration=Release - #- name: mstest + msbuild nitro.sln /p:configuration=${{ matrix.configuration }} + #- name: vstest + # uses: microsoft/vstest-action@v1.0.0 # https://github.com/marketplace/actions/vstest-action + # with: + # platform: ${{ matrix.platform }} + # testAssembly: UnitTest.dll + # searchFolder: D:\a\nitro\nitro\x64\Debug + #- name: vstest # run: | - # mstest /testcontainer:${RUNNER_WORKSPACE}\coda-oss\x64\Releast\Test.dll - # mstest /testcontainer:${RUNNER_WORKSPACE}\coda-oss\x64\Releast\Test++.dll + # vstest.console D:\a\nitro\nitro\x64\Debug\UnitTest.dll build-linux-cmake: strategy: @@ -60,7 +96,7 @@ jobs: run: | mkdir target-Release cd target-Release - cmake -DCMAKE_INSTALL_PREFIX=install${{ matrix.os }}CMake-Github -DPYTHON_VERSION=3.7 .. + cmake .. -DCMAKE_INSTALL_PREFIX=install${{ matrix.os }}CMake-Github -DPYTHON_VERSION=3.7 - name: make run: | cd target-Release diff --git a/externals/nitro/.github/workflows/main.yml b/externals/nitro/.github/workflows/main.yml index 5151ecc5c1..f08b708076 100644 --- a/externals/nitro/.github/workflows/main.yml +++ b/externals/nitro/.github/workflows/main.yml @@ -11,6 +11,8 @@ jobs: strategy: matrix: os: [windows-latest] + platform: [x64] + configuration: [Release] name: ${{ matrix.os }}-CMake runs-on: ${{ matrix.os }} @@ -22,29 +24,63 @@ jobs: python-version: '3.7' - name: configure run: | - mkdir target-Release - cd target-Release - cmake -DCMAKE_INSTALL_PREFIX=install${{ matrix.os }}CMake-Github -DPYTHON_VERSION="3.7" .. + mkdir out + cd out + cmake .. -DCMAKE_INSTALL_PREFIX=install\${{ matrix.platform }}-${{ matrix.configuration }} -DPYTHON_VERSION="3.7" - name: make run: | - cd target-Release - cmake --build . --config Release -j - cmake --build . --config Release --target install + cd out + cmake --build . --config ${{ matrix.configuration }} -j + cmake --build . --config ${{ matrix.configuration }} --target install - name: test run: | - cd target-Release - ctest -C Release --output-on-failure + cd out + ctest -C ${{ matrix.configuration }} --output-on-failure + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild + with: + msbuild-architecture: x64 + - name: msbuild + run: | + msbuild nitro.sln /p:configuration=${{ matrix.configuration }} + + build-msbuild-windows: + strategy: + matrix: + os: [windows-latest] + platform: [x64] + configuration: [Debug] # Debug turns on more compiler warnings + name: ${{ matrix.os }}-msbuild + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - name: configure CODA-OSS + run: | + mkdir externals\coda-oss\out + cd externals\coda-oss\out + cmake .. -DCMAKE_INSTALL_PREFIX=install\${{ matrix.platform }}-${{ matrix.configuration }} -DENABLE_PYTHON=OFF + - name: make CODA-OSS + run: | + cd externals\coda-oss\out + cmake --build . --config ${{ matrix.configuration }} -j + cmake --build . --config ${{ matrix.configuration }} --target install - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.1 + uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild with: msbuild-architecture: x64 - name: msbuild run: | - msbuild nitro.sln /p:configuration=Release - #- name: mstest + msbuild nitro.sln /p:configuration=${{ matrix.configuration }} + #- name: vstest + # uses: microsoft/vstest-action@v1.0.0 # https://github.com/marketplace/actions/vstest-action + # with: + # platform: ${{ matrix.platform }} + # testAssembly: UnitTest.dll + # searchFolder: D:\a\nitro\nitro\x64\Debug + #- name: vstest # run: | - # mstest /testcontainer:${RUNNER_WORKSPACE}\coda-oss\x64\Releast\Test.dll - # mstest /testcontainer:${RUNNER_WORKSPACE}\coda-oss\x64\Releast\Test++.dll + # vstest.console D:\a\nitro\nitro\x64\Debug\UnitTest.dll build-linux-cmake: strategy: diff --git a/externals/nitro/Test++/Test++.vcxproj b/externals/nitro/Test++/Test++.vcxproj deleted file mode 100644 index 19fff43f6b..0000000000 --- a/externals/nitro/Test++/Test++.vcxproj +++ /dev/null @@ -1,177 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - 17.0 - {E610F11D-1240-4260-87F8-504B49DB6915} - Win32Proj - UnitTest - 10.0 - NativeUnitTestProject - - - - DynamicLibrary - true - v143 - Unicode - false - - - DynamicLibrary - false - v143 - true - Unicode - false - - - - - - - - - - - - - - - true - - - false - - - - Use - EnableAllWarnings - true - $(SolutionDir)modules\c++\;$(SolutionDir)modules\c++\nitf\include\;$(SolutionDir)modules\c\;$(SolutionDir)modules\c\nrt\include\;$(SolutionDir)modules\c\nitf\include\;$(SolutionDir)modules\c\jpeg\include\;$(SolutionDir)modules\c\j2k\include\;$(SolutionDir)modules\c\cgm\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)externals\coda-oss\install-$(Configuration)-$(Platform).$(PlatformToolset)\include\;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\ - _DEBUG;%(PreprocessorDefinitions) - true - pch.h - true - true - Guard - MultiThreadedDebugDLL - true - true - ProgramDatabase - AdvancedVectorExtensions2 - - - Windows - $(VCInstallDir)UnitTest\lib;$(SolutionDir)out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\lib\;%(AdditionalLibraryDirectories) - - - - - Use - Level3 - true - true - true - $(SolutionDir)modules\c\nrt\include\;$(SolutionDir)modules\c\nitf\include\;$(SolutionDir)modules\c\jpeg\include\;$(SolutionDir)modules\c\j2k\include\;$(SolutionDir)modules\c\cgm\include;$(SolutionDir)modules\c\;$(SolutionDir)modules\c++\;$(SolutionDir)modules\c++\nitf\include\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)externals\coda-oss\install-$(Configuration)-$(Platform).$(PlatformToolset)\include\;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\ - NDEBUG;%(PreprocessorDefinitions) - true - pch.h - true - Guard - true - true - AdvancedVectorExtensions2 - - - Windows - true - true - $(VCInstallDir)UnitTest\lib;$(SolutionDir)out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\lib\;%(AdditionalLibraryDirectories) - - - - - - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - {8f357a19-799e-4971-850e-3f28485c130b} - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - {53f9f908-c678-4dee-9309-e71c1d03a45f} - - - {730b1e6e-2469-4f9e-b093-d0c6262453c9} - - - {51d7b426-899e-428d-9f69-5ddac9e403fb} - - - {12aa0752-4ee3-4e0a-85af-0e5deadbf343} - - - {023de06d-3967-4406-b1b8-032118bb2552} - - - {53f9f908-c678-4dee-9309-e71c1e03a45f} - - - {d749aa73-4c9a-473d-96bb-070a6d9caa54} - - - {d1d7fcd3-6130-4504-9da0-9d80506be55e} - - - {2baaaca9-a5a4-412c-ae52-b16c2d107f55} - - - {cf5b4f02-364d-4117-9fb9-6c9c7938e412} - - - {78849481-d356-4cc7-b182-31c21f857ed1} - - - - - - \ No newline at end of file diff --git a/externals/nitro/Test++/Test++.vcxproj.filters b/externals/nitro/Test++/Test++.vcxproj.filters deleted file mode 100644 index cbac6cf64f..0000000000 --- a/externals/nitro/Test++/Test++.vcxproj.filters +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/externals/nitro/Test++/Test.h b/externals/nitro/Test++/Test.h deleted file mode 100644 index d701a1544f..0000000000 --- a/externals/nitro/Test++/Test.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#pragma warning(push) -#pragma warning(disable: 4464) // relative include path contains '..' -#include "../Test/Test.h" -#pragma warning(pop) \ No newline at end of file diff --git a/externals/nitro/Test++/TestCase.h b/externals/nitro/Test++/TestCase.h deleted file mode 100644 index c9583fa66e..0000000000 --- a/externals/nitro/Test++/TestCase.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -#include "Test.h" diff --git a/externals/nitro/Test++/nitf_Test.h b/externals/nitro/Test++/nitf_Test.h deleted file mode 100644 index 107330a623..0000000000 --- a/externals/nitro/Test++/nitf_Test.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#if defined(MS_CPP_UNITTESTFRAMEWORK) -#define __TEST_H__ // #include "../nitf/unittests/Test.h" -#define __TEST_CASE_H__ // #include "../nitf/unittests/TestCase.h" -#endif -#include "Test.h" - -#include - -#include "import/nitf.h" - -#include - -namespace Microsoft{ namespace VisualStudio {namespace CppUnitTestFramework -{ - -template<> -inline std::wstring ToString(const nitf::PixelValueType& q) -{ - return str::EncodedStringView(nitf::to_string(q)).wstring(); -} - -template<> -inline std::wstring ToString(const nitf::BlockingMode& q) -{ - return str::EncodedStringView(nitf::to_string(q)).wstring(); -} - -template<> -inline std::wstring ToString(const nitf::ImageCompression& q) -{ - return str::EncodedStringView(nitf::to_string(q)).wstring(); -} - -}}} \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_compress_tile.cpp b/externals/nitro/Test++/nitf_test_compress_tile.cpp deleted file mode 100644 index c4c4d11c26..0000000000 --- a/externals/nitro/Test++/nitf_test_compress_tile.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(test_j2k_read_tile) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_j2k_compress_tile.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_create_nitf++.cpp b/externals/nitro/Test++/nitf_test_create_nitf++.cpp deleted file mode 100644 index b7a4face16..0000000000 --- a/externals/nitro/Test++/nitf_test_create_nitf++.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "pch.h" - -#include - -#include "nitf_Test.h" - -CODA_OSS_disable_warning_push -#if _MSC_VER -#pragma warning(disable: 4464) // relative include path contains '..' -#endif -#include -CODA_OSS_disable_warning_pop - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_create_nitf__) { -public: - nitf_test_create_nitf__() { - // initialization code here - nitf::Test::setNitfPluginPath(); - } - - ~nitf_test_create_nitf__() = default; - nitf_test_create_nitf__(const nitf_test_create_nitf__&) = delete; - nitf_test_create_nitf__& operator=(const nitf_test_create_nitf__&) = delete; - - #define TEST_CASE(X) TEST_METHOD(X) - #include "nitf/unittests/test_create_nitf++.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_field++.cpp b/externals/nitro/Test++/nitf_test_field++.cpp deleted file mode 100644 index 416032b1c2..0000000000 --- a/externals/nitro/Test++/nitf_test_field++.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_field__) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_field++.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_hash_table_1++.cpp b/externals/nitro/Test++/nitf_test_hash_table_1++.cpp deleted file mode 100644 index 62fece1c6f..0000000000 --- a/externals/nitro/Test++/nitf_test_hash_table_1++.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_hash_table_1__) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_hash_table_1++.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_image_blocker.cpp b/externals/nitro/Test++/nitf_test_image_blocker.cpp deleted file mode 100644 index be61b895e7..0000000000 --- a/externals/nitro/Test++/nitf_test_image_blocker.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(test_image_blocker) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_image_blocker.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_image_io.cpp b/externals/nitro/Test++/nitf_test_image_io.cpp deleted file mode 100644 index 4d9ad96639..0000000000 --- a/externals/nitro/Test++/nitf_test_image_io.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(test_image_loading__) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_image_loading++.cpp" - -}; diff --git a/externals/nitro/Test++/nitf_test_image_segment_blank_nm_compression.cpp b/externals/nitro/Test++/nitf_test_image_segment_blank_nm_compression.cpp deleted file mode 100644 index 47a54fd251..0000000000 --- a/externals/nitro/Test++/nitf_test_image_segment_blank_nm_compression.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(test_image_segment_blank_nm_compression) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_image_segment_blank_nm_compression.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_image_segment_computer.cpp b/externals/nitro/Test++/nitf_test_image_segment_computer.cpp deleted file mode 100644 index 3129bc58f1..0000000000 --- a/externals/nitro/Test++/nitf_test_image_segment_computer.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(test_image_segment_computer) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_image_segment_computer.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_j2k_compress_tile.cpp b/externals/nitro/Test++/nitf_test_j2k_compress_tile.cpp deleted file mode 100644 index 81fc998389..0000000000 --- a/externals/nitro/Test++/nitf_test_j2k_compress_tile.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(test_j2k_compress_tile) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_j2k_compress_tile.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_j2k_compressed_byte_provider.cpp b/externals/nitro/Test++/nitf_test_j2k_compressed_byte_provider.cpp deleted file mode 100644 index 8c102027a9..0000000000 --- a/externals/nitro/Test++/nitf_test_j2k_compressed_byte_provider.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(test_j2k_compressed_byte_provider) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_j2k_compressed_byte_provider.cpp" - -}; - -std::string test_j2k_compressed_byte_provider::testName; diff --git a/externals/nitro/Test++/nitf_test_j2k_loading++.cpp b/externals/nitro/Test++/nitf_test_j2k_loading++.cpp deleted file mode 100644 index bcd2132370..0000000000 --- a/externals/nitro/Test++/nitf_test_j2k_loading++.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(test_j2k_loading__) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_j2k_loading++.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_j2k_read_tile.cpp b/externals/nitro/Test++/nitf_test_j2k_read_tile.cpp deleted file mode 100644 index c7d2e83d61..0000000000 --- a/externals/nitro/Test++/nitf_test_j2k_read_tile.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(test_j2k_read_tile) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_j2k_read_tile.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_nitf_buffer_list.cpp b/externals/nitro/Test++/nitf_test_nitf_buffer_list.cpp deleted file mode 100644 index 71f19a07ed..0000000000 --- a/externals/nitro/Test++/nitf_test_nitf_buffer_list.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(test_nitf_buffer_list) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_nitf_buffer_list.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_tre_create++.cpp b/externals/nitro/Test++/nitf_test_tre_create++.cpp deleted file mode 100644 index 2db6022c62..0000000000 --- a/externals/nitro/Test++/nitf_test_tre_create++.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "pch.h" - -#include - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_tre_create__) { -public: - nitf_test_tre_create__() { - // initialization code here - nitf::Test::setNitfPluginPath(); - } - ~nitf_test_tre_create__() = default; - nitf_test_tre_create__(const nitf_test_tre_create__&) = delete; - nitf_test_tre_create__& operator=(const nitf_test_tre_create__&) = delete; - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_tre_create++.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_tre_mods++.cpp b/externals/nitro/Test++/nitf_test_tre_mods++.cpp deleted file mode 100644 index b5ec3ba039..0000000000 --- a/externals/nitro/Test++/nitf_test_tre_mods++.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "pch.h" - -#include - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_tre_mods__) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_tre_mods++.cpp" - -}; - -// Be sure this runs AFTER the tre_mods tests ... not really sure why ... -#undef TEST_CASE -TEST_CLASS(test_image_writer) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_image_writer.cpp" - -}; - -#undef TEST_CASE -TEST_CLASS(test_load_plugins) { -public: - test_load_plugins() { - // initialization code here - nitf::Test::setNitfPluginPath(); - } - ~test_load_plugins() = default; - test_load_plugins(const test_load_plugins&) = delete; - test_load_plugins& operator=(const test_load_plugins&) = delete; - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_load_plugins.cpp" - -}; diff --git a/externals/nitro/Test++/nitf_test_tre_mods.cpp b/externals/nitro/Test++/nitf_test_tre_mods.cpp deleted file mode 100644 index dac0bec70b..0000000000 --- a/externals/nitro/Test++/nitf_test_tre_mods.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "pch.h" - -#include - -#include -#include - -#include "nitf_Test.h" - -namespace fs = std::filesystem; - -static bool is_x64_Configuration(const fs::path& path) // "Configuration" is typically "Debug" or "Release" -{ - const std::string build_configuration = -#if defined(NDEBUG) // i.e., release - "Release"; -#else - "Debug"; -#endif - - const auto Configuration = path.filename(); - const auto path_parent_path = path.parent_path(); - const auto x64 = path_parent_path.filename(); - return (Configuration == build_configuration) && (x64 == "x64"); -} - -static bool is_install_unittests(const fs::path& path) -{ - const auto unittests = path.filename(); - const auto path_parent_path = path.parent_path(); - const auto install = path_parent_path.filename(); - return (unittests == "unittests") && (install == "install"); -} -static bool is_install_tests(const fs::path& path) -{ - const auto tests = path.filename(); - const auto path_parent_path = path.parent_path(); - const auto install = path_parent_path.filename(); - return (tests == "tests") && (install == "install"); -} - -static fs::path buildDir(const fs::path& path) -{ - const auto cwd = fs::current_path(); - - const sys::OS os; - const auto exec = fs::path(os.getCurrentExecutable()); - const auto argv0 = exec.filename(); - if (argv0 == "testhost.exe") - { - // Running Visual Studio unit-tests on Windows - if (is_x64_Configuration(cwd)) - { - return cwd / path; - } - } - - if (argv0 == "unittests.exe") - { - // stand-alone unittest executable on Windows (ends in .EXE) - const auto parent_path = exec.parent_path(); - if (is_x64_Configuration(parent_path)) - { - const auto parent_path_ = parent_path.parent_path().parent_path(); - return parent_path_ / "dev" / "tests" / "images"; - } - } - - // stand-alone unit-test on Linux - const auto exec_dir = exec.parent_path(); - if (is_install_unittests(exec_dir)) - { - const auto install = exec_dir.parent_path(); - return install / "unittests" / "data"; - } - if (is_install_tests(exec_dir)) - { - const auto install = exec_dir.parent_path(); - return install / "unittests" / "data"; - } - - if (argv0 == "unittests") - { - // stand-alone unittest executable on Linux - const auto bin = exec.parent_path(); - if (bin.filename() == "bin") - { - const auto unittests = bin.parent_path(); - return unittests / "unittests" / "data"; - } - } - - //fprintf(stderr, "cwd = %s\n", cwd.c_str()); - //fprintf(stderr, "exec = %s\n", exec.c_str()); - - return cwd; -} - -static fs::path buildPluginsDir() -{ - return buildDir(fs::path("share") / "nitf" / "plugins"); -} - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_tre_mods) { -public: - nitf_test_tre_mods() - { - // initialization code here - //const std::string NITF_PLUGIN_PATH = R"(C:\Users\jdsmith\source\repos\nitro\x64\Debug\share\nitf\plugins)"; - const std::string putenv_ = "NITF_PLUGIN_PATH=" + buildPluginsDir().string(); - _putenv(putenv_.c_str()); - } - - ~nitf_test_tre_mods() = default; - nitf_test_tre_mods(const nitf_test_tre_mods&) = delete; - nitf_test_tre_mods& operator=(const nitf_test_tre_mods&) = delete; - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_tre_mods.cpp" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/nitf_test_tre_read.cpp b/externals/nitro/Test++/nitf_test_tre_read.cpp deleted file mode 100644 index f193b32aa6..0000000000 --- a/externals/nitro/Test++/nitf_test_tre_read.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "pch.h" - -#include - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(test_tre_read) { -public: - test_tre_read() { - // initialization code here - nitf::Test::setNitfPluginPath(); - } - ~test_tre_read() = default; - test_tre_read(const test_tre_read&) = delete; - test_tre_read& operator=(const test_tre_read&) = delete; - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_tre_read.cpp" - -}; diff --git a/externals/nitro/Test++/nitf_test_writer_3++.cpp b/externals/nitro/Test++/nitf_test_writer_3++.cpp deleted file mode 100644 index 820cb4a563..0000000000 --- a/externals/nitro/Test++/nitf_test_writer_3++.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "pch.h" - -#include - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_writer_3__) { -public: - nitf_test_writer_3__() { - // initialization code here - nitf::Test::setNitfPluginPath(); - } - ~nitf_test_writer_3__() = default; - nitf_test_writer_3__(const nitf_test_writer_3__&) = delete; - nitf_test_writer_3__& operator=(const nitf_test_writer_3__&) = delete; - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_writer_3++.cpp" - -}; -std::string nitf_test_writer_3__::argv0; \ No newline at end of file diff --git a/externals/nitro/Test++/nrt_Test.h b/externals/nitro/Test++/nrt_Test.h deleted file mode 100644 index 7f0d7a36f3..0000000000 --- a/externals/nitro/Test++/nrt_Test.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#if defined(MS_CPP_UNITTESTFRAMEWORK) -#define __TEST_H__ // #include "../nrt/unittests/Test.h" -#endif -#include "Test.h" diff --git a/externals/nitro/Test++/nrt_test_utils.cpp b/externals/nitro/Test++/nrt_test_utils.cpp deleted file mode 100644 index 4ca3e39fc9..0000000000 --- a/externals/nitro/Test++/nrt_test_utils.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nrt_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nrt_test_utils) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nrt/unittests/test_utils.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test++/pch.cpp b/externals/nitro/Test++/pch.cpp deleted file mode 100644 index 97b544ec11..0000000000 --- a/externals/nitro/Test++/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/externals/nitro/Test++/pch.h b/externals/nitro/Test++/pch.h deleted file mode 100644 index 050a70e79f..0000000000 --- a/externals/nitro/Test++/pch.h +++ /dev/null @@ -1,72 +0,0 @@ -// pch.h: This is a precompiled header file. -// Files listed below are compiled only once, improving build performance for future builds. -// This also affects IntelliSense performance, including code completion and many code browsing features. -// However, files listed here are ALL re-compiled if any one of them is updated between builds. -// Do not add files here that you will be updating frequently as this negates the performance advantage. - -#ifndef PCH_H -#define PCH_H -#pragma once - -#pragma warning(disable: 4820) // '...': '...' bytes padding added after data member '...' -#pragma warning(disable: 4710) // '...': function not inlined -#pragma warning(disable: 5045) // Compiler will insert Spectre mitigation for memory load if / Qspectre switch specified -#pragma warning(disable: 4668) // '...' is not defined as a preprocessor macro, replacing with '...' for '...' -// TODO: get rid of these someday? -#pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception. -#pragma warning(disable: 4514) // '...': unreferenced inline function has been removed - -#pragma warning(push) -#pragma warning(disable: 4464) // relative include path contains '..' -#include "../modules/c++/cpp.h" -#pragma warning(pop) -#pragma comment(lib, "ws2_32") - -// We're building in Visual Studio ... used to control where we get a little bit of config info -#define NITRO_PCH 1 - -#pragma warning(disable: 5032) // detected #pragma warning(push) with no corresponding #pragma warning(pop) -#pragma warning(push) -#pragma warning(disable: 4464) // relative include path contains '..' -#pragma warning(disable: 4625) // '...' : copy constructor was implicitly defined as deleted -#pragma warning(disable: 4626) // '...' : assignment operator was implicitly defined as deleted -#include -#include -#include -#include -#include -#include -#pragma warning(disable: 5031) // #pragma warning(pop): likely mismatch, popping warning state pushed in different file -#pragma comment(lib, "io-c++") -#pragma comment(lib, "except-c++") -#pragma comment(lib, "sys-c++") -#pragma comment(lib, "str-c++") -#pragma comment(lib, "sio.lite-c++.lib") -#pragma comment(lib, "math-c++") -#pragma comment(lib, "mt-c++") -#pragma warning(pop) - -#pragma warning(push) -#include "CppUnitTest.h" -#pragma warning(pop) - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nitf_Test.h" -#include "Test.h" - -#endif //PCH_H diff --git a/externals/nitro/Test/Test.h b/externals/nitro/Test/Test.h deleted file mode 100644 index 8fb840d232..0000000000 --- a/externals/nitro/Test/Test.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include -#include - -#include "CppUnitTest.h" - -#define TEST_ASSERT(X) Assert::IsTrue(X) - -template -inline void test_assert_eq_(T&& t, U&& u) -{ - Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(t, u); - Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(u, t); -} -#define TEST_ASSERT_EQ(X1, X2) test_assert_eq_(X1, X2); -#define TEST_ASSERT_EQ_INT(X1, X2) TEST_ASSERT_EQ(X2, X1) -#define TEST_ASSERT_EQ_STR(X1, X2) TEST_ASSERT_EQ(std::string(X1), std::string(X2)) -#define TEST_ASSERT_EQ_FLOAT(X1, X2) TEST_ASSERT_EQ(static_cast(X1), static_cast(X2)) - -#define TEST_ASSERT_NULL(X) Assert::IsNull((X)) -#define TEST_ASSERT_NOT_NULL(X) Assert::IsNotNull((X)) -#define TEST_ASSERT_TRUE(X) Assert::IsTrue((X)) -#define TEST_ASSERT_FALSE(X) Assert::IsFalse((X)) - -template -inline void test_assert_not_eq_(T&& t, U&& u) -{ - Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreNotEqual(t, u); - Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreNotEqual(u, t); -} -#define TEST_ASSERT_NOT_EQ(X1, X2) test_assert_not_eq_(X1, X2); -template -inline void test_assert_greater_(T&& t, U&& u) -{ - Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(t > u); -} -#define TEST_ASSERT_GREATER(X1, X2) test_assert_greater_(X1, X2) - -#define TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS) { Assert:AreEqual(X1, X2, EPS); Assert:AreEqual(X2, X1, EPS); } -#define TEST_ASSERT_ALMOST_EQ(X1, X2) TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, 0.0001) - -#define TEST_ASSERT_EQ_MSG(msg, X1, X2) Logger::WriteMessage(msg.c_str()); TEST_ASSERT_EQ(X1, X2) - -#define TEST_EXCEPTION(X) try { (X); TEST_ASSERT_FALSE(false); } catch (...) { TEST_ASSERT_TRUE(true); } -#define TEST_THROWS(X) TEST_EXCEPTION(X) - -#define TEST_MAIN(X) diff --git a/externals/nitro/Test/Test.vcxproj b/externals/nitro/Test/Test.vcxproj deleted file mode 100644 index 3f37235948..0000000000 --- a/externals/nitro/Test/Test.vcxproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - 17.0 - {238C9787-B27D-4107-B8FD-1BDB49EA8023} - Win32Proj - UnitTest - 10.0 - NativeUnitTestProject - - - - DynamicLibrary - true - v143 - Unicode - false - - - DynamicLibrary - false - v143 - true - Unicode - false - - - - - - - - - - - - - - - true - - - false - - - - Use - EnableAllWarnings - true - $(SolutionDir)modules\c\nrt\include\;$(SolutionDir)modules\c\nitf\include\;$(SolutionDir)modules\c\jpeg\include\;$(SolutionDir)modules\c\j2k\include\;$(SolutionDir)modules\c\cgm\include;$(SolutionDir)modules\c\;$(SolutionDir)modules\c++\;$(SolutionDir)modules\c++\nitf\include\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) - _DEBUG;%(PreprocessorDefinitions) - true - pch.h - true - true - Guard - MultiThreadedDebugDLL - true - true - ProgramDatabase - AdvancedVectorExtensions2 - - - Windows - $(VCInstallDir)UnitTest\lib;$(SolutionDir)out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\lib\;%(AdditionalLibraryDirectories) - - - - - Use - Level3 - true - true - true - $(SolutionDir)modules\c\nrt\include\;$(SolutionDir)modules\c\nitf\include\;$(SolutionDir)modules\c\jpeg\include\;$(SolutionDir)modules\c\j2k\include\;$(SolutionDir)modules\c\cgm\include;$(SolutionDir)modules\c\;$(SolutionDir)modules\c++\;$(SolutionDir)modules\c++\nitf\include\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) - NDEBUG;%(PreprocessorDefinitions) - true - pch.h - true - Guard - true - true - AdvancedVectorExtensions2 - - - Windows - true - true - $(VCInstallDir)UnitTest\lib;$(SolutionDir)out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\lib\;%(AdditionalLibraryDirectories) - - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - - {8f357a19-799e-4971-850e-3f28485c130b} - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - {53f9f908-c678-4dee-9309-e71c1d03a45f} - - - {730b1e6e-2469-4f9e-b093-d0c6262453c9} - - - {51d7b426-899e-428d-9f69-5ddac9e403fb} - - - {12aa0752-4ee3-4e0a-85af-0e5deadbf343} - - - {023de06d-3967-4406-b1b8-032118bb2552} - - - {53f9f908-c678-4dee-9309-e71c1e03a45f} - - - {d749aa73-4c9a-473d-96bb-070a6d9caa54} - - - {d1d7fcd3-6130-4504-9da0-9d80506be55e} - - - {2baaaca9-a5a4-412c-ae52-b16c2d107f55} - - - {cf5b4f02-364d-4117-9fb9-6c9c7938e412} - - - {78849481-d356-4cc7-b182-31c21f857ed1} - - - - - - \ No newline at end of file diff --git a/externals/nitro/Test/Test.vcxproj.filters b/externals/nitro/Test/Test.vcxproj.filters deleted file mode 100644 index 0b5d831d11..0000000000 --- a/externals/nitro/Test/Test.vcxproj.filters +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/externals/nitro/Test/TestCase.h b/externals/nitro/Test/TestCase.h deleted file mode 100644 index c9583fa66e..0000000000 --- a/externals/nitro/Test/TestCase.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -#include "Test.h" diff --git a/externals/nitro/Test/j2k_Test.h b/externals/nitro/Test/j2k_Test.h deleted file mode 100644 index 23af9b6d40..0000000000 --- a/externals/nitro/Test/j2k_Test.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#if defined(GTEST_API_) -#define __TEST_H__ // #include "../j2k/unittests/Test.h" -#endif -#include "Test.h" diff --git a/externals/nitro/Test/nitf_Test.h b/externals/nitro/Test/nitf_Test.h deleted file mode 100644 index c307e56435..0000000000 --- a/externals/nitro/Test/nitf_Test.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#if defined(MS_CPP_UNITTESTFRAMEWORK) -#define __TEST_H__ // #include "../nitf/unittests/Test.h" -#define __TEST_CASE_H__ // #include "../nitf/unittests/TestCase.h" -#endif -#include "Test.h" - -#include - -#include "import/nitf.h" diff --git a/externals/nitro/Test/nitf_test_create.cpp b/externals/nitro/Test/nitf_test_create.cpp deleted file mode 100644 index f794fe5859..0000000000 --- a/externals/nitro/Test/nitf_test_create.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_create) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_create.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test/nitf_test_create_nitf.cpp b/externals/nitro/Test/nitf_test_create_nitf.cpp deleted file mode 100644 index 8fdf17ce88..0000000000 --- a/externals/nitro/Test/nitf_test_create_nitf.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -#define TEST_NAME nitf_test_create_nitf -int argc = 1; -const char* argv[] = { "nitf_test_create_nitf" }; - -#include "nitf/unittests/nitro_image_.c_" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_create_nitf) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#define TEST_CASE_ARGS(X) TEST_METHOD(X) -#include "nitf/unittests/test_create_nitf.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test/nitf_test_field.cpp b/externals/nitro/Test/nitf_test_field.cpp deleted file mode 100644 index 70fecd6e68..0000000000 --- a/externals/nitro/Test/nitf_test_field.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_field) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_field.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test/nitf_test_geo_utils.cpp b/externals/nitro/Test/nitf_test_geo_utils.cpp deleted file mode 100644 index e30ba258da..0000000000 --- a/externals/nitro/Test/nitf_test_geo_utils.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_geo_utils) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_geo_utils.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test/nitf_test_image_io.cpp b/externals/nitro/Test/nitf_test_image_io.cpp deleted file mode 100644 index 097defccb6..0000000000 --- a/externals/nitro/Test/nitf_test_image_io.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_image_io) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_image_io.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test/nitf_test_mem_source.cpp b/externals/nitro/Test/nitf_test_mem_source.cpp deleted file mode 100644 index 341cccbac9..0000000000 --- a/externals/nitro/Test/nitf_test_mem_source.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_mem_source) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_mem_source.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test/nitf_test_tre_read.cpp b/externals/nitro/Test/nitf_test_tre_read.cpp deleted file mode 100644 index aaf2f98864..0000000000 --- a/externals/nitro/Test/nitf_test_tre_read.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "pch.h" - -#include - -#include "nitf_Test.h" - -struct test_tre_read : public ::testing::Test { - test_tre_read() { - // initialization code here - //const std::string NITF_PLUGIN_PATH = R"(C:\Users\jdsmith\source\repos\nitro\x64\Debug\share\nitf\plugins)"; - nitf::Test::setNitfPluginPath(); - } - - void SetUp() { - // code here will execute just before the test ensues - } - - void TearDown() { - // code here will be called just after the test completes - // ok to through exceptions from here if need be - } - - ~test_tre_read() { - // cleanup any pending stuff, but no exceptions allowed - } - - test_tre_read(const test_tre_read&) = delete; - test_tre_read& operator=(const test_tre_read&) = delete; - - - // put in any custom data members that you need -}; - -#define TEST_CASE(X) TEST_F(test_tre_read, X) -#include "nitf/unittests/test_tre_read.cpp" diff --git a/externals/nitro/Test/nitf_test_zero_field.cpp b/externals/nitro/Test/nitf_test_zero_field.cpp deleted file mode 100644 index adda886ae9..0000000000 --- a/externals/nitro/Test/nitf_test_zero_field.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nitf_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nitf_test_zero_field) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nitf/unittests/test_zero_field.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test/nrt_Test.h b/externals/nitro/Test/nrt_Test.h deleted file mode 100644 index 7f0d7a36f3..0000000000 --- a/externals/nitro/Test/nrt_Test.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#if defined(MS_CPP_UNITTESTFRAMEWORK) -#define __TEST_H__ // #include "../nrt/unittests/Test.h" -#endif -#include "Test.h" diff --git a/externals/nitro/Test/nrt_test_buffer_adapter.cpp b/externals/nitro/Test/nrt_test_buffer_adapter.cpp deleted file mode 100644 index 79b5af6f3b..0000000000 --- a/externals/nitro/Test/nrt_test_buffer_adapter.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nrt_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nrt_test_buffer_adapter) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nrt/unittests/test_buffer_adapter.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test/nrt_test_core_values.cpp b/externals/nitro/Test/nrt_test_core_values.cpp deleted file mode 100644 index 8e1b964165..0000000000 --- a/externals/nitro/Test/nrt_test_core_values.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nrt_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nrt_test_core_values) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nrt/unittests/test_core_values.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test/nrt_test_list.cpp b/externals/nitro/Test/nrt_test_list.cpp deleted file mode 100644 index 45ddc75ffb..0000000000 --- a/externals/nitro/Test/nrt_test_list.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nrt_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nrt_test_list) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nrt/unittests/test_list.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test/nrt_test_nrt_byte_swap.cpp b/externals/nitro/Test/nrt_test_nrt_byte_swap.cpp deleted file mode 100644 index c863cf98f8..0000000000 --- a/externals/nitro/Test/nrt_test_nrt_byte_swap.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nrt_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nrt_test_nrt_byte_swap) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nrt/unittests/test_nrt_byte_swap.c" - -}; diff --git a/externals/nitro/Test/nrt_test_nrt_datetime.cpp b/externals/nitro/Test/nrt_test_nrt_datetime.cpp deleted file mode 100644 index 59e0f3faa6..0000000000 --- a/externals/nitro/Test/nrt_test_nrt_datetime.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nrt_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nrt_test_nrt_datetime) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nrt/unittests/test_nrt_datetime.c" - -}; diff --git a/externals/nitro/Test/nrt_test_tree.cpp b/externals/nitro/Test/nrt_test_tree.cpp deleted file mode 100644 index 0d1c83100b..0000000000 --- a/externals/nitro/Test/nrt_test_tree.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "pch.h" - -#include "nrt_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -const char* testName = "testTree"; -TEST_CLASS(nrt_test_tree) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nrt/unittests/test_tree.c" - -}; \ No newline at end of file diff --git a/externals/nitro/Test/nrt_test_utils.cpp b/externals/nitro/Test/nrt_test_utils.cpp deleted file mode 100644 index 4ca3e39fc9..0000000000 --- a/externals/nitro/Test/nrt_test_utils.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" - -#include "nrt_Test.h" - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -TEST_CLASS(nrt_test_utils) { -public: - -#define TEST_CASE(X) TEST_METHOD(X) -#include "nrt/unittests/test_utils.c" - -}; \ No newline at end of file diff --git a/externals/nitro/UnitTest/CppUnitTestAssert.cpp b/externals/nitro/UnitTest/CppUnitTestAssert.cpp new file mode 100644 index 0000000000..5bea8da590 --- /dev/null +++ b/externals/nitro/UnitTest/CppUnitTestAssert.cpp @@ -0,0 +1,5 @@ +#include "pch.h" +#include "TestCase.h" + +// Can't get this to build in the **coda-oss** project. +#include "sys/source/CppUnitTestAssert_.cpp_" diff --git a/externals/nitro/UnitTest/Test.h b/externals/nitro/UnitTest/Test.h new file mode 100644 index 0000000000..a36e09780e --- /dev/null +++ b/externals/nitro/UnitTest/Test.h @@ -0,0 +1,8 @@ +#pragma once + +#include "nitf/unittests/Test.h" +#include "TestCase.h" + +#define TEST_ASSERT_EQ_INT(X1, X2) TEST_ASSERT_EQ(X2, X1) +#define TEST_ASSERT_EQ_STR(X1, X2) TEST_ASSERT_EQ(std::string(X1), std::string(X2)) +#define TEST_ASSERT_EQ_FLOAT(X1, X2) TEST_ASSERT_EQ(static_cast(X1), static_cast(X2)) \ No newline at end of file diff --git a/externals/nitro/UnitTest/TestCase.h b/externals/nitro/UnitTest/TestCase.h new file mode 100644 index 0000000000..2c8a470500 --- /dev/null +++ b/externals/nitro/UnitTest/TestCase.h @@ -0,0 +1,7 @@ +#pragma once + +#undef TEST_ASSERT_NULL +#undef TEST_ASSERT +#undef TEST_ASSERT_ALMOST_EQ +#undef TEST_ASSERT_EQ +#include diff --git a/externals/nitro/UnitTest/UnitTest.cpp b/externals/nitro/UnitTest/UnitTest.cpp new file mode 100644 index 0000000000..aedc2a9f63 --- /dev/null +++ b/externals/nitro/UnitTest/UnitTest.cpp @@ -0,0 +1,11 @@ +#include "pch.h" +#include "CppUnitTest.h" + +#include + +// https://learn.microsoft.com/en-us/visualstudio/test/microsoft-visualstudio-testtools-cppunittestframework-api-reference?view=vs-2022 +TEST_MODULE_INITIALIZE(methodName) +{ + // module initialization code + nitf::Test::setNitfPluginPath(); +} \ No newline at end of file diff --git a/externals/nitro/UnitTest/UnitTest.vcxproj b/externals/nitro/UnitTest/UnitTest.vcxproj new file mode 100644 index 0000000000..d936467254 --- /dev/null +++ b/externals/nitro/UnitTest/UnitTest.vcxproj @@ -0,0 +1,301 @@ + + + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {8ACE478C-8F6F-4D42-9B43-7D75882D4BE1} + Win32Proj + UnitTest + 10.0 + NativeUnitTestProject + + + + DynamicLibrary + true + v143 + Unicode + false + + + DynamicLibrary + false + v143 + true + Unicode + false + + + + + + + + + + + + + + + true + + + false + + + + Use + Level3 + true + $(ProjectDir);$(SolutionDir)modules\c\nrt\include;$(SolutionDir)modules\c\nitf\include;$(SolutionDir)modules\c++\nitf\include;$(SolutionDir)modules\c\j2k\include;$(SolutionDir)modules\c;$(SolutionDir)modules\c++;$(SolutionDir)externals\coda-oss\modules\c++;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + _DEBUG;%(PreprocessorDefinitions) + true + pch.h + AdvancedVectorExtensions2 + MultiThreadedDebugDLL + true + true + true + true + true + + + Windows + $(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib;$(SolutionDir)out\install\$(Platform)-$(Configuration)\lib;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + Use + Level3 + true + true + true + $(ProjectDir);$(SolutionDir)modules\c\nrt\include;$(SolutionDir)modules\c\nitf\include;$(SolutionDir)modules\c++\nitf\include;$(SolutionDir)modules\c\j2k\include;$(SolutionDir)modules\c;$(SolutionDir)modules\c++;$(SolutionDir)externals\coda-oss\modules\c++;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + NDEBUG;%(PreprocessorDefinitions) + true + pch.h + AdvancedVectorExtensions2 + Guard + true + true + true + true + + + Windows + true + true + $(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib;$(SolutionDir)out\install\$(Platform)-$(Configuration)\lib;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + + + + + Create + Create + + + + + + + + + + + {8f357a19-799e-4971-850e-3f28485c130b} + + + {f06550ad-cfc7-40b8-8727-6c82c69a8982} + + + {53f9f908-c678-4dee-9309-e71c1d03a45f} + + + {730b1e6e-2469-4f9e-b093-d0c6262453c9} + + + {51d7b426-899e-428d-9f69-5ddac9e403fb} + + + {12aa0752-4ee3-4e0a-85af-0e5deadbf343} + + + {023de06d-3967-4406-b1b8-032118bb2552} + + + {0a9bda26-092f-4a2c-bbef-00c64bf0c65e} + + + {53f9f908-c678-4dee-9309-e71c1e03a45f} + + + {d749aa73-4c9a-473d-96bb-070a6d9caa54} + + + {d1d7fcd3-6130-4504-9da0-9d80506be55e} + + + {2baaaca9-a5a4-412c-ae52-b16c2d107f55} + + + {cf5b4f02-364d-4117-9fb9-6c9c7938e412} + + + {78849481-d356-4cc7-b182-31c21f857ed1} + + + + + + \ No newline at end of file diff --git a/externals/nitro/UnitTest/UnitTest.vcxproj.filters b/externals/nitro/UnitTest/UnitTest.vcxproj.filters new file mode 100644 index 0000000000..7eecfb2b8e --- /dev/null +++ b/externals/nitro/UnitTest/UnitTest.vcxproj.filters @@ -0,0 +1,135 @@ + + + + + {d6b8959a-344d-4af2-b926-05be973609a4} + + + {a03980e8-d43d-473b-9f2a-a883ddd94df0} + + + {555282a7-bf5d-4012-842a-435bfb7324ab} + + + + + nrt + + + + nrt + + + + nrt + + + nrt + + + nrt + + + nrt + + + nrt + + + nrt + + + nitf-c + + + nitf-c + + + nitf-c + + + nitf-c + + + nitf-c + + + nitf-c + + + nitf-c + + + nitf-c + + + nitf-c + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + nitf-c++ + + + + + + + + + \ No newline at end of file diff --git a/externals/nitro/UnitTest/nitf-c++.cpp b/externals/nitro/UnitTest/nitf-c++.cpp new file mode 100644 index 0000000000..700258d514 --- /dev/null +++ b/externals/nitro/UnitTest/nitf-c++.cpp @@ -0,0 +1,105 @@ +#include "pch.h" +#include "CppUnitTest.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace nitf_cpp +{ + +TEST_CLASS(test_create_nitf__){ public: +#include "nitf/unittests/test_create_nitf++.cpp" +}; + +TEST_CLASS(test_field__){ public: +#include "nitf/unittests/test_field++.cpp" +}; + +TEST_CLASS(test_hash_table_1__){ public: +#include "nitf/unittests/test_hash_table_1++.cpp" +}; + +TEST_CLASS(test_image_blocker){ public: +#include "nitf/unittests/test_image_blocker.cpp" +}; + +TEST_CLASS(test_image_loading__){ public: +#include "nitf/unittests/test_image_loading++.cpp" +}; + +TEST_CLASS(test_image_segment_blank_nm_compression){ public: +#include "nitf/unittests/test_image_segment_blank_nm_compression.cpp" +}; + +TEST_CLASS(test_image_segment_computer){ public: +#include "nitf/unittests/test_image_segment_computer.cpp" +}; + +TEST_CLASS(test_image_writer){ public: +#include "nitf/unittests/test_image_writer.cpp" +}; + +TEST_CLASS(test_j2k_compress_tile){ public: +#include "nitf/unittests/test_j2k_compress_tile.cpp" +}; + +TEST_CLASS(test_j2k_compressed_byte_provider){ public: +#include "nitf/unittests/test_j2k_compressed_byte_provider.cpp" +}; + +TEST_CLASS(test_j2k_loading__){ public: +#include "nitf/unittests/test_j2k_loading++.cpp" +}; + +TEST_CLASS(test_j2k_read_tile){ public: +#include "nitf/unittests/test_j2k_read_tile.cpp" +}; + +TEST_CLASS(test_load_plugins){ public: +#include "nitf/unittests/test_load_plugins.cpp" +}; + +TEST_CLASS(test_nitf_buffer_list){ public: +#include "nitf/unittests/test_nitf_buffer_list.cpp" +}; + +TEST_CLASS(test_tre_create__){ public: +#include "nitf/unittests/test_tre_create++.cpp" +}; + +TEST_CLASS(test_tre_mods){ public: +#include "nitf/unittests/test_tre_mods.cpp" +}; + +TEST_CLASS(test_tre_mods__){ public: +#include "nitf/unittests/test_tre_mods++.cpp" +}; + +TEST_CLASS(test_tre_read){ public: +#include "nitf/unittests/test_tre_read.cpp" +}; + +TEST_CLASS(test_writer_3__){ public: +#include "nitf/unittests/test_writer_3++.cpp" +}; + +} \ No newline at end of file diff --git a/externals/nitro/UnitTest/nitf-c.cpp b/externals/nitro/UnitTest/nitf-c.cpp new file mode 100644 index 0000000000..a25999a6e2 --- /dev/null +++ b/externals/nitro/UnitTest/nitf-c.cpp @@ -0,0 +1,43 @@ +#include "pch.h" +#include "CppUnitTest.h" + +#include +#include +#include + +namespace nitf_c +{ + +TEST_CLASS(test_create){ public: +#include "nitf/unittests/test_create.c" +}; + +TEST_CLASS(test_create_nitf){ public: +#include "nitf/unittests/test_create_nitf.c" +}; + +TEST_CLASS(test_field){ public: +#include "nitf/unittests/test_field.c" +}; + +TEST_CLASS(test_geo_utils_){ public: // "TEST_CASE(test_geo_utils)" conflicts +#include "nitf/unittests/test_geo_utils.c" +}; + +TEST_CLASS(test_image_io){ public: +#include "nitf/unittests/test_image_io.c" +}; + +TEST_CLASS(test_mem_source){ public: +#include "nitf/unittests/test_mem_source.c" +}; + +TEST_CLASS(test_moveTREs){ public: +#include "nitf/unittests/test_moveTREs.c" +}; + +TEST_CLASS(test_zero_field){ public: +#include "nitf/unittests/test_zero_field.c" +}; + +} \ No newline at end of file diff --git a/externals/nitro/UnitTest/nrt.cpp b/externals/nitro/UnitTest/nrt.cpp new file mode 100644 index 0000000000..7fa9c57eac --- /dev/null +++ b/externals/nitro/UnitTest/nrt.cpp @@ -0,0 +1,38 @@ +#include "pch.h" +#include "CppUnitTest.h" + +#include +#include + +namespace nrt +{ + +TEST_CLASS(test_buffer_adapter){ public: +#include "nrt/unittests/test_buffer_adapter.c" +}; + +TEST_CLASS(test_core_values){ public: +#include "nrt/unittests/test_core_values.c" +}; + +TEST_CLASS(test_list){ public: +#include "nrt/unittests/test_list.c" +}; + +TEST_CLASS(test_nrt_byte_swap){ public: +#include "nrt/unittests/test_nrt_byte_swap.c" +}; + +TEST_CLASS(test_nrt_datetime){ public: +#include "nrt/unittests/test_nrt_datetime.c" +}; + +TEST_CLASS(test_tree){ public: +#include "nrt/unittests/test_tree.c" +}; + +TEST_CLASS(test_utils){ public: +#include "nrt/unittests/test_utils.c" +}; + +} \ No newline at end of file diff --git a/externals/nitro/Test/pch.cpp b/externals/nitro/UnitTest/pch.cpp similarity index 97% rename from externals/nitro/Test/pch.cpp rename to externals/nitro/UnitTest/pch.cpp index 64b7eef6d6..91c22df2a1 100644 --- a/externals/nitro/Test/pch.cpp +++ b/externals/nitro/UnitTest/pch.cpp @@ -1,5 +1,5 @@ -// pch.cpp: source file corresponding to the pre-compiled header - -#include "pch.h" - -// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. +// pch.cpp: source file corresponding to the pre-compiled header + +#include "pch.h" + +// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/externals/nitro/Test/pch.h b/externals/nitro/UnitTest/pch.h similarity index 50% rename from externals/nitro/Test/pch.h rename to externals/nitro/UnitTest/pch.h index fb05af902b..ab78e8ef45 100644 --- a/externals/nitro/Test/pch.h +++ b/externals/nitro/UnitTest/pch.h @@ -1,50 +1,45 @@ -// pch.h: This is a precompiled header file. -// Files listed below are compiled only once, improving build performance for future builds. -// This also affects IntelliSense performance, including code completion and many code browsing features. -// However, files listed here are ALL re-compiled if any one of them is updated between builds. -// Do not add files here that you will be updating frequently as this negates the performance advantage. - -#ifndef PCH_H -#define PCH_H -#pragma once - -#pragma warning(disable: 4820) // '...': '...' bytes padding added after data member '...' -#pragma warning(disable: 4710) // '...': function not inlined -#pragma warning(disable: 5045) // Compiler will insert Spectre mitigation for memory load if / Qspectre switch specified -#pragma warning(disable: 4668) // '...' is not defined as a preprocessor macro, replacing with '...' for '...' -// TODO: get rid of these someday? -#pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception. -#pragma warning(disable: 4514) // '...': unreferenced inline function has been removed - -#pragma warning(push) -#pragma warning(disable: 4464) // relative include path contains '..' -#include "../modules/c++/cpp.h" -#pragma warning(pop) -#pragma comment(lib, "ws2_32") - -// We're building in Visual Studio ... used to control where we get a little bit of config info -#define NITRO_PCH 1 - -#pragma warning(disable: 5032) // detected #pragma warning(push) with no corresponding #pragma warning(pop) -#pragma warning(push) -#pragma warning(disable: 4464) // relative include path contains '..' -#include -#pragma warning(disable: 5031) // #pragma warning(pop): likely mismatch, popping warning state pushed in different file -#pragma comment(lib, "io-c++") -#pragma comment(lib, "except-c++") -#pragma comment(lib, "sys-c++") -#pragma comment(lib, "str-c++") -#pragma warning(pop) - -#pragma warning(push) -#include "CppUnitTest.h" -#pragma warning(pop) - -#include -#include -#include - -#include "nitf_Test.h" -#include "Test.h" - -#endif //PCH_H +// pch.h: This is a precompiled header file. +// Files listed below are compiled only once, improving build performance for future builds. +// This also affects IntelliSense performance, including code completion and many code browsing features. +// However, files listed here are ALL re-compiled if any one of them is updated between builds. +// Do not add files here that you will be updating frequently as this negates the performance advantage. + +#ifndef PCH_H +#define PCH_H + +// add headers that you want to pre-compile here + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define NOMINMAX +#pragma warning(push) +#pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception. +#include +#pragma warning(pop) +#pragma comment(lib, "ws2_32") + +// We're building in Visual Studio ... used to control where we get a little bit of config info +#define NITRO_PCH 1 + +#include +#include +#include + +#include +#pragma comment(lib, "io-c++") +#pragma comment(lib, "io-c++") +#pragma comment(lib, "except-c++") +#pragma comment(lib, "sys-c++") +#pragma comment(lib, "str-c++") +#pragma comment(lib, "sio.lite-c++.lib") +#pragma comment(lib, "math-c++") +#pragma comment(lib, "mt-c++") + +#include +#include +#include +#include +#include + +#include "Test.h" + +#endif //PCH_H diff --git a/externals/nitro/modules/c++/cpp.h b/externals/nitro/modules/c++/cpp.h deleted file mode 100644 index 931c7632dd..0000000000 --- a/externals/nitro/modules/c++/cpp.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once - -#pragma warning(push) -#pragma warning(disable: 4619) // #pragma warning: there is no warning number '...' - -#pragma warning(disable: 4668) // '...' is not defined as a preprocessor macro, replacing with '...' for '...' -#pragma warning(disable: 4820) // '...': '...' bytes padding added after data member '...' -#pragma warning(disable: 4710) // '...': function not inlined - -#pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to 'extern "C"' function under - EHc.Undefined behavior may occur if this function throws an exception. -#pragma warning(disable: 5219) // implicit conversion from '...' to '...', possible loss of data -#pragma warning(disable: 4355) // '...': used in base member initializer list -#pragma warning(disable: 5220) // '...': a non - static data member with a volatile qualified type no longer implies -#pragma warning(disable: 5204) // '...': class has virtual functions, but its trivial destructor is not virtual; instances of objects derived from this class may not be destructed correctly -#pragma warning(disable: 4625) // '...': copy constructor was implicitly defined as deleted -#pragma warning(disable: 4626) // '...': assignment operator was implicitly defined as deleted -#pragma warning(disable: 5026) // '...': move constructor was implicitly defined as deleted -#pragma warning(disable: 5027) // '...': move assignment operator was implicitly defined as deleted -#pragma warning(disable: 5219) // implicit conversion from '...' to '...', possible loss of data -#pragma warning(disable: 6285) // ( || ) is always a non-zero constant. Did you intend to use the bitwise-and operator? -#pragma warning(disable: 5264) // '...': '...' variable is not used - -#define _USE_MATH_DEFINES -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#undef min -#undef max -#pragma warning(pop) diff --git a/externals/nitro/modules/c++/nitf-c++.vcxproj b/externals/nitro/modules/c++/nitf-c++.vcxproj index 7a96691719..bb2e908281 100644 --- a/externals/nitro/modules/c++/nitf-c++.vcxproj +++ b/externals/nitro/modules/c++/nitf-c++.vcxproj @@ -86,7 +86,6 @@ - @@ -219,7 +218,7 @@ true _DEBUG;%(PreprocessorDefinitions) true - $(ProjectDir)nitf\include\;$(ProjectDir)..\c\nrt\include\;$(ProjectDir)..\c\nitf\include\;$(ProjectDir)..\c\j2k\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\ + $(ProjectDir)nitf\include;$(ProjectDir)..\c\nrt\include;$(ProjectDir)..\c\nitf\include;$(ProjectDir)..\c\j2k\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include Use pch.h pch.h @@ -230,10 +229,11 @@ true EnableFastChecks Disabled - true - MultiThreadedDebugDLL true AdvancedVectorExtensions2 + true + MultiThreadedDebugDLL + true @@ -252,7 +252,7 @@ true NDEBUG;%(PreprocessorDefinitions) true - $(ProjectDir)nitf\include\;$(ProjectDir)..\c\nrt\include\;$(ProjectDir)..\c\nitf\include\;$(ProjectDir)..\c\j2k\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\ + $(ProjectDir)nitf\include;$(ProjectDir)..\c\nrt\include;$(ProjectDir)..\c\nitf\include;$(ProjectDir)..\c\j2k\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include Use pch.h pch.h @@ -262,6 +262,7 @@ true Level3 AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c++/nitf-c++.vcxproj.filters b/externals/nitro/modules/c++/nitf-c++.vcxproj.filters index 05d9a5eaaa..2ae0875ada 100644 --- a/externals/nitro/modules/c++/nitf-c++.vcxproj.filters +++ b/externals/nitro/modules/c++/nitf-c++.vcxproj.filters @@ -412,7 +412,6 @@ Header Files - Header Files diff --git a/externals/nitro/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj b/externals/nitro/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj index 1ab273b982..7e93ad84ad 100644 --- a/externals/nitro/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj +++ b/externals/nitro/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj @@ -51,7 +51,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - $(SolutionDir)modules\c\nrt\include\;$(SolutionDir)modules\c\nitf\include\;$(SolutionDir)modules\c\jpeg\include\;$(SolutionDir)modules\c\j2k\include\;$(SolutionDir)modules\c\cgm\include;$(SolutionDir)modules\c\;$(SolutionDir)modules\c++\;$(SolutionDir)modules\c++\nitf\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\ + $(SolutionDir)modules\c\nrt\include;$(SolutionDir)modules\c\nitf\include;$(SolutionDir)modules\c\jpeg\include;$(SolutionDir)modules\c\j2k\include;$(SolutionDir)modules\c\cgm\include;$(SolutionDir)modules\c;$(SolutionDir)modules\c++;$(SolutionDir)modules\c++\nitf\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include Use pch.h pch.h @@ -61,15 +61,16 @@ true EnableFastChecks Disabled - true MultiThreadedDebugDLL true AdvancedVectorExtensions2 + true + true Console true - $(SolutionDir)out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\lib\ + $(SolutionDir)out\install\$(Platform)-$(Configuration)\lib;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib @@ -79,7 +80,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - $(SolutionDir)modules\c\nrt\include\;$(SolutionDir)modules\c\nitf\include\;$(SolutionDir)modules\c\jpeg\include\;$(SolutionDir)modules\c\j2k\include\;$(SolutionDir)modules\c\cgm\include;$(SolutionDir)modules\c\;$(SolutionDir)modules\c++\;$(SolutionDir)modules\c++\nitf\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\ + $(SolutionDir)modules\c\nrt\include;$(SolutionDir)modules\c\nitf\include;$(SolutionDir)modules\c\jpeg\include;$(SolutionDir)modules\c\j2k\include;$(SolutionDir)modules\c\cgm\include;$(SolutionDir)modules\c;$(SolutionDir)modules\c++;$(SolutionDir)modules\c++\nitf\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include Use pch.h pch.h @@ -89,13 +90,14 @@ true Level3 AdvancedVectorExtensions2 + true Console true true true - $(SolutionDir)out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\lib\ + $(SolutionDir)out\install\$(Platform)-$(Configuration)\lib;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib diff --git a/externals/nitro/modules/c++/nitf/include/nitf/TREField.hpp b/externals/nitro/modules/c++/nitf/include/nitf/TREField.hpp index c6a0857153..56b18158f7 100644 --- a/externals/nitro/modules/c++/nitf/include/nitf/TREField.hpp +++ b/externals/nitro/modules/c++/nitf/include/nitf/TREField.hpp @@ -51,7 +51,7 @@ namespace nitf const_field(const_field&&) = default; const_field& operator=(const_field&&) = delete; - const T getFieldValue() const // "const" as a hint to clients that this value is really stored elsewhere + T getFieldValue() const { return tre_.getFieldValue(tag_); } @@ -78,7 +78,7 @@ namespace nitf { tre_.setFieldValue(field_.tag_, v, forceUpdate_); } - const T getFieldValue() const + T getFieldValue() const { return field_.getFieldValue(); } @@ -110,11 +110,11 @@ namespace nitf field_.setFieldValue(v); } - const value_type value() const // "const" as a hint to clients that this value is really stored elsewhere + value_type value() const { return field_.getFieldValue(); } - operator const value_type() const + operator value_type() const { return value(); } diff --git a/externals/nitro/modules/c++/nitf/include/nitf/coda-oss.hpp b/externals/nitro/modules/c++/nitf/include/nitf/coda-oss.hpp index bb4e9720ff..18467eac92 100644 --- a/externals/nitro/modules/c++/nitf/include/nitf/coda-oss.hpp +++ b/externals/nitro/modules/c++/nitf/include/nitf/coda-oss.hpp @@ -22,19 +22,16 @@ #pragma once -#if _MSC_VER -#pragma warning(disable: 5032) // detected #pragma warning(push) with no corresponding #pragma warning(pop) -#pragma warning(push) -#pragma warning(disable: 26487) // Don't return a pointer '...' that may be invalid (lifetime.4). -#pragma warning(disable: 5031) // #pragma warning(pop): likely mismatch, popping warning state pushed in different file -#endif // _MSC_VER +#include "config/disable_compiler_warnings.h" -#include // std::endian -#include // std::byte +#include "import/std.h" +#include +#include #include #include #include +CODA_OSS_disable_warning_push #if _MSC_VER #pragma warning(disable: 26432) // If you define or delete any default operation in the type '...', define or delete them all(c.21). #pragma warning(disable: 26447) // The function is declared '...' but calls function '..' which may throw exceptions (f.6). @@ -52,29 +49,17 @@ #include #include - #include #include -#if _MSC_VER -#pragma warning(push) -#pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to 'extern "C"' function under - EHc.Undefined behavior may occur if this function throws an exception. -#endif // _MSC_VER #include -#if _MSC_VER -#pragma warning(pop) -#endif // _MSC_VER #include - -#include -#include -#include +#include +#include #include -#include #include +#include #include - #include +#include -#if _MSC_VER -#pragma warning(pop) -#endif // _MSC_VER +CODA_OSS_disable_warning_pop diff --git a/externals/nitro/modules/c++/nitf/unittests/TestCase.h b/externals/nitro/modules/c++/nitf/unittests/TestCase.h deleted file mode 100644 index cc4ec42a37..0000000000 --- a/externals/nitro/modules/c++/nitf/unittests/TestCase.h +++ /dev/null @@ -1,117 +0,0 @@ -/* ========================================================================= - * This file is part of CODA-OSS - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * CODA-OSS 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 __TEST_CASE_H__ -#define __TEST_CASE_H__ -#pragma once - -#ifdef __cplusplus - -# include -# include -# include -# include -# include -# include -# include - -# define IS_NAN(X) X != X -# define TEST_CHECK(X) try{ X(std::string(#X)); std::cerr << #X << ": PASSED" << std::endl; } \ - catch(const except::Throwable& ex) { die_printf("%s: FAILED: Exception thrown: %s\n", std::string(#X).c_str(), ex.what()); } \ - catch(const std::exception& ex) { die_printf("%s: FAILED: Exception thrown: %s\n", std::string(#X).c_str(), ex.what()); } -# define TEST_ASSERT(X) if (!(X)) { die_printf("%s (%s,%s,%d): FAILED: Value should not be NULL\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } -# define TEST_ASSERT_NULL(X) if ((X) != nullptr) { die_printf("%s (%s,%s,%d): FAILED: Value should be NULL\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } -# define TEST_ASSERT_NOT_NULL(X) if ((X) == nullptr) { die_printf("%s (%s,%s,%d): FAILED: Value should not be NULL\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } -# define TEST_ASSERT_FALSE(X) if ((X)) { die_printf("%s (%s,%s,%d): FAILED: Value should evaluate to false\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } -# define TEST_ASSERT_TRUE(X) if (!(X)) { die_printf("%s (%s,%s,%d): FAILED: Value should evaluate to true\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } -# define TEST_ASSERT_EQ(X1, X2) if ((X1) != (X2)) { die_printf("%s (%s,%s,%d): FAILED: Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__, str::toString(X1).c_str(), str::toString(X2).c_str()); } -# define TEST_ASSERT_EQ_STR(X1, X2) TEST_ASSERT_EQ(std::string(X1), std::string(X2)) -# define TEST_ASSERT_EQ_MSG(msg, X1, X2) if ((X1) != (X2)) die_printf("%s (%s,%d): FAILED (%s): Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, __LINE__, (msg).c_str(), str::toString((X1)).c_str(), str::toString((X2)).c_str()); -# define TEST_ASSERT_NOT_EQ(X1, X2) if ((X1) == (X2)) { die_printf("%s (%s,%s,%d): FAILED: Recv'd %s should not equal %s\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__, str::toString(X1).c_str(), str::toString(X2).c_str()); } -# define TEST_ASSERT_NOT_EQ_MSG(msg, X1, X2) if ((X1) == (X2)) die_printf("%s (%s,%d): FAILED (%s): Recv'd %s should not equal %s\n", testName.c_str(), __FILE__, __LINE__, (msg).c_str(), str::toString((X1)).c_str(), str::toString((X2)).c_str()); -# define TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS) if (std::abs((X1) - (X2)) > EPS || IS_NAN(std::abs((X1) - (X2)))) die_printf("%s (%s,%d): FAILED: Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, __LINE__, str::toString((X1)).c_str(), str::toString((X2)).c_str()); -# define TEST_ASSERT_ALMOST_EQ(X1, X2) if (std::abs((X1) - (X2)) > std::numeric_limits::epsilon() || IS_NAN(std::abs((X1) - (X2)))) { die_printf("%s (%s,%s,%d): FAILED: Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__, str::toString(X1).c_str(), str::toString(X2).c_str()); } -# define TEST_ASSERT_GREATER_EQ(X1, X2) if ((X1) < X2) { die_printf("%s (%s,%s,%d): FAILED: Value should be greater than or equal\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } -# define TEST_ASSERT_GREATER(X1, X2) if ((X1) <= X2) { die_printf("%s (%s,%s,%d): FAILED: Value should be greater than\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } -# define TEST_ASSERT_LESSER_EQ(X1, X2) if ((X1) > X2) { die_printf("%s (%s,%s,%d): FAILED: Value should be less than or equal\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } -# define TEST_ASSERT_LESSER(X1, X2) if ((X1) >= X2) { die_printf("%s (%s,%s,%d): FAILED: Value should be less than\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } -# define TEST_FAIL(msg) die_printf("%s (%s,%s,%d): FAILED: %s\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__, str::toString(msg).c_str()); -# define TEST_EXCEPTION(X) try{ (X); die_printf("%s (%s,%s,%d): FAILED: Should have thrown exception\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } catch (const except::Throwable&){ TEST_ASSERT_TRUE(true); } catch (const std::exception&){ TEST_ASSERT_TRUE(true); } -# define TEST_THROWS(X) try{ (X); die_printf("%s (%s,%s,%d): FAILED: Should have thrown exception\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } catch (...){} -# define TEST_SPECIFIC_EXCEPTION(X,Y) try{ (X); die_printf("%s (%s,%s,%d): FAILED: Should have thrown exception: " # Y , testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } catch(const Y&) { } \ - catch (const except::Throwable&){ die_printf("%s (%s,%s,%d): FAILED: Should have thrown exception: " # Y , testName.c_str(), __FILE__, SYS_FUNC, __LINE__);} \ - catch (const std::exception&){ die_printf("%s (%s,%s,%d): FAILED: Should have thrown exception: " # Y , testName.c_str(), __FILE__, SYS_FUNC, __LINE__);} -# define TEST_CASE(X) void X(std::string testName) - -#define TEST_MAIN(X) int main(int argc, char** argv) { try { X; return EXIT_SUCCESS; } \ - catch (const except::Exception& ex) { std::cerr << ex.toString() << std::endl; } \ - catch (const std::exception& e) { std::cerr << e.what() << std::endl; } \ - catch (...) { std::cerr << "Unknown exception\n"; } \ - return EXIT_FAILURE; } - -#else /* C only */ -# include -# include -# include -# include - -/* Copied from sys/Conf.h */ -# define TEST_FILE __FILE__ -# define TEST_LINE __LINE__ -# if defined(__GNUC__) -# define TEST_FUNC __PRETTY_FUNCTION__ -# elif __STDC_VERSION__ < 199901 -# define TEST_FUNC "unknown function" -# else /* Should be c99 */ -# define TEST_FUNC __func__ -# endif - -# define TEST_CHECK(X) X(#X); fprintf(stderr, "%s : PASSED\n", #X); -# define TEST_CHECK_ARGS(X) X(#X,argc,argv); fprintf(stderr, "%s : PASSED\n", #X); -# define TEST_ASSERT(X) if (!(X)) { \ - fprintf(stderr, "%s (%s,%s,%d) : FAILED: Value should not be NULL\n", testName, TEST_FILE, TEST_FUNC, TEST_LINE); \ - exit(EXIT_FAILURE); \ -} -# define TEST_ASSERT_NULL(X) if ((X) != NULL) { \ - fprintf(stderr, "%s (%s,%s,%d) : FAILED: Value should be NULL\n", testName, TEST_FILE, TEST_FUNC, TEST_LINE); \ - exit(EXIT_FAILURE); \ -} -# define TEST_ASSERT_EQ_STR(X1, X2) if (strcmp((X1), (X2)) != 0) { \ - fprintf(stderr, "%s (%s,%s,%d) : FAILED: Recv'd %s, Expected %s\n", testName, TEST_FILE, TEST_FUNC, TEST_LINE, X1, X2); \ - exit(EXIT_FAILURE); \ -} -# define TEST_ASSERT_EQ_INT(X1, X2) if ((X1) != (X2)) { \ - fprintf(stderr, "%s (%s,%s,%d) : FAILED: Recv'd %d, Expected %d\n", testName, TEST_FILE, TEST_FUNC, TEST_LINE, (int)X1, (int)X2); \ - exit(EXIT_FAILURE); \ -} -/* TODO use epsilon for comparing floating points */ -# define TEST_ASSERT_EQ_FLOAT(X1, X2) if (fabs((X1) - (X2)) > .0000001f) { \ - fprintf(stderr, "%s (%s,%s,%d) : FAILED: Recv'd %f, Expected %f\n", testName, TEST_FILE, TEST_FUNC, TEST_LINE, X1, X2); \ - exit(EXIT_FAILURE); \ -} - -# define TEST_CASE(X) void X(const char* testName) -# define TEST_CASE_ARGS(X) void X(const char* testName, int argc, char **argv) - -#endif - -#endif diff --git a/externals/nitro/modules/c++/nitf/unittests/test_create_nitf++.cpp b/externals/nitro/modules/c++/nitf/unittests/test_create_nitf++.cpp index 23a02686df..10bf65413d 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_create_nitf++.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_create_nitf++.cpp @@ -41,6 +41,7 @@ #include #include +#include CODA_OSS_disable_warning_push #if _MSC_VER @@ -150,6 +151,8 @@ static void test_create_nitf_with_byte_provider__addImageSegment(nitf::Record& r // a file in the j2k plugin. To make this test run, go to the file // and disable the check for blocking mode B. // To the best of my knowledge, nothing bad happens as a result. + const auto pNitroImage = getNitroImage(); + const auto& NITRO_IMAGE = *pNitroImage; header.setBlocking(NITRO_IMAGE.height, /*!< The number of rows */ NITRO_IMAGE.width, /*!< The number of columns */ NITRO_IMAGE.height, /*!< The number of rows/block */ @@ -176,6 +179,8 @@ static void test_create_nitf_with_byte_provider__writeNITF(nitf::Record& record, * Once you have CompressedByteProvider constructed, everything else * should work the same */ + const auto pNitroImage = getNitroImage(); + const auto& NITRO_IMAGE = *pNitroImage; const std::vector > bytesPerBlock{ { static_cast(NITRO_IMAGE.width) * NITRO_IMAGE.height * NUM_BANDS } }; nitf::CompressedByteProvider byteProvider(record, bytesPerBlock); nitf::Off fileOffset; @@ -212,6 +217,8 @@ static bool test_create_nitf_with_byte_provider__testRead(const std::string& pat // Read one block. It should match the first blockSize points of the // image. If it does, we got the blocking mode right. auto block = reinterpret_cast(imageReader.readBlock(0, &blockSize)); + const auto pNitroImage = getNitroImage(); + const auto& NITRO_IMAGE = *pNitroImage; const size_t imageLength = static_cast(NITRO_IMAGE.width) * NITRO_IMAGE.height; for (size_t jj = 0; jj < imageLength * NUM_BANDS; ++jj) @@ -228,6 +235,8 @@ static bool test_create_nitf_with_byte_provider__testRead(const std::string& pat TEST_CASE(test_create_nitf_with_byte_provider_test) { + nitf::Test::setNitfPluginPath(); + // We can't actually compress. This is just for illustration. const bool shouldCompress = false; const std::string outname("test_create.nitf"); @@ -286,6 +295,8 @@ static void test_create_nitf__addImageSegment(nitf::Record& record, bool isMono // a file in the j2k plugin. To make this test run, go to the file // and disable the check for blocking mode B. // To the best of my knowledge, nothing bad happens as a result. + const auto pNitroImage = getNitroImage(); + const auto& NITRO_IMAGE = *pNitroImage; header.setBlocking(NITRO_IMAGE.height, /*!< The number of rows */ NITRO_IMAGE.width, /*!< The number of columns */ NITRO_IMAGE.height, /*!< The number of rows/block */ @@ -305,6 +316,9 @@ static void test_create_nitf__writeNITF(nitf::Record& record, const std::string& nitf::ImageWriter imageWriter = writer.newImageWriter(0); nitf::ImageSource imageSource; + const auto pNitroImage = getNitroImage(); + const auto& NITRO_IMAGE = *pNitroImage; + /* make one bandSource per band */ for (int ii = 0; ii < NUM_BANDS; ++ii) { @@ -339,6 +353,9 @@ static bool test_create_nitf__testRead(const std::string& pathname, bool isMono nitf::Reader reader; nitf::Record record = reader.read(handle); + const auto pNitroImage = getNitroImage(); + const auto& NITRO_IMAGE = *pNitroImage; + for (int ii = 0; ii < static_cast(record.getNumImages()); ++ii) { nitf::ImageReader imageReader = reader.newImageReader(ii); @@ -380,6 +397,8 @@ static bool test_create_nitf__testRead(const std::string& pathname, bool isMono TEST_CASE(test_create_nitf_test) { + nitf::Test::setNitfPluginPath(); + const std::string outname("test_create.nitf"); @@ -414,7 +433,7 @@ TEST_CASE(test_create_nitf_test) } else { - TEST_ASSERT_TRUE(true); + TEST_FAIL_MSG("NITF_PLUGIN_PATH not set"); } } @@ -455,7 +474,9 @@ static void RecordThread_run() TEST_CASE(test_mt_record) { - const int NTHR = 2; + nitf::Test::setNitfPluginPath(); + + constexpr int NTHR = 2; std::array thrs; try @@ -483,8 +504,6 @@ TEST_CASE(test_mt_record) TEST_MAIN( - (void)argc; - (void)argv; TEST_CHECK(test_create_nitf_with_byte_provider_test); TEST_CHECK(test_create_nitf_test); TEST_CHECK(test_mt_record); diff --git a/externals/nitro/modules/c++/nitf/unittests/test_field++.cpp b/externals/nitro/modules/c++/nitf/unittests/test_field++.cpp index 75b9037012..68ea8e8b26 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_field++.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_field++.cpp @@ -113,8 +113,6 @@ TEST_CASE(testDescriptors) } TEST_MAIN( - (void)argc; - (void)argv; TEST_CHECK(testCastOperator); TEST_CHECK(testDescriptors); ) diff --git a/externals/nitro/modules/c++/nitf/unittests/test_image_blocker.cpp b/externals/nitro/modules/c++/nitf/unittests/test_image_blocker.cpp index 189e331fab..f08d71198a 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_image_blocker.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_image_blocker.cpp @@ -475,9 +475,6 @@ TEST_CASE(testBlockPartialImage) } TEST_MAIN( - (void)argc; - (void)argv; - TEST_CHECK(testSingleSegmentNoLeftovers); TEST_CHECK(testSingleSegmentPadCols); TEST_CHECK(testSingleSegmentPadRowsAndPadCols); diff --git a/externals/nitro/modules/c++/nitf/unittests/test_image_loading++.cpp b/externals/nitro/modules/c++/nitf/unittests/test_image_loading++.cpp index be3e035696..70797983a8 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_image_loading++.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_image_loading++.cpp @@ -31,8 +31,6 @@ using path = std::filesystem::path; #include "TestCase.h" -static std::string testName; - static path findInputFile() { static const auto unittests = path("modules") / "c++" / "nitf" / "unittests"; @@ -69,12 +67,13 @@ struct expected_values final int luts = 0; }; -static void writeImage(nitf::ImageSegment &segment, - nitf::Reader &reader, - const int imageNumber, - const std::string& imageName, - uint32_t rowSkipFactor, - uint32_t columnSkipFactor, bool optz, +static void writeImage(const std::string& testName, + nitf::ImageSegment& segment, + nitf::Reader& reader, + const int imageNumber, + const std::string& imageName, + uint32_t rowSkipFactor, + uint32_t columnSkipFactor, bool optz, const expected_values& expected) { nitf::ImageReader deserializer = reader.newImageReader(imageNumber); @@ -175,7 +174,8 @@ static void writeImage(nitf::ImageSegment &segment, } } -static void test_image_loading_(const std::string& input_file, bool optz, const expected_values& expected) +static void test_image_loading_(const std::string& testName, + const std::string& input_file, bool optz, const expected_values& expected) { /* Skip factors */ uint32_t rowSkipFactor = 1; @@ -200,7 +200,8 @@ static void test_image_loading_(const std::string& input_file, bool optz, const nitf::ImageSegment imageSegment(iter.get()); /* Write the thing out */ - writeImage(imageSegment, reader, count, input_file, + writeImage(testName, + imageSegment, reader, count, input_file, rowSkipFactor, columnSkipFactor, optz, expected); } } @@ -217,8 +218,8 @@ TEST_CASE(test_image_loading) expected.pixelsPerHorizBlock = expected.nCols; expected.pixelsPerVertBlock = expected.nRows; - test_image_loading_(input_file, false /*optz*/, expected); - test_image_loading_(input_file, true /*optz*/, expected); + test_image_loading_(testName, input_file, false /*optz*/, expected); + test_image_loading_(testName, input_file, true /*optz*/, expected); } TEST_CASE(test_8bit_image_loading) @@ -233,12 +234,12 @@ TEST_CASE(test_8bit_image_loading) expected.pixelsPerHorizBlock = expected.nCols; expected.pixelsPerVertBlock = expected.nRows; - test_image_loading_(input_file, false /*optz*/, expected); - test_image_loading_(input_file, true /*optz*/, expected); + test_image_loading_(testName, input_file, false /*optz*/, expected); + test_image_loading_(testName, input_file, true /*optz*/, expected); input_file = findInputFile(false /*withAmpTable*/).string(); - test_image_loading_(input_file, false /*optz*/, expected); - test_image_loading_(input_file, true /*optz*/, expected); + test_image_loading_(testName, input_file, false /*optz*/, expected); + test_image_loading_(testName, input_file, true /*optz*/, expected); } TEST_MAIN( diff --git a/externals/nitro/modules/c++/nitf/unittests/test_image_segment_blank_nm_compression.cpp b/externals/nitro/modules/c++/nitf/unittests/test_image_segment_blank_nm_compression.cpp index 8cff7624ff..c8552739fd 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_image_segment_blank_nm_compression.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_image_segment_blank_nm_compression.cpp @@ -255,7 +255,7 @@ TEST_CASE(testBlankSegmentsValid) imageDataOffset, blockRecordLength, padRecordLength, padPixelValueLength, padValue, blockMask, padMask) != 0); - TEST_ASSERT_GREATER(blockRecordLength, 0u); + TEST_ASSERT_GREATER_EQ(blockRecordLength, 1u); const int64_t totalBlocks = blockingInfo.getNumBlocksPerRow()*blockingInfo.getNumBlocksPerCol(); TEST_ASSERT_GREATER(totalBlocks, 0); @@ -279,7 +279,5 @@ TEST_CASE(testBlankSegmentsValid) } TEST_MAIN( - (void)argc; - (void)argv; TEST_CHECK(testBlankSegmentsValid); ) diff --git a/externals/nitro/modules/c++/nitf/unittests/test_image_segment_computer.cpp b/externals/nitro/modules/c++/nitf/unittests/test_image_segment_computer.cpp index 26c952b9ad..3d47d49681 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_image_segment_computer.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_image_segment_computer.cpp @@ -216,9 +216,6 @@ TEST_CASE(testKnownCase) TEST_MAIN ( - (void)argc; - (void)argv; - TEST_CHECK(testBlockSizedBoundaries); TEST_CHECK(testPerfectSplitting); TEST_CHECK(testOneRowOver); diff --git a/externals/nitro/modules/c++/nitf/unittests/test_image_writer.cpp b/externals/nitro/modules/c++/nitf/unittests/test_image_writer.cpp index 37645649da..76e315a8e2 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_image_writer.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_image_writer.cpp @@ -107,8 +107,6 @@ TEST_CASE(changeFileHeader) } TEST_MAIN( - (void)argc;(void)argv; - TEST_CHECK(imageWriterThrowsOnFailedConstruction); TEST_CHECK(constructValidImageWriter); TEST_CHECK(changeFileHeader); diff --git a/externals/nitro/modules/c++/nitf/unittests/test_j2k_compress_tile.cpp b/externals/nitro/modules/c++/nitf/unittests/test_j2k_compress_tile.cpp index fe9736266f..dedefd5ce4 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_j2k_compress_tile.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_j2k_compress_tile.cpp @@ -226,7 +226,7 @@ TEST_CASE(j2k_compress_tile) } } -TEST_MAIN((void)argc; (void)argv; +TEST_MAIN( TEST_CHECK(j2k_compress_tile); ) diff --git a/externals/nitro/modules/c++/nitf/unittests/test_j2k_compressed_byte_provider.cpp b/externals/nitro/modules/c++/nitf/unittests/test_j2k_compressed_byte_provider.cpp index 100cc7382f..efd377469b 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_j2k_compressed_byte_provider.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_j2k_compressed_byte_provider.cpp @@ -54,8 +54,6 @@ #include "TestCase.h" -static std::string testName; - static void setCornersFromDMSBox(nitf::ImageSubheader& header) { /* @@ -631,7 +629,14 @@ TEST_CASE(j2k_compressed_byte_provider) } } -TEST_MAIN((void)argc;(void)argv; +TEST_CASE(j2k_do_nothing) +{ + /* placeholder */ + TEST_ASSERT_TRUE(true); +} + +TEST_MAIN( + TEST_CHECK(j2k_do_nothing); //TEST_CHECK(j2k_compressed_byte_provider_maxRowsPerSegment0); // TODO: get working with CMake //TEST_CHECK(j2k_compressed_byte_provider); // TODO: get working with CMake ) \ No newline at end of file diff --git a/externals/nitro/modules/c++/nitf/unittests/test_j2k_loading++.cpp b/externals/nitro/modules/c++/nitf/unittests/test_j2k_loading++.cpp index fec7449b18..22de200df8 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_j2k_loading++.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_j2k_loading++.cpp @@ -59,8 +59,6 @@ #include -static std::string testName; - static auto findInputFile(const std::filesystem::path& fn) { static const auto unittests = std::filesystem::path("modules") / "c++" / "nitf" / "unittests"; @@ -112,7 +110,8 @@ TEST_CASE(test_j2k_loading) TEST_ASSERT_TRUE(true); // be sure hidden "testName" parameter is used } -static void test_j2k_nitf_(const std::string& fname) +static void test_j2k_nitf_(const std::string& testName, + const std::string& fname) { nitf::IOHandle io(fname); nitf::Reader reader; @@ -163,7 +162,7 @@ TEST_CASE(test_j2k_nitf) // This is a JP2 file, not J2K; see OpenJPEG_setup_() const auto input_file = findInputFile("j2k_compressed_file1_jp2.ntf").string(); - test_j2k_nitf_(input_file); + test_j2k_nitf_(testName, input_file); } void writeFile(uint32_t x0, uint32_t y0, @@ -206,7 +205,8 @@ void writeJ2K(uint32_t x0, uint32_t y0, writer.write(outIO); //printf("Wrote file: %s\n", outName.c_str()); } -void test_j2k_nitf_read_region_(const std::filesystem::path& fname) +void test_j2k_nitf_read_region_(const std::string& testName, + const std::filesystem::path& fname) { nitf::IOHandle io(fname.string(), NRT_ACCESS_READONLY, NRT_OPEN_EXISTING); nitf::Reader reader; @@ -281,12 +281,13 @@ TEST_CASE(test_j2k_nitf_read_region) { // This is a JP2 file, not J2K; see OpenJPEG_setup_() const auto input_file = findInputFile("j2k_compressed_file1_jp2.ntf"); - test_j2k_nitf_read_region_(input_file); + test_j2k_nitf_read_region_(testName, input_file); TEST_ASSERT_TRUE(true); // be sure hidden "testName" parameter is used } -static std::vector readImage(nitf::ImageReader& imageReader, const nitf::ImageSubheader& imageSubheader) +static std::vector readImage(const std::string& testName, + nitf::ImageReader& imageReader, const nitf::ImageSubheader& imageSubheader) { const auto numBlocks = imageSubheader.numBlocksPerRow() * imageSubheader.numBlocksPerCol(); TEST_ASSERT_GREATER(static_cast(numBlocks), 0); @@ -308,7 +309,8 @@ static std::vector readImage(nitf::ImageReader& imageReader, const ni } return retval; } -static void test_decompress_nitf_to_sio_(const std::filesystem::path& inputPathname, const std::filesystem::path& outputPathname) +static void test_decompress_nitf_to_sio_(const std::string& testName, + const std::filesystem::path& inputPathname, const std::filesystem::path& outputPathname) { // Take a J2K-compressed NITF, decompress the image and save to an SIO. nitf::Reader reader; @@ -319,7 +321,7 @@ static void test_decompress_nitf_to_sio_(const std::filesystem::path& inputPathn const auto imageSubheader = imageSegment.getSubheader(); auto imageReader = reader.newImageReader(0 /*imageSegmentNumber*/); - const auto imageData = readImage(imageReader, imageSubheader); + const auto imageData = readImage(testName, imageReader, imageSubheader); const sys::filesystem::path outputPathname_ = outputPathname.string(); sio::lite::writeSIO(imageData.data(), imageSubheader.dims(), outputPathname_); @@ -329,7 +331,7 @@ TEST_CASE(test_j2k_decompress_nitf_to_sio) nitf::Test::j2kSetNitfPluginPath(); const auto inputPathname = findInputFile("j2k_compressed_file1_jp2.ntf"); // This is a JP2 file, not J2K; see OpenJPEG_setup_() - test_decompress_nitf_to_sio_(inputPathname, "test_decompress_nitf.sio"); + test_decompress_nitf_to_sio_(testName, inputPathname, "test_decompress_nitf.sio"); TEST_ASSERT_TRUE(true); // be sure hidden "testName" parameter is used } @@ -340,7 +342,7 @@ TEST_CASE(test_j2k_compress_raw_image) const auto inputPathname = findInputFile("j2k_compressed_file1_jp2.ntf"); // This is a JP2 file, not J2K; see OpenJPEG_setup_() const std::filesystem::path outputPathname = "test_j2k_compress_raw_image.sio"; - test_decompress_nitf_to_sio_(inputPathname, outputPathname); + test_decompress_nitf_to_sio_(testName, inputPathname, outputPathname); // --------------------------------------------------------------------------------------- // J2K compresses the raw image data of an SIO file diff --git a/externals/nitro/modules/c++/nitf/unittests/test_j2k_read_tile.cpp b/externals/nitro/modules/c++/nitf/unittests/test_j2k_read_tile.cpp index f08b268dd2..1cf1c1d888 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_j2k_read_tile.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_j2k_read_tile.cpp @@ -31,8 +31,6 @@ TEST_CASE(j2k_read_tile) } TEST_MAIN( - (void)argc; - (void)argv; TEST_CHECK(j2k_read_tile); ) diff --git a/externals/nitro/modules/c++/nitf/unittests/test_load_plugins.cpp b/externals/nitro/modules/c++/nitf/unittests/test_load_plugins.cpp index fd6762ca16..4aaee43ca9 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_load_plugins.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_load_plugins.cpp @@ -26,12 +26,11 @@ #include #include +#include #include "TestCase.h" -static std::string testName; - -static void load_plugin(const char* tre) +static void load_plugin(const std::string& testName, const char* tre) { nitf_Error error; @@ -75,36 +74,52 @@ static const std::vector& all_plugins() TEST_CASE(test_load_all_plugins_C) { + nitf::Test::setNitfPluginPath(); + for (const auto& tre : all_plugins()) { - load_plugin(tre.c_str()); + load_plugin(testName, tre.c_str()); } } TEST_CASE(test_load_PTPRAA) { - load_plugin("PTPRAA"); + nitf::Test::setNitfPluginPath(); + load_plugin(testName, "PTPRAA"); } TEST_CASE(test_load_ENGRDA) { - load_plugin("ENGRDA"); + nitf::Test::setNitfPluginPath(); + load_plugin(testName, "ENGRDA"); } -TEST_CASE(test_load_all_plugins) +static void loadPlugin(const std::string& testName, const std::string& path) { - for (const auto& tre : all_plugins()) + try { #ifdef _WIN32 // need the full path to load on Linux - nitf::PluginRegistry::loadPlugin(tre); + nitf::PluginRegistry::loadPlugin(path); #endif + TEST_SUCCESS; + } + catch (const nitf::NITFException& ex) + { + TEST_FAIL_MSG(ex.toString()); + } +} +TEST_CASE(test_load_all_plugins) +{ + nitf::Test::setNitfPluginPath(); + + for (const auto& tre : all_plugins()) + { + loadPlugin(testName, tre); TEST_ASSERT(nitf::PluginRegistry::treHandlerExists(tre)); } } TEST_MAIN( - (void)argc; - (void)argv; TEST_CHECK(test_load_PTPRAA); TEST_CHECK(test_load_ENGRDA); TEST_CHECK(test_load_all_plugins_C); diff --git a/externals/nitro/modules/c++/nitf/unittests/test_nitf_buffer_list.cpp b/externals/nitro/modules/c++/nitf/unittests/test_nitf_buffer_list.cpp index 06a07dfa61..889d904463 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_nitf_buffer_list.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_nitf_buffer_list.cpp @@ -177,8 +177,6 @@ TEST_CASE(testGetBlock_std_byte) } TEST_MAIN( - (void)argc; - (void)argv; TEST_CHECK(testGetNumBlocks); TEST_CHECK(testGetBlock_sys_byte); TEST_CHECK(testGetBlock_std_byte); diff --git a/externals/nitro/modules/c++/nitf/unittests/test_tre_create++.cpp b/externals/nitro/modules/c++/nitf/unittests/test_tre_create++.cpp index 9883132a0b..9ffe050005 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_tre_create++.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_tre_create++.cpp @@ -43,7 +43,6 @@ TEST_CASE(test_tre_clone_329) } TEST_MAIN( - (void)argv; (void)argc; TEST_CHECK(test_tre_create_329); TEST_CHECK(test_tre_clone_329); ) diff --git a/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp b/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp index 02e5a20858..8eb85006b1 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_tre_mods++.cpp @@ -418,8 +418,6 @@ TEST_CASE(overflowingNumericFields) } TEST_MAIN( - (void)argv; (void)argc; - TEST_CHECK(setFields); TEST_CHECK(setBinaryFields); TEST_CHECK(cloneTRE); diff --git a/externals/nitro/modules/c++/nitf/unittests/test_tre_mods.cpp b/externals/nitro/modules/c++/nitf/unittests/test_tre_mods.cpp index 1f0ebff570..be2517963e 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_tre_mods.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_tre_mods.cpp @@ -247,9 +247,6 @@ TEST_CASE(populateWhileIterating) } TEST_MAIN( - (void) argc; - (void) argv; - TEST_CHECK(testClone); TEST_CHECK(testSize); TEST_CHECK(testBasicMod); diff --git a/externals/nitro/modules/c++/nitf/unittests/test_tre_read.cpp b/externals/nitro/modules/c++/nitf/unittests/test_tre_read.cpp index 183cc048ea..8050f361e6 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_tre_read.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_tre_read.cpp @@ -91,7 +91,6 @@ files, this bug may allow an attacker to cause a denial of service. */ -static std::string testName; const char* output_file = "test_writer_3++.nitf"; static std::filesystem::path findInputFile_(const std::string& name) @@ -277,8 +276,6 @@ TEST_CASE(test_nitf_CSEXRB_bugfix) } TEST_MAIN( - (void)argc; (void)argv; - TEST_CHECK(test_nitf_Record_unmergeTREs_crash); // 2 TEST_CHECK(test_defaultRead_crash); // 3 TEST_CHECK(test_readBandInfo_crash); // 4 diff --git a/externals/nitro/modules/c++/nitf/unittests/test_writer_3++.cpp b/externals/nitro/modules/c++/nitf/unittests/test_writer_3++.cpp index b7fa3c88f5..d2955dd26d 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_writer_3++.cpp +++ b/externals/nitro/modules/c++/nitf/unittests/test_writer_3++.cpp @@ -31,29 +31,15 @@ #include "TestCase.h" -static std::string testName; const std::string output_file = "test_writer_3++.nitf"; using path = std::filesystem::path; -static std::string argv0; static path findInputFile() { - const auto inputFile = path("modules") / "c++" / "nitf" / "unittests" / "sicd_50x50.nitf"; - - path root; - if (argv0.empty()) - { - // running in Visual Studio - root = std::filesystem::current_path().parent_path().parent_path(); - } - else - { - root = absolute(path(argv0)).parent_path().parent_path().parent_path().parent_path(); - root = root.parent_path().parent_path(); - } - - return root / inputFile; + static const auto unittests = path("modules") / "c++" / "nitf" / "unittests"; + static const auto inputPath = nitf::Test::findInputFile(unittests, "sicd_50x50.nitf"); + return inputPath; } static std::string makeBandName(const std::string& rootFile, int imageNum, int bandNum) @@ -112,10 +98,8 @@ static void doWrite(const nitf::Record& record_, nitf::Reader& reader, const std writer.write(); } -static void manuallyWriteImageBands(nitf::ImageSegment & segment, - const std::string& imageName, - nitf::ImageReader& deserializer, - int imageNumber) +static void manuallyWriteImageBands(const std::string& testName, + nitf::ImageSegment& segment, const std::string& imageName, nitf::ImageReader& deserializer, int imageNumber) { int padded; @@ -188,7 +172,8 @@ static void manuallyWriteImageBands(nitf::ImageSegment & segment, handles[i].close(); } -static nitf::Record doRead(const std::string& inFile, nitf::Reader& reader) +static nitf::Record doRead(const std::string& testName, + const std::string& inFile, nitf::Reader& reader) { // Check that wew have a valid NITF const auto version = nitf::Reader::getNITFVersion(inFile); @@ -207,7 +192,7 @@ static nitf::Record doRead(const std::string& inFile, nitf::Reader& reader) nitf::ImageReader deserializer = reader.newImageReader(count); /* Write the thing out */ - manuallyWriteImageBands(imageSegment, inFile, deserializer, count); + manuallyWriteImageBands(testName, imageSegment, inFile, deserializer, count); } return record; @@ -234,7 +219,7 @@ TEST_CASE(test_writer_3_) const auto input_file = findInputFile().string(); nitf::Reader reader; - nitf::Record record = doRead(input_file, reader); + nitf::Record record = doRead(testName, input_file, reader); test_writer_3__doWrite(record, reader, input_file, output_file); } @@ -249,7 +234,8 @@ TEST_CASE(test_writer_3_) * if the data does not fill the block. * */ -static void test_buffered_write__doWrite(nitf::Record record, nitf::Reader& reader, +static void test_buffered_write__doWrite(const std::string& testName, + nitf::Record record, nitf::Reader& reader, const std::string& inRootFile, const std::string& outFile, size_t bufferSize) @@ -273,14 +259,13 @@ TEST_CASE(test_buffered_write_) size_t blockSize = 8192; nitf::Reader reader; - nitf::Record record = doRead(input_file, reader); - test_buffered_write__doWrite(record, reader, input_file, output_file, blockSize); + nitf::Record record = doRead(testName, input_file, reader); + test_buffered_write__doWrite(testName, + record, reader, input_file, output_file, blockSize); } TEST_MAIN( - (void)argc; - argv0 = argv[0]; TEST_CHECK(test_writer_3_); TEST_CHECK(test_buffered_write_); ) \ No newline at end of file diff --git a/externals/nitro/modules/c++/pch.h b/externals/nitro/modules/c++/pch.h index a969486e3c..2d5aa61256 100644 --- a/externals/nitro/modules/c++/pch.h +++ b/externals/nitro/modules/c++/pch.h @@ -1,5 +1,36 @@ #pragma once +#include "coda_oss/CPlusPlus.h" +#include "config/disable_compiler_warnings.h" + +CODA_OSS_disable_warning_system_header_push + +#define _USE_MATH_DEFINES +#include +#include +#include +#include +#include +#include +#include +#include + +CODA_OSS_disable_warning_pop + +#include "import/std.h" +#include +#include +#include +#include +#include + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define NOMINMAX +#pragma warning(push) +#pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception. +#include +#pragma warning(pop) + #pragma warning(disable: 4619) // #pragma warning: there is no warning number '...' #pragma warning(disable: 4820) // '...': '...' bytes padding added after data member '...' #pragma warning(disable: 4710) // '...': function not inlined @@ -10,27 +41,17 @@ #pragma warning(disable: 4514) // '...': unreferenced inline function has been removed #pragma warning(disable: 26823) // Dereferencing a possibly null pointer '...' (lifetime.1). -#include "cpp.h" -#pragma comment(lib, "ws2_32") - #pragma warning(disable: 26822) // Dereferencing a null pointer '...' (lifetime.1). #pragma warning(disable: 26467) // Converting from floating point to unsigned integral types results in non-portable code if the double/float has a negative value. Use gsl::narrow_cast or gsl::narrow instead to guard against undefined behavior and potential data loss(es.46). // changing this breaks SWIG #pragma warning (disable: 26812) // The enum type '...' is unscoped. Prefer '...' over '...' -#include "nitf/coda-oss.hpp" - -#pragma comment(lib, "io-c++") -#pragma comment(lib, "except-c++") -#pragma comment(lib, "sys-c++") -#pragma comment(lib, "str-c++") -#pragma comment(lib, "mt-c++") -#pragma comment(lib, "math-c++") - // We're building in Visual Studio ... used to control where we get a little bit of config info #define NITRO_PCH 1 +// Yes, these are our files ... but they don't change very often, and if they do +// change we want to rebuild everything anyway. #include "import/nitf.h" #include "nitf/ImageIO.h" #include "nitf/System.h" @@ -49,4 +70,15 @@ #pragma warning(disable: 26486) // Don't pass a pointer that may be invalid to a function. Parameter '...' in call to '...' may be invalid (lifetime.3). #pragma warning(disable: 26487) // Don't return a pointer '...' that may be invalid(lifetime.4). +// Yes, these are our files ... but they don't change very often, and if they do +// change we want to rebuild everything anyway. #include "nitf/Object.hpp" +#include "nitf/Handle.hpp" + +#include "nitf/coda-oss.hpp" +#pragma comment(lib, "io-c++") +#pragma comment(lib, "except-c++") +#pragma comment(lib, "sys-c++") +#pragma comment(lib, "str-c++") +#pragma comment(lib, "mt-c++") +#pragma comment(lib, "math-c++") \ No newline at end of file diff --git a/externals/nitro/modules/c/j2k/J2KCompress.vcxproj b/externals/nitro/modules/c/j2k/J2KCompress.vcxproj index 80e6ea5317..bb15eb1491 100644 --- a/externals/nitro/modules/c/j2k/J2KCompress.vcxproj +++ b/externals/nitro/modules/c/j2k/J2KCompress.vcxproj @@ -70,12 +70,12 @@ /FS %(AdditionalOptions) true CompileAsCpp - true Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/j2k/J2KDecompress.vcxproj b/externals/nitro/modules/c/j2k/J2KDecompress.vcxproj index 2010203c4d..1c1a018e37 100644 --- a/externals/nitro/modules/c/j2k/J2KDecompress.vcxproj +++ b/externals/nitro/modules/c/j2k/J2KDecompress.vcxproj @@ -70,12 +70,12 @@ /FS %(AdditionalOptions) true CompileAsCpp - true Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/j2k/source/OpenJPEGImpl.c b/externals/nitro/modules/c/j2k/source/OpenJPEGImpl.c index 7dd0999b32..11687c50f2 100644 --- a/externals/nitro/modules/c/j2k/source/OpenJPEGImpl.c +++ b/externals/nitro/modules/c/j2k/source/OpenJPEGImpl.c @@ -281,10 +281,16 @@ OpenJPEG_cleanup(opj_stream_t **stream, opj_codec_t **codec, /******************************************************************************/ // these are private to cio.h +#if __cplusplus +extern "C" { +#endif extern OPJ_OFF_T opj_stream_tell(const opj_stream_t*); extern int opj_stream_read_seek(opj_stream_t*, OPJ_OFF_T p_size, void* p_event_mgr); extern OPJ_SIZE_T opj_stream_read_data(opj_stream_t*, OPJ_BYTE* p_buffer, OPJ_SIZE_T p_size, void* p_event_mgr); extern OPJ_OFF_T opj_stream_get_number_byte_left(const opj_stream_t*); +#if __cplusplus +} +#endif // This is our own to distingish an error from an expected failure OPJ_CODEC_FORMAT nitf_OPJ_CODEC_ERROR_ = (OPJ_CODEC_FORMAT)(OPJ_CODEC_UNKNOWN - 1); // i.e., -2 diff --git a/externals/nitro/modules/c/nitf-c.vcxproj b/externals/nitro/modules/c/nitf-c.vcxproj index 45fa8fa678..eb3b5ad7a4 100644 --- a/externals/nitro/modules/c/nitf-c.vcxproj +++ b/externals/nitro/modules/c/nitf-c.vcxproj @@ -52,7 +52,7 @@ true _DEBUG;%(PreprocessorDefinitions);HAVE_OPENJPEG_H true - $(ProjectDir)nrt\include\;$(ProjectDir)nitf\include\;$(ProjectDir)jpeg\include\;$(ProjectDir)j2k\include\;$(ProjectDir)cgm\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\;%(AdditionalIncludeDirectories) + $(ProjectDir)nrt\include;$(ProjectDir)nitf\include;$(ProjectDir)jpeg\include;$(ProjectDir)j2k\include;$(ProjectDir)cgm\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include;%(AdditionalIncludeDirectories) Use pch.h pch.h @@ -62,10 +62,13 @@ true EnableFastChecks Disabled - MultiThreadedDebugDLL true - true AdvancedVectorExtensions2 + CompileAsCpp + false + true + MultiThreadedDebugDLL + true @@ -80,7 +83,7 @@ true NDEBUG;%(PreprocessorDefinitions);HAVE_OPENJPEG_H true - $(ProjectDir)nrt\include\;$(ProjectDir)nitf\include\;$(ProjectDir)jpeg\include\;$(ProjectDir)j2k\include\;$(ProjectDir)cgm\include\;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include\;$(SolutionDir)\target-$(Configuration)\installwindows-latestCMake-Github\include\;%(AdditionalIncludeDirectories) + $(ProjectDir)nrt\include;$(ProjectDir)nitf\include;$(ProjectDir)jpeg\include;$(ProjectDir)j2k\include;$(ProjectDir)cgm\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include;%(AdditionalIncludeDirectories) Use pch.h pch.h @@ -90,6 +93,9 @@ true Level3 AdvancedVectorExtensions2 + CompileAsCpp + false + true diff --git a/externals/nitro/modules/c/nitf/ACCHZB.vcxproj b/externals/nitro/modules/c/nitf/ACCHZB.vcxproj index cf18d23902..663aef4ba8 100644 --- a/externals/nitro/modules/c/nitf/ACCHZB.vcxproj +++ b/externals/nitro/modules/c/nitf/ACCHZB.vcxproj @@ -69,13 +69,13 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/ACCPOB.vcxproj b/externals/nitro/modules/c/nitf/ACCPOB.vcxproj index 20212f3d20..e8a899d7a7 100644 --- a/externals/nitro/modules/c/nitf/ACCPOB.vcxproj +++ b/externals/nitro/modules/c/nitf/ACCPOB.vcxproj @@ -69,13 +69,13 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/ACFTA.vcxproj b/externals/nitro/modules/c/nitf/ACFTA.vcxproj index 05e79a2de1..e89489e7f4 100644 --- a/externals/nitro/modules/c/nitf/ACFTA.vcxproj +++ b/externals/nitro/modules/c/nitf/ACFTA.vcxproj @@ -69,13 +69,13 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/AIMIDB.vcxproj b/externals/nitro/modules/c/nitf/AIMIDB.vcxproj index 0f70aa7c9b..830685508d 100644 --- a/externals/nitro/modules/c/nitf/AIMIDB.vcxproj +++ b/externals/nitro/modules/c/nitf/AIMIDB.vcxproj @@ -69,13 +69,13 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/CSCRNA.vcxproj b/externals/nitro/modules/c/nitf/CSCRNA.vcxproj index c737b6b4b3..bd97ece2af 100644 --- a/externals/nitro/modules/c/nitf/CSCRNA.vcxproj +++ b/externals/nitro/modules/c/nitf/CSCRNA.vcxproj @@ -69,13 +69,13 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/CSEXRB.vcxproj b/externals/nitro/modules/c/nitf/CSEXRB.vcxproj index 9712bafcda..add865a7ca 100644 --- a/externals/nitro/modules/c/nitf/CSEXRB.vcxproj +++ b/externals/nitro/modules/c/nitf/CSEXRB.vcxproj @@ -69,13 +69,13 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/ENGRDA.vcxproj b/externals/nitro/modules/c/nitf/ENGRDA.vcxproj index aaa8673444..3e28f89e63 100644 --- a/externals/nitro/modules/c/nitf/ENGRDA.vcxproj +++ b/externals/nitro/modules/c/nitf/ENGRDA.vcxproj @@ -69,13 +69,13 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/HISTOA.vcxproj b/externals/nitro/modules/c/nitf/HISTOA.vcxproj index f186bc6c9a..07c71effdd 100644 --- a/externals/nitro/modules/c/nitf/HISTOA.vcxproj +++ b/externals/nitro/modules/c/nitf/HISTOA.vcxproj @@ -69,13 +69,13 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/JITCID.vcxproj b/externals/nitro/modules/c/nitf/JITCID.vcxproj index 37b29b98e6..9c0d3aedbf 100644 --- a/externals/nitro/modules/c/nitf/JITCID.vcxproj +++ b/externals/nitro/modules/c/nitf/JITCID.vcxproj @@ -69,13 +69,13 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/PTPRAA.vcxproj b/externals/nitro/modules/c/nitf/PTPRAA.vcxproj index d0a975671a..860ddfeda2 100644 --- a/externals/nitro/modules/c/nitf/PTPRAA.vcxproj +++ b/externals/nitro/modules/c/nitf/PTPRAA.vcxproj @@ -69,13 +69,13 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/RPFHDR.vcxproj b/externals/nitro/modules/c/nitf/RPFHDR.vcxproj index a2858247eb..2618b65397 100644 --- a/externals/nitro/modules/c/nitf/RPFHDR.vcxproj +++ b/externals/nitro/modules/c/nitf/RPFHDR.vcxproj @@ -69,13 +69,13 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/XML_DATA_CONTENT.vcxproj b/externals/nitro/modules/c/nitf/XML_DATA_CONTENT.vcxproj index a243a545b4..310754ef1f 100644 --- a/externals/nitro/modules/c/nitf/XML_DATA_CONTENT.vcxproj +++ b/externals/nitro/modules/c/nitf/XML_DATA_CONTENT.vcxproj @@ -69,13 +69,14 @@ $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) /FS %(AdditionalOptions) true - true CompileAsCpp Guard - MultiThreadedDebugDLL true ProgramDatabase AdvancedVectorExtensions2 + true + MultiThreadedDebugDLL + true @@ -98,6 +99,7 @@ Guard true AdvancedVectorExtensions2 + true diff --git a/externals/nitro/modules/c/nitf/unittests/Test.h b/externals/nitro/modules/c/nitf/unittests/Test.h index db85a2c462..3231578897 100644 --- a/externals/nitro/modules/c/nitf/unittests/Test.h +++ b/externals/nitro/modules/c/nitf/unittests/Test.h @@ -80,7 +80,7 @@ #define TEST_CASE(X) void X(const char* testName) #define TEST_CASE_ARGS(X) void X(const char* testName, int argc, char **argv) -#define TEST_MAIN(X) int main(int argc, char** argv) { X; return 0; } +#define TEST_MAIN(X) int main(int argc, char** argv) { {(void)argc; (void)argv;} X; return 0; } #endif diff --git a/externals/nitro/modules/c/nitf/unittests/nitro_image_.c_ b/externals/nitro/modules/c/nitf/unittests/nitro_image_.c_ index 611bc89e4c..7a3fde11ed 100644 --- a/externals/nitro/modules/c/nitf/unittests/nitro_image_.c_ +++ b/externals/nitro/modules/c/nitf/unittests/nitro_image_.c_ @@ -28,12 +28,15 @@ #pragma warning(push) #pragma warning(disable: 4125) // decimal digit terminates octal escape sequence #endif -static const struct { +typedef struct { unsigned int width; unsigned int height; unsigned int bytesPerPixel; unsigned char data[188 * 36 * 3 + 1]; -} NITRO_IMAGE = { +} NITRO_IMAGE_t; +static inline const NITRO_IMAGE_t* getNitroImage() +{ +static const NITRO_IMAGE_t retval = { 188, 36, 3, "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" @@ -971,7 +974,8 @@ static const struct { "\343\343\355\355\355\366\366\366\375\375\375\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377", + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377",}; +return &retval; }; #ifdef _MSC_VER #pragma warning(pop) diff --git a/externals/nitro/modules/c/nitf/unittests/test_create_nitf.c b/externals/nitro/modules/c/nitf/unittests/test_create_nitf.c index 6240db1014..d092629acc 100644 --- a/externals/nitro/modules/c/nitf/unittests/test_create_nitf.c +++ b/externals/nitro/modules/c/nitf/unittests/test_create_nitf.c @@ -111,6 +111,7 @@ NITF_BOOL addImageSegment(nitf_Record *record, nitf_Error *error) nitf_ImageSegment *segment = NULL; nitf_ImageSubheader *header = NULL; nitf_BandInfo **bands = NULL; + const NITRO_IMAGE_t* pNITRO_IMAGE = NULL; int i; @@ -179,11 +180,12 @@ NITF_BOOL addImageSegment(nitf_Record *record, nitf_Error *error) goto CATCH_ERROR; /* set the blocking info */ + pNITRO_IMAGE = getNitroImage(); if (!nitf_ImageSubheader_setBlocking(header, - NITRO_IMAGE.height, /*!< The number of rows */ - NITRO_IMAGE.width, /*!< The number of columns */ - NITRO_IMAGE.height, /*!< The number of rows/block */ - NITRO_IMAGE.width, /*!< The number of columns/block */ + pNITRO_IMAGE->height, /*!< The number of rows */ + pNITRO_IMAGE->width, /*!< The number of columns */ + pNITRO_IMAGE->height, /*!< The number of rows/block */ + pNITRO_IMAGE->width, /*!< The number of columns/block */ "P", /*!< Image mode */ error)) goto CATCH_ERROR; @@ -232,8 +234,9 @@ NITF_BOOL writeNITF(nitf_Record *record, const char* filename, nitf_Error *error /* make one bandSource per band */ for (i = 0; i < 3; ++i) { + const NITRO_IMAGE_t* pNITRO_IMAGE = getNitroImage(); nitf_BandSource *bandSource = nitf_MemorySource_construct( - (char*)NITRO_IMAGE.data, NITRO_IMAGE.width * NITRO_IMAGE.height, + (char*)pNITRO_IMAGE->data, pNITRO_IMAGE->width * pNITRO_IMAGE->height, i, 1, 2, error); if (!bandSource) goto CATCH_ERROR; @@ -268,11 +271,11 @@ NITF_BOOL writeNITF(nitf_Record *record, const char* filename, nitf_Error *error } -TEST_CASE_ARGS(testCreate) +TEST_CASE(testCreate) { nitf_Record *record = NULL; nitf_Error error; - const char* outname = argc > 1 ? argv[1] : "test_create.ntf"; + const char* outname = "test_create.ntf"; record = nitf_Record_construct(NITF_VER_21, &error); TEST_ASSERT(record != NULL); @@ -282,13 +285,13 @@ TEST_CASE_ARGS(testCreate) nitf_Record_destruct(&record); } -TEST_CASE_ARGS(testRead) +TEST_CASE(testRead) { nitf_Reader *reader = NULL; nitf_Record *record = NULL; nitf_Error error; nitf_IOHandle io; - const char* outname = argc > 1 ? argv[1] : "test_create.ntf"; + const char* outname = "test_create.ntf"; io = nitf_IOHandle_create(outname, NITF_ACCESS_READONLY, NITF_OPEN_EXISTING, &error); reader = nitf_Reader_construct(&error); @@ -300,9 +303,7 @@ TEST_CASE_ARGS(testRead) } TEST_MAIN( - (void)argc; - (void)argv; - CHECK_ARGS(testCreate); - CHECK_ARGS(testRead); + CHECK(testCreate); + CHECK(testRead); ) diff --git a/externals/nitro/modules/c/nitf/unittests/test_geo_utils.c b/externals/nitro/modules/c/nitf/unittests/test_geo_utils.c index f166daaa42..62f9fbddba 100644 --- a/externals/nitro/modules/c/nitf/unittests/test_geo_utils.c +++ b/externals/nitro/modules/c/nitf/unittests/test_geo_utils.c @@ -166,8 +166,6 @@ TEST_CASE(test_decimalToGeographic_normal) } TEST_MAIN( - (void)argc; - (void)argv; CHECK(test_geo_utils); CHECK(test_decimalToGeographic_normal); ) diff --git a/externals/nitro/modules/c/nitf/unittests/test_moveTREs.c b/externals/nitro/modules/c/nitf/unittests/test_moveTREs.c index b40fa96956..ea02f9b804 100644 --- a/externals/nitro/modules/c/nitf/unittests/test_moveTREs.c +++ b/externals/nitro/modules/c/nitf/unittests/test_moveTREs.c @@ -30,8 +30,6 @@ #include #include "Test.h" -static const char* const DATE_TIME = "20120126000000"; - static NITF_BOOL insertTRE(nitf_Extensions* ext, nitf_Error* error) { @@ -67,6 +65,8 @@ NITF_BOOL initializeTREs(nitf_FileHeader* header, nitf_Error* error) static NITF_BOOL initializeHeader(nitf_FileHeader* header, nitf_Error* error) { + static const char* const DATE_TIME = "20120126000000"; + return (nitf_Field_setString(header->fileHeader, "NITF", error) && nitf_Field_setString(header->fileVersion, "02.10", error) && nitf_Field_setUint32(header->complianceLevel, 3, error) && @@ -122,9 +122,6 @@ TEST_CASE(testUnmerge) nitf_Record_destruct(&record); } -int main() // int argc, char **argv -{ +TEST_MAIN( CHECK(testUnmerge); - return 0; -} - +) diff --git a/externals/nitro/modules/c/nrt/unittests/Test.h b/externals/nitro/modules/c/nrt/unittests/Test.h index 71e46bcafa..5b1e503ca5 100644 --- a/externals/nitro/modules/c/nrt/unittests/Test.h +++ b/externals/nitro/modules/c/nrt/unittests/Test.h @@ -79,7 +79,8 @@ #define TEST_CASE(X) void X(const char* testName) #define TEST_CASE_ARGS(X) void X(const char* testName, int argc, char **argv) -#define TEST_MAIN(X) int main(int argc, char** argv) { X; return 0; } +#define TEST_MAIN(X) int main(int argc, char** argv) { {(void)argc; (void)argv;} X; return 0; } + #endif diff --git a/externals/nitro/modules/c/nrt/unittests/test_tree.c b/externals/nitro/modules/c/nrt/unittests/test_tree.c index 85707b0577..e35448d4c7 100644 --- a/externals/nitro/modules/c/nrt/unittests/test_tree.c +++ b/externals/nitro/modules/c/nrt/unittests/test_tree.c @@ -109,7 +109,8 @@ TEST_CASE(testTree) nrt_Tree *tc = NULL; TEST_ASSERT(t != NULL); - makeTree(t, testName); + const char* testName_ = "testTree"; + makeTree(t, testName_); printf("Pre-order traversal:\n"); printf("=======================================================\n"); TEST_ASSERT(nrt_Tree_walk(t, &printElement, NRT_PRE_ORDER, NULL, &e)); diff --git a/externals/nitro/modules/c/nrt/unittests/test_utils.c b/externals/nitro/modules/c/nrt/unittests/test_utils.c index 959cc68ba3..e7191e0123 100644 --- a/externals/nitro/modules/c/nrt/unittests/test_utils.c +++ b/externals/nitro/modules/c/nrt/unittests/test_utils.c @@ -473,8 +473,6 @@ TEST_CASE(test_matlab_dms) TEST_MAIN( - (void)argc; - (void)argv; CHECK(testParseZeroDegrees); CHECK(testParseZeroMinutes); CHECK(testParseErrorGeographicString); diff --git a/externals/nitro/modules/c/pch.h b/externals/nitro/modules/c/pch.h index c022b32c00..5928459c7d 100644 --- a/externals/nitro/modules/c/pch.h +++ b/externals/nitro/modules/c/pch.h @@ -3,25 +3,10 @@ // We're building in Visual Studio ... used to control where we get a little bit of config info #define NITRO_PCH 1 -#pragma warning(disable: 4668) // '...' is not defined as a preprocessor macro, replacing with '...' for '...' -#pragma warning(disable: 4820) // '...': '...' bytes padding added after data member '...' -#pragma warning(disable: 4710) // '...': function not inlined -#pragma warning(disable: 4774) // '...' : format string expected in argument 3 is not a string literal -#pragma warning(disable: 5045) // Compiler will insert Spectre mitigation for memory load if / Qspectre switch specified - // TODO: get rid of these someday? ... from Visual Studio code-analysis #pragma warning(disable: 6385) // Reading invalid data from '...': the readable size is '...' bytes, but '...' bytes may be read. #pragma warning(disable: 6386) // Buffer overrun while writing to '...': the writable size is '...' bytes, but '...' bytes might be written. - -#pragma warning(push) -#pragma warning(disable: 4255) // '...': no function prototype given : converting '...' to '...' -#pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to '...' function under -EHc. Undefined behavior may occur if this function throws an exception. -#pragma warning(disable: 5105) // macro expansion producing '...' has undefined behavior - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include - #include #include #include @@ -33,11 +18,47 @@ #include #include -#include +#pragma warning(push) +#pragma warning(disable: 4820) // '...': '...' bytes padding added after data member '...' + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#if defined(_WIN32) +#undef BIGENDIAN +#include +#else +#include +#endif + +#include +#include + #pragma warning(pop) -#pragma warning(disable: 4505) // '...': unreferenced local function has been removed -#pragma warning(disable: 4514) // '...' : unreferenced inline function has been removed -#pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to '...' function under -EHc. Undefined behavior may occur if this function throws an exception. + +#include + +#pragma warning(disable: 4505) // '...': unreferenced function with internal linkage has been removed +#pragma warning(disable: 4774) // '...' : format string expected in argument 3 is not a string literal +// 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 + +#if __cplusplus +#pragma warning(disable: 4365) // '...': conversion from '...' to '...', signed/unsigned mismatch +#pragma warning(disable: 4800) // Implicit conversion from '...' to bool. Possible information loss +#pragma warning(disable: 4804) // '...: unsafe use of type '...' in operation +#pragma warning(disable: 5219) // implicit conversion from '...' to '...', possible loss of data +#pragma warning(disable: 4191) // '...': unsafe conversion from '...' to '...' +#pragma warning(disable: 4244) // '...': conversion from '...' to '...', possible loss of data +#endif #define OPJ_STATIC diff --git a/externals/nitro/nitro.sln b/externals/nitro/nitro.sln index d7e22ef783..0df4d94e2c 100644 --- a/externals/nitro/nitro.sln +++ b/externals/nitro/nitro.sln @@ -30,7 +30,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AIMIDB", "modules\c\nitf\AI EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JITCID", "modules\c\nitf\JITCID.vcxproj", "{D1D7FCD3-6130-4504-9DA0-9D80506BE55E}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nitf-plugins", "nitf-plugins", "{27A2685A-E869-42A2-956D-92994F60C536}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "c-nitf-shared", "c-nitf-shared", "{27A2685A-E869-42A2-956D-92994F60C536}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CSCRNA", "modules\c\nitf\CSCRNA.vcxproj", "{023DE06D-3967-4406-B1B8-032118BB2552}" EndProject @@ -46,21 +46,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HISTOA", "modules\c\nitf\HI EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ENGRDA", "modules\c\nitf\ENGRDA.vcxproj", "{53F9F908-C678-4DEE-9309-E71C1E03A45F}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test\Test.vcxproj", "{238C9787-B27D-4107-B8FD-1BDB49EA8023}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test++", "Test++\Test++.vcxproj", "{E610F11D-1240-4260-87F8-504B49DB6915}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "J2KCompress", "modules\c\j2k\J2KCompress.vcxproj", "{A676EDF3-F231-47C8-A6E6-0FE50B50B71B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "J2KDecompress", "modules\c\j2k\J2KDecompress.vcxproj", "{C787537A-0CAC-4D6D-A6D6-A66765A06753}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{A45CB073-25A7-411D-A7E7-589BCC8AF547}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{AC22B9D3-0749-486F-A8F2-D6977BF9505D}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github-workflows", ".github-workflows", "{A45CB073-25A7-411D-A7E7-589BCC8AF547}" ProjectSection(SolutionItems) = preProject - .github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml + .github\workflows\codeql.yml = .github\workflows\codeql.yml .github\workflows\frequent_check.yml = .github\workflows\frequent_check.yml - .github\workflows\master.yml = .github\workflows\master.yml + .github\workflows\main.yml = .github\workflows\main.yml EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CSEXRB", "modules\c\nitf\CSEXRB.vcxproj", "{0A9BDA26-092F-4A2C-BBEF-00C64BF0C65E}" @@ -69,6 +63,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "externals", "externals", "{ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coda-oss", "externals\coda-oss\modules\c++\coda-oss.vcxproj", "{9997E895-5161-4DDF-8F3F-099894CB2F21}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "UnitTest\UnitTest.vcxproj", "{8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -131,14 +127,6 @@ Global {53F9F908-C678-4DEE-9309-E71C1E03A45F}.Debug|x64.Build.0 = Debug|x64 {53F9F908-C678-4DEE-9309-E71C1E03A45F}.Release|x64.ActiveCfg = Release|x64 {53F9F908-C678-4DEE-9309-E71C1E03A45F}.Release|x64.Build.0 = Release|x64 - {238C9787-B27D-4107-B8FD-1BDB49EA8023}.Debug|x64.ActiveCfg = Debug|x64 - {238C9787-B27D-4107-B8FD-1BDB49EA8023}.Debug|x64.Build.0 = Debug|x64 - {238C9787-B27D-4107-B8FD-1BDB49EA8023}.Release|x64.ActiveCfg = Release|x64 - {238C9787-B27D-4107-B8FD-1BDB49EA8023}.Release|x64.Build.0 = Release|x64 - {E610F11D-1240-4260-87F8-504B49DB6915}.Debug|x64.ActiveCfg = Debug|x64 - {E610F11D-1240-4260-87F8-504B49DB6915}.Debug|x64.Build.0 = Debug|x64 - {E610F11D-1240-4260-87F8-504B49DB6915}.Release|x64.ActiveCfg = Release|x64 - {E610F11D-1240-4260-87F8-504B49DB6915}.Release|x64.Build.0 = Release|x64 {A676EDF3-F231-47C8-A6E6-0FE50B50B71B}.Debug|x64.ActiveCfg = Debug|x64 {A676EDF3-F231-47C8-A6E6-0FE50B50B71B}.Debug|x64.Build.0 = Debug|x64 {A676EDF3-F231-47C8-A6E6-0FE50B50B71B}.Release|x64.ActiveCfg = Release|x64 @@ -155,6 +143,10 @@ Global {9997E895-5161-4DDF-8F3F-099894CB2F21}.Debug|x64.Build.0 = Debug|x64 {9997E895-5161-4DDF-8F3F-099894CB2F21}.Release|x64.ActiveCfg = Release|x64 {9997E895-5161-4DDF-8F3F-099894CB2F21}.Release|x64.Build.0 = Release|x64 + {8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}.Debug|x64.ActiveCfg = Debug|x64 + {8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}.Debug|x64.Build.0 = Debug|x64 + {8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}.Release|x64.ActiveCfg = Release|x64 + {8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -174,7 +166,6 @@ Global {A676EDF3-F231-47C8-A6E6-0FE50B50B71B} = {27A2685A-E869-42A2-956D-92994F60C536} {C787537A-0CAC-4D6D-A6D6-A66765A06753} = {27A2685A-E869-42A2-956D-92994F60C536} {A45CB073-25A7-411D-A7E7-589BCC8AF547} = {5C5727E7-0CFF-42B4-8F5A-D31B3BC81F21} - {AC22B9D3-0749-486F-A8F2-D6977BF9505D} = {A45CB073-25A7-411D-A7E7-589BCC8AF547} {0A9BDA26-092F-4A2C-BBEF-00C64BF0C65E} = {27A2685A-E869-42A2-956D-92994F60C536} {9997E895-5161-4DDF-8F3F-099894CB2F21} = {7D26D571-0014-4C50-BF86-612E743E64B6} EndGlobalSection