Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update files changes in cpp17 branch #568

Merged
merged 117 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
d4a82b1
us VS "unit tests" as they don't need extra stuff
JDanielSmith Mar 11, 2022
9135e50
add test_tree
JDanielSmith Mar 11, 2022
379021d
add remaining NRT tests
JDanielSmith Mar 11, 2022
5f61e5b
start adding nitf_ unittests
JDanielSmith Mar 11, 2022
ff1c6c0
add some simple nitf unittests
JDanielSmith Mar 11, 2022
0facbe5
hook up more "nitf" unit-tests
JDanielSmith Mar 11, 2022
c7553f4
hookup test_tre_mods
JDanielSmith Mar 11, 2022
b916f11
move C++ unit-test to Test++
JDanielSmith Mar 14, 2022
da58fba
replace Google "Test" with Visual Studio "UnitTest"
JDanielSmith Mar 14, 2022
7ac6eda
start converting Tests++ to VS-test
JDanielSmith Mar 14, 2022
ac622a8
use universal references to better preserve actual types
Mar 15, 2022
afd267a
move another test case to UnitTests++
Mar 15, 2022
2c5ea36
trying to get new unittest working with CMake
Mar 10, 2022
738078f
don't need these changes from feature/j2k here
Mar 15, 2022
a7fe154
use buildPluginDir() utility
Mar 15, 2022
ada8518
get unit-tests to compile as Visual Studio tests
Mar 15, 2022
cb0bd9e
find path to shares
Mar 15, 2022
97b4c82
move UnitTest++ to Test++
Mar 15, 2022
aac24ae
update TEST_ macros
Mar 15, 2022
fee835f
use same Test.h for both projects
Mar 15, 2022
a90229c
Fix CodeQL diagnostics
Mar 15, 2022
ec2705b
use std::span
Mar 15, 2022
0d44d85
try to fix compile error on Linux
Mar 15, 2022
8f21ef0
tweak OutputStream::write() overloads
Mar 15, 2022
edefcfa
use full name for Assert
Mar 16, 2022
9a788ba
Merge branch 'master' into develop/vs-unit-testing
Mar 16, 2022
5943ad1
Merge branch 'master' into develop/vs-unit-testing
JDanielSmith Jun 23, 2022
6fa3b0a
Squashed commit of the following:
JDanielSmith Jun 23, 2022
5d569f2
Squashed commit of the following:
JDanielSmith Jun 23, 2022
1a0988c
Merge branch 'main' into develop/vs-unit-testing
Jul 10, 2023
f5b94d4
Merge branch 'main' into develop/vs-unit-testing
Jul 10, 2023
eeddd4f
build with AVX2
Jul 10, 2023
786e467
build coda-oss project
Jul 10, 2023
e37e724
'build' -> 'out' to match Visual Studio
Jul 10, 2023
75b07f9
try to build NITRO.SLN
Jul 10, 2023
804f38e
build coda-oss with "nitro" install
Jul 10, 2023
693e139
more closely match YAML from CODA-OSS
Jul 10, 2023
13b134b
adjust paths for NITRO install
Jul 10, 2023
95a892e
restore changes from "main"
Jul 10, 2023
ad6895a
Merge branch 'main' into develop/vs-unit-testing
Jul 12, 2023
af6fd8b
Squashed commit of the following:
Jul 12, 2023
3ca5b34
develop/sync_externals
Jul 12, 2023
117470a
new UnitTest project
Jul 12, 2023
7970c5b
hookup "new" Visual Studio unittest
Jul 12, 2023
abfbf2a
add remaining NRT unittests
Jul 12, 2023
0f6a3ec
begin adding NITF unittests
Jul 12, 2023
7f0c29a
finish hooking up NITF unittests
Jul 12, 2023
34103fa
fix C compile errors
Jul 12, 2023
d3d38d4
begin adding NITF-C++ unittests
Jul 12, 2023
2e3e455
most NITF-C++ unittests building
Jul 12, 2023
664e36c
"const" on return value has no effect
JDanielSmith Jul 13, 2023
d3d9d4d
64-bit only, no Win32/x86
JDanielSmith Jul 13, 2023
9d3d1db
build CODA-OSS, then MSBUILD
JDanielSmith Jul 13, 2023
5f440a4
test_image_loading__ fails on Github?
JDanielSmith Jul 13, 2023
9f8b4c2
fix cmake typo
JDanielSmith Jul 13, 2023
2d40aab
fix name
JDanielSmith Jul 13, 2023
f53f64e
vstest
JDanielSmith Jul 13, 2023
be7a6e4
adjust name
JDanielSmith Jul 13, 2023
971efbe
find vstest action
JDanielSmith Jul 13, 2023
dfd1d75
full path to DLL
Jul 13, 2023
36c2e51
try w/o ${RUNNER_WORKSPACE}
Jul 13, 2023
1319c17
tweak msbuild action version
Jul 13, 2023
f9e74cd
comment-out vstest for now
Jul 13, 2023
2b20188
UnitTest changes from coda-oss
Jul 13, 2023
71d8c9d
Adjust paths for coda-oss being used in another SLN
Jul 13, 2023
e55f757
remove goofy #include path
Jul 13, 2023
752dd02
fix compiler warnings from rearranging UnitTest files
Jul 13, 2023
7769697
do msbuild with DEBUG, not Release
Jul 13, 2023
35c359a
Use common UnitTest code from coda-oss
Jul 13, 2023
2932a8f
build in "out" directory to match Visual Studio
Jul 13, 2023
a83f40f
forgot to "cd" into new directory
Jul 13, 2023
8afeeb5
use nitf::Test::findInputFile()
JDanielSmith Jul 14, 2023
8e490ee
test_image_loading++
JDanielSmith Jul 14, 2023
aeb7cfb
TEST_MAIN() already suppresses argc/argv
JDanielSmith Jul 14, 2023
437c120
trying to get VSTest working
JDanielSmith Jul 14, 2023
4f426dd
no more argc/argv to main()
JDanielSmith Jul 14, 2023
9c48cfe
pass `testName` rather than a `static` variable
JDanielSmith Jul 14, 2023
d138c98
try calling vstest.console directly
JDanielSmith Jul 14, 2023
f32f985
more `testName` arguments
JDanielSmith Jul 14, 2023
3c37c11
remove Test and Test++, moving to UnitTest anyway
JDanielSmith Jul 14, 2023
9cf5b97
vstest.console doesn't work either
JDanielSmith Jul 14, 2023
f23998f
trying to get unittests building again
JDanielSmith Jul 14, 2023
3fda663
Squashed commit of the following:
JDanielSmith Jul 14, 2023
84746e0
consistent settings for VCXPROJ files
JDanielSmith Jul 14, 2023
a39a30e
consistent project settings
Jul 17, 2023
3a428f1
TEST_ASSERT_EQ_STR() to make it easy to compare `const char*`s
Jul 17, 2023
d5f284d
test_image_loading++
Jul 17, 2023
6901ffe
test_writer_3++
Jul 17, 2023
30af403
tweak Throwable::toString()
Jul 17, 2023
0880226
be sure NITF_PLUGIN_PATH is set
Jul 17, 2023
620f926
GREATER_EQ for unsigned
Jul 17, 2023
1330988
TRE unittests
Jul 17, 2023
88dd063
enable remaining unittests
Jul 17, 2023
cdb661b
All unittests now in single UnitTest project
Jul 17, 2023
d9f1acb
Merge branch 'develop/vs-unit-testing' of github.com:mdaus/nitro into…
Jul 17, 2023
0abd72f
latest from coda-oss
Jul 17, 2023
ba79b8e
latest from CODA-OSS
Jul 17, 2023
3942110
Merge commit '5d18020c33ceb7016652a29ac99b548df7e36ce1' into develop/…
Jul 17, 2023
5d18020
Squashed 'externals/coda-oss/' changes from e87c32b4de..e2472acfc1
Jul 17, 2023
dcc4b0c
Merge branch 'main' into develop/vs-unit-testing
JDanielSmith Jul 18, 2023
c394495
Revert "latest from CODA-OSS (known broken build) (#565)"
JDanielSmith Jul 18, 2023
1a4ac37
Merge branch 'main' into develop/vs-unit-testing
JDanielSmith Jul 18, 2023
d24d89f
Merge branch 'main' into develop/vs-unit-testing
JDanielSmith Jul 18, 2023
704e17e
slam-in develop/sync_externals
JDanielSmith Jul 18, 2023
60b3c0f
Fixed bug in Error::to_string(); using the entire buffer rather than …
Jul 18, 2023
e3c1ad5
latest from CODA-OSS
Jul 18, 2023
9357f71
Squashed 'externals/coda-oss/' changes from e2472acfc1..4092fd8e76
Jul 18, 2023
720d677
Merge commit '9357f7116a6c7be9c39799aa0c235ed1c3261b4c' into develop/…
Jul 18, 2023
f45324c
Merge branch 'main' into develop/vs-unit-testing
Jul 18, 2023
7a6d76b
fix WAF build errors discovered in CODA
Jul 18, 2023
b329258
changes from cpp17 branch
Jul 19, 2023
a01a9f6
trying to get test_load_all_plugins() working on Linux
Jul 19, 2023
2ea1669
fix compile warning
Jul 19, 2023
bf16edd
only need to call setNitfPluginPath() once
Jul 19, 2023
bfc8903
only need to call setNitfPluginPath() once
Jul 19, 2023
5b88f62
figured out why loadPlugin() failed on Linux
Jul 19, 2023
506d0e8
Merge branch 'develop/vs-unit-testing' of github.com:mdaus/nitro into…
Jul 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/c++/nitf/apps/show_nitf++/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#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: 5220) // '...': a non-static data member with a volatile qualified type no longer implies
#pragma warning(disable: 4355) // '...': used in base member initializer list
#pragma warning(disable: 5105) // macro expansion producing '...' has undefined behavior

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
Expand Down
4 changes: 1 addition & 3 deletions modules/c++/nitf/unittests/test_hash_table_1++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ TEST_CASE(test_hash_table_iterator)
}

TEST_MAIN(
(void)argc;
(void)argv;
TEST_CHECK(test_hash_table_1);
TEST_CHECK(test_hash_table_iterator);
)
)
82 changes: 39 additions & 43 deletions modules/c++/nitf/unittests/test_load_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,28 @@

#include "TestCase.h"

static void load_plugin(const std::string& testName, const char* tre)
static void retrieveTREHandler(const std::string& testName, const char* tre)
{
nitf_Error error;

auto reg = nitf::PluginRegistry::getInstance(error);
auto const reg = nitf::PluginRegistry::getInstance(error);
TEST_ASSERT(reg != nullptr);

nitf::HashTable::print(*(reg->treHandlers));
//nitf::HashTable::print(*(reg->treHandlers));

int bad = 0;
auto test_main_ =
nitf::PluginRegistry::retrieveTREHandler(*reg,
tre,
bad,
error);
auto const test_main_ = nitf::PluginRegistry::retrieveTREHandler(*reg, tre, bad, error);
TEST_ASSERT_EQ(0, bad);
TEST_ASSERT(test_main_ != nullptr);
}

static const std::vector<std::string>& all_plugins()
static const auto& all_TREs()
{
static const std::vector<std::string> all_plugins_
static const std::vector<std::string> retval
{
#if _MSC_VER && NITRO_PCH
// only build a handful in Visual Studio
"ACCHZB", "ACCPOB", "ACFTA", "AIMIDB", "CSCRNA", "ENGRDA", "HISTOA", "JITCID", "PTPRAA", "RPFHDR",
"ACCHZB", "ACCPOB", "ACFTA", "AIMIDB", "CSCRNA", "CSEXRB", "ENGRDA", "HISTOA", "JITCID", "PTPRAA", "RPFHDR",
#else
"ACCHZB", "BANDSB", "CSDIDA", "GEOLOB", "JITCID", "NBLOCA", "PIAPEB", "REGPTB", "RSMIDA", "STEROB",
"ACCPOB", "BCKGDA", "CSEPHA", "GEOPSB", "MAPLOB", "OBJCTA", "PIAPRC", "RPC00B", "RSMPCA", "STREOB",
Expand All @@ -69,59 +65,59 @@ static const std::vector<std::string>& all_plugins()
"BANDSA", "CSCRNA", "EXPLTB", "J2KLRA", "MTIRPB", "PIAPEA", "PTPRAA", "RSMGIA", "STDIDC",
#endif
};
return all_plugins_;
return retval;
}

TEST_CASE(test_load_all_plugins_C)
TEST_CASE(test_retrieveTREHandler)
{
nitf::Test::setNitfPluginPath();

for (const auto& tre : all_plugins())
for (const auto& tre : all_TREs())
{
load_plugin(testName, tre.c_str());
retrieveTREHandler(testName, tre.c_str());
}
}

TEST_CASE(test_load_PTPRAA)
{
nitf::Test::setNitfPluginPath();
load_plugin(testName, "PTPRAA");
retrieveTREHandler(testName, "PTPRAA");
}
TEST_CASE(test_load_ENGRDA)
{
nitf::Test::setNitfPluginPath();
load_plugin(testName, "ENGRDA");
retrieveTREHandler(testName, "ENGRDA");
}

static void loadPlugin(const std::string& testName, const std::string& path)
{
try
{
#ifdef _WIN32
// need the full path to load on Linux
nitf::PluginRegistry::loadPlugin(path);
#endif
TEST_SUCCESS;
}
catch (const nitf::NITFException& ex)
{
TEST_FAIL_MSG(ex.toString());
}
}
TEST_CASE(test_load_all_plugins)
TEST_CASE(test_load_all_TREs)
{
nitf::Test::setNitfPluginPath();
const nitf::TRE tre("ACCPOB");

for (const auto& tre : all_plugins())
for (const auto& tre : all_TREs())
{
loadPlugin(testName, tre);
// TREs are quite the same thing as an arbitrary "plug in;" the underlying
// infrastructure is all built on shared-libraries/DLLs, but details differ.
//
// As a result, we can't expect loadPlugin() will "just work" on a TRE name.
// Unfortunately, the behavior is different on Windows and Linux. :-(
#if _WIN32
// Keep this around for now as it works ... but it's not necessarily correct.
// Mostly an excuse to exercise more code.
try
{
nitf::PluginRegistry::loadPlugin(tre);
}
catch (const nitf::NITFException& ex)
{
TEST_FAIL_MSG(ex.toString());
}
#endif // _WIN32

TEST_ASSERT(nitf::PluginRegistry::treHandlerExists(tre));
}
}

TEST_MAIN(
nitf::Test::setNitfPluginPath();

TEST_CHECK(test_load_PTPRAA);
TEST_CHECK(test_load_ENGRDA);
TEST_CHECK(test_load_all_plugins_C);
TEST_CHECK(test_load_all_plugins);
TEST_CHECK(test_load_ENGRDA);
TEST_CHECK(test_retrieveTREHandler);
TEST_CHECK(test_load_all_TREs);
)
6 changes: 2 additions & 4 deletions modules/c++/nitf/unittests/test_tre_create++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

TEST_CASE(test_tre_create_329)
{
nitf::Test::setNitfPluginPath();

// https://github.com/mdaus/nitro/issues/329

nitf::TRE tre("HISTOA", "HISTOA"); // allocates fields SYSTEM .. NEVENTS
Expand All @@ -21,8 +19,6 @@ TEST_CASE(test_tre_create_329)

TEST_CASE(test_tre_clone_329)
{
nitf::Test::setNitfPluginPath();

// https://github.com/mdaus/nitro/issues/329
const std::string rd = "begin1020030004ABCDEFend";

Expand All @@ -43,6 +39,8 @@ TEST_CASE(test_tre_clone_329)
}

TEST_MAIN(
nitf::Test::setNitfPluginPath();

TEST_CHECK(test_tre_create_329);
TEST_CHECK(test_tre_clone_329);
)
22 changes: 2 additions & 20 deletions modules/c++/nitf/unittests/test_tre_mods++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ struct /*namespace*/ TREs

TEST_CASE(setFields)
{
nitf::Test::setNitfPluginPath();

// create an ACFTA TRE
nitf::TRE tre("ACFTA");

Expand All @@ -180,8 +178,6 @@ TEST_CASE(setFields)

TEST_CASE(setBinaryFields)
{
nitf::Test::setNitfPluginPath();

nitf::TRE tre("RPFHDR");
const int value = 123;
tre.setField("LOCSEC", value);
Expand All @@ -193,8 +189,6 @@ TEST_CASE(setBinaryFields)

TEST_CASE(cloneTRE)
{
nitf::Test::setNitfPluginPath();

nitf::TRE tre("JITCID");
tre.setField("FILCMT", "fyi");

Expand All @@ -208,8 +202,6 @@ TEST_CASE(cloneTRE)

TEST_CASE(basicIteration)
{
nitf::Test::setNitfPluginPath();

nitf::TRE tre("ACCPOB");

// The entire TRE is one loop, and we haven't told it
Expand Down Expand Up @@ -237,8 +229,6 @@ TEST_CASE(basicIteration)

TEST_CASE(use_ENGRDA)
{
nitf::Test::setNitfPluginPath();

nitf::TRE engrda("ENGRDA", "ENGRDA");

engrda.setField("RESRC", "HSS");
Expand All @@ -263,8 +253,6 @@ TEST_CASE(use_ENGRDA)

TEST_CASE(use_ENGRDA_typed_fields)
{
nitf::Test::setNitfPluginPath();

nitf::TRE engrda("ENGRDA", "ENGRDA");

nitf::TREField_BCS_A<20> RESRC(engrda, "RESRC");
Expand Down Expand Up @@ -297,8 +285,6 @@ TEST_CASE(use_ENGRDA_typed_fields)

TEST_CASE(use_typed_ENGRDA)
{
nitf::Test::setNitfPluginPath();

TREs::ENGRDA engrda; // nitf::TRE engrda("ENGRDA", "ENGRDA");

engrda.RESRC = "HSS"; // engrda.setField("RESRC", "HSS");
Expand Down Expand Up @@ -347,8 +333,6 @@ TEST_CASE(use_typed_ENGRDA)

TEST_CASE(use_CSEXRB_typed_fields)
{
nitf::Test::setNitfPluginPath();

nitf::TRE tre("CSEXRB", "CSEXRB");

constexpr auto length = 12;
Expand All @@ -362,8 +346,6 @@ TEST_CASE(use_CSEXRB_typed_fields)

TEST_CASE(populateWhileIterating)
{
nitf::Test::setNitfPluginPath();

nitf::TRE tre("ACCPOB");
size_t numFields = 0;
for (auto it = tre.begin(); it != tre.end(); ++it)
Expand All @@ -388,8 +370,6 @@ TEST_CASE(populateWhileIterating)

TEST_CASE(overflowingNumericFields)
{
nitf::Test::setNitfPluginPath();

nitf::TRE tre("CSCRNA");

// This field has a length of 9, so check that it's properly
Expand Down Expand Up @@ -418,6 +398,8 @@ TEST_CASE(overflowingNumericFields)
}

TEST_MAIN(
nitf::Test::setNitfPluginPath();

TEST_CHECK(setFields);
TEST_CHECK(setBinaryFields);
TEST_CHECK(cloneTRE);
Expand Down
18 changes: 2 additions & 16 deletions modules/c++/nitf/unittests/test_tre_mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

TEST_CASE(testNestedMod)
{
nitf::Test::setNitfPluginPath();

nitf_Error error;
NITF_BOOL exists;
nitf_TRE* tre = nitf_TRE_construct("ACCHZB", NULL, &error);
Expand Down Expand Up @@ -61,8 +59,6 @@ TEST_CASE(testNestedMod)

TEST_CASE(testIncompleteCondMod)
{
nitf::Test::setNitfPluginPath();

nitf_Error error;
NITF_BOOL exists;
nitf_TRE* tre = nitf_TRE_construct("ACCPOB", NULL, &error);
Expand All @@ -89,8 +85,6 @@ TEST_CASE(testIncompleteCondMod)

TEST_CASE(testClone)
{
nitf::Test::setNitfPluginPath();

NITF_BOOL exists;
nitf_TRE* dolly; /* used for clone */
nitf_Field* clonedField = NULL;
Expand All @@ -116,8 +110,6 @@ TEST_CASE(testClone)

TEST_CASE(testBasicMod)
{
nitf::Test::setNitfPluginPath();

/* construct a tre */
NITF_BOOL exists;
nitf_Error error;
Expand Down Expand Up @@ -147,8 +139,6 @@ TEST_CASE(testBasicMod)

TEST_CASE(testSize)
{
nitf::Test::setNitfPluginPath();

nitf_Error error;
int treLength;
nitf_TRE* tre = nitf_TRE_construct("AIMIDB", NULL, &error);
Expand All @@ -163,8 +153,6 @@ TEST_CASE(testSize)

TEST_CASE(iterateUnfilled)
{
nitf::Test::setNitfPluginPath();

nitf_Error error;
nitf_TRECursor cursor;
nitf_TRE* tre = nitf_TRE_construct("ACCPOB", NULL, &error);
Expand All @@ -186,8 +174,6 @@ TEST_CASE(iterateUnfilled)

TEST_CASE(populateThenIterate)
{
nitf::Test::setNitfPluginPath();

nitf_Error error;
nitf_TRECursor cursor;
nitf_TRE* tre = nitf_TRE_construct("ACCPOB", NULL, &error);
Expand All @@ -214,8 +200,6 @@ TEST_CASE(populateThenIterate)

TEST_CASE(populateWhileIterating)
{
nitf::Test::setNitfPluginPath();

nitf_Error error;
nitf_TRECursor cursor;
nitf_TRE* tre = nitf_TRE_construct("ACCPOB", NULL, &error);
Expand Down Expand Up @@ -247,6 +231,8 @@ TEST_CASE(populateWhileIterating)
}

TEST_MAIN(
nitf::Test::setNitfPluginPath();

TEST_CHECK(testClone);
TEST_CHECK(testSize);
TEST_CHECK(testBasicMod);
Expand Down
3 changes: 2 additions & 1 deletion modules/c++/nitf/unittests/test_writer_3++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <gsl/gsl.h>

#include <import/nitf.hpp>
#include <nitf/UnitTests.hpp>

#include "TestCase.h"

Expand Down Expand Up @@ -268,4 +269,4 @@ TEST_CASE(test_buffered_write_)
TEST_MAIN(
TEST_CHECK(test_writer_3_);
TEST_CHECK(test_buffered_write_);
)
)
1 change: 1 addition & 0 deletions modules/c++/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CODA_OSS_disable_warning_pop
#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.
#pragma warning(disable: 5105) // macro expansion producing '...' has undefined behavior
#include <windows.h>
#pragma warning(pop)

Expand Down
Loading
Loading