Skip to content

Commit

Permalink
add another unit-test (#371)
Browse files Browse the repository at this point in the history
* put common #includes for PCH in a single file

* build check_valid_six

* use EXIT_* rather than 0/1

* getting rid of std::auto_ptr<> because it's gone in C++17

* build all projects with C++17

* use <filesystem> to remove hard-coded paths

* in Visual Studio, run check_valid_six with a pre-defined path

* tweak plugin dir

* can't have "check_valid_six" as a directory for *ix build

* build crop_sicd

* turn on /Wall, fix some warnings

* C++17 generates more warnings that I don't want to fix right now

* removed some compiler warnings from third-party code

* comment-out use of C++17's <filesystem>

* tweak project settings for consistency

* unit-test for createFakeComplexData()
  • Loading branch information
J. Daniel Smith authored Nov 30, 2020
1 parent ce28071 commit 79aa44f
Show file tree
Hide file tree
Showing 39 changed files with 2,414 additions and 2,312 deletions.
402 changes: 206 additions & 196 deletions Test/Test.vcxproj

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Test/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@

#pragma comment(lib, "ws2_32")

#pragma warning(push)
#pragma warning(disable: 4800) // Implicit conversion from '...' to bool.Possible information loss
#pragma warning(disable: 4388) // '...': signed / unsigned mismatch
#pragma warning(disable: 4866) // compiler may not enforce left - to - right evaluation order for call to '...'

#include "gtest/gtest.h"
#pragma warning(pop)

#include "six_Test.h"
#include "sidd_Test.h"
Expand Down
497 changes: 249 additions & 248 deletions externals/nitro/modules/c++/nitro-c++.vcxproj

Large diffs are not rendered by default.

639 changes: 321 additions & 318 deletions externals/nitro/modules/c/nitro-c.vcxproj

Large diffs are not rendered by default.

345 changes: 175 additions & 170 deletions six/modules/c++/cphd/cphd.vcxproj

Large diffs are not rendered by default.

36 changes: 20 additions & 16 deletions six/modules/c++/cphd/include/cphd/TestDataGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ void setUpMetadata(Metadata& metadata);
*
* \throws except::Exception if wideband data is not an accepted type or size
*/
inline cphd::SignalArrayFormat getSignalArrayFormat(size_t writeDataSize)
{
if (writeDataSize == 2)
{
return cphd::SignalArrayFormat::CI2;
}
if (writeDataSize == 4)
{
return cphd::SignalArrayFormat::CI4;
}
if (writeDataSize == 8)
{
return cphd::SignalArrayFormat::CF8;
}

throw except::Exception(Ctxt("Signal format is incorrect size or type"));
}


template<typename T>
void setUpData(Metadata& metadata,
const types::RowCol<size_t>& dims,
Expand Down Expand Up @@ -128,22 +147,7 @@ void setUpData(Metadata& metadata,
// Must set the sample type
else
{
if (sizeof(writeData[0]) == 2)
{
metadata.data.signalArrayFormat = cphd::SignalArrayFormat::CI2;
}
else if (sizeof(writeData[0]) == 4)
{
metadata.data.signalArrayFormat = cphd::SignalArrayFormat::CI4;
}
else if (sizeof(writeData[0]) == 8)
{
metadata.data.signalArrayFormat = cphd::SignalArrayFormat::CF8;
}
else
{
throw except::Exception(Ctxt("Signal format is incorrect size or type"));
}
metadata.data.signalArrayFormat = getSignalArrayFormat(sizeof(writeData[0]));
}
}
else
Expand Down
12 changes: 6 additions & 6 deletions six/modules/c++/cphd/source/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ size_t Metadata::getNumChannels() const
return data.getNumChannels();
}

size_t Metadata::getNumVectors(size_t channel) const
size_t Metadata::getNumVectors(size_t channel_) const
{
return data.getNumVectors(channel);
return data.getNumVectors(channel_);
}

size_t Metadata::getNumSamples(size_t channel) const
size_t Metadata::getNumSamples(size_t channel_) const
{
return data.getNumSamples(channel);
return data.getNumSamples(channel_);
}

size_t Metadata::getNumBytesPerSample() const
{
return data.getNumBytesPerSample();
}

size_t Metadata::getCompressedSignalSize(size_t channel) const
size_t Metadata::getCompressedSignalSize(size_t channel_) const
{
return data.getCompressedSignalSize(channel);
return data.getCompressedSignalSize(channel_);
}

bool Metadata::isCompressed() const
Expand Down
291 changes: 148 additions & 143 deletions six/modules/c++/cphd03/cphd03.vcxproj

Large diffs are not rendered by default.

31 changes: 19 additions & 12 deletions six/modules/c++/cphd03/unittests/test_cphd_read_unscaled_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ std::vector<double> generateScaleFactors(size_t length, bool scale)
return scaleFactors;
}

inline cphd::SampleType getSampleType(size_t writeDataSize)
{
//! Must set the sample type
if (writeDataSize == 2)
{
return cphd::SampleType::RE08I_IM08I;
}
if (writeDataSize == 4)
{
return cphd::SampleType::RE16I_IM16I;
}
if (writeDataSize == 8)
{
return cphd::SampleType::RE32F_IM32F;
}
throw std::invalid_argument("Unespced writeDataSize");
}

template<typename T>
void writeCPHD(const std::string& outPathname, size_t numThreads,
const types::RowCol<size_t> dims,
Expand All @@ -85,18 +103,7 @@ void writeCPHD(const std::string& outPathname, size_t numThreads,
}

//! Must set the sample type
if (sizeof(writeData[0]) == 2)
{
metadata.data.sampleType = cphd::SampleType::RE08I_IM08I;
}
else if (sizeof(writeData[0]) == 4)
{
metadata.data.sampleType = cphd::SampleType::RE16I_IM16I;
}
else if (sizeof(writeData[0]) == 8)
{
metadata.data.sampleType = cphd::SampleType::RE32F_IM32F;
}
metadata.data.sampleType = getSampleType(sizeof(writeData[0]));

//! We must have a radar mode set
metadata.collectionInformation.radarMode = cphd::RadarModeType::SPOTLIGHT;
Expand Down
3 changes: 2 additions & 1 deletion six/modules/c++/cphd03/unittests/test_cphd_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,10 @@ void writeCPHD(
}


void runCPHDTest(const std::string& testName,
void runCPHDTest(const std::string& testName_,
cphd03::Metadata& metadata)
{
testName = testName_;

metadata.data.numCPHDChannels = NUM_IMAGES;

Expand Down
4 changes: 3 additions & 1 deletion six/modules/c++/cphd03/unittests/test_vbm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ static std::string testName;

namespace
{
void testVectorParameters(const std::string& testName,
void testVectorParameters(const std::string& testName_,
size_t channel,
size_t vector,
cphd03::VBM& vbm)
{
testName = testName_;

const double txTime = cphd::getRandom();
vbm.setTxTime(txTime, channel, vector);

Expand Down
Loading

0 comments on commit 79aa44f

Please sign in to comment.