-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dan Smith
committed
May 12, 2022
1 parent
c6a6ab7
commit 6fe80ca
Showing
85 changed files
with
2,881 additions
and
718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,55 @@ | ||
*.swp | ||
*~ | ||
*.pyc | ||
__pycache__/ | ||
# Build artifacts | ||
|
||
install/ | ||
install-*/ | ||
target/ | ||
|
||
# Conan | ||
modules/drivers/**/build | ||
test_package/build/ | ||
|
||
# CMake | ||
_deps/ | ||
*.cmake | ||
CMakeCache.txt | ||
CMakeFiles/ | ||
*_config.h | ||
Makefile | ||
modules/**/Makefile | ||
out/ | ||
|
||
# Waf | ||
.waf-* | ||
waf-* | ||
.waf3-* | ||
waf3-* | ||
.lock-waf* | ||
build/waf*/ | ||
|
||
# Eclipse | ||
.project | ||
.cproject | ||
|
||
# Drivers | ||
modules/drivers/fftw/fftw-2.1.*/ | ||
modules/drivers/jpeg/jpeg-9/ | ||
modules/drivers/jpeg/jpeg-9d/ | ||
modules/drivers/j2k/openjpeg/openjpeg-2.3.*_mod/ | ||
modules/drivers/pcre/pcre2-10.*/ | ||
modules/drivers/uuid/e2fsprogs-1.*-uuid/ | ||
modules/drivers/xml/xerces/xerces-c-*/ | ||
modules/drivers/zlib/zlib-1.2.*/ | ||
|
||
# VS | ||
.vs/ | ||
project.sln | ||
.depproj/ | ||
|
||
CMakeSettings.json | ||
*.swp | ||
*~ | ||
*.pyc | ||
__pycache__/ | ||
# Build artifacts | ||
|
||
install/ | ||
install-*/ | ||
target/ | ||
|
||
# Conan | ||
modules/drivers/**/build | ||
test_package/build/ | ||
|
||
# CMake | ||
_deps/ | ||
*.cmake | ||
CMakeCache.txt | ||
CMakeFiles/ | ||
*_config.h | ||
Makefile | ||
modules/**/Makefile | ||
out/ | ||
|
||
# Waf | ||
.waf-* | ||
waf-* | ||
.waf3-* | ||
waf3-* | ||
.lock-waf* | ||
build/waf*/ | ||
|
||
# Eclipse | ||
.project | ||
.cproject | ||
|
||
# Drivers | ||
modules/drivers/fftw/fftw-2.1.*/ | ||
modules/drivers/jpeg/jpeg-9/ | ||
modules/drivers/jpeg/jpeg-9d/ | ||
modules/drivers/j2k/openjpeg/openjpeg-2.3.*_mod/ | ||
modules/drivers/pcre/pcre2-10.*/ | ||
modules/drivers/uuid/e2fsprogs-1.*-uuid/ | ||
modules/drivers/xml/xerces/xerces-c-*/ | ||
modules/drivers/zlib/zlib-1.2.*/ | ||
|
||
# VS | ||
.vs/ | ||
project.sln | ||
.depproj/ | ||
*.tlog | ||
**/x64/ | ||
*.vcxproj.user | ||
|
||
CMakeSettings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/questions/6873138/calling-private-method-in-c?msclkid=dd8b1f8bd09711ec8610b4501a04de94 | ||
|
||
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 <FailOnCondition_t fFailOnCondition, GetAssertMessage_t fGetAssertMessage> | ||
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! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include <string> | ||
|
||
#include "CppUnitTest.h" | ||
#include "include/TestCase.h" | ||
|
||
#undef TEST_CHECK | ||
#undef TEST_ASSERT | ||
#undef TEST_ASSERT_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) Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsNull((X)) | ||
#define TEST_ASSERT_TRUE(X) Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue((X)) | ||
#define TEST_ASSERT_FALSE(X) Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsFalse((X)) | ||
#define TEST_ASSERT(X) TEST_ASSERT_TRUE(X) | ||
#define TEST_CASE(X) TEST_METHOD(X) | ||
|
||
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<const unsigned short*>(test::Assert::GetAssertMessage(true, str::toString(expected), str::toString(actual), message).c_str()) | ||
#define CODA_OSS_not_equals_message_(notExpected, actual, message) reinterpret_cast<const unsigned short*>(test::Assert::GetAssertMessage(false, str::toString(notExpected), str::toString(actual), message).c_str()) | ||
|
||
// see Assert::AreEqual<> | ||
template<typename TExpected, typename TActual> | ||
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<typename TExpected, typename TActual> | ||
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); | ||
} | ||
} | ||
#undef CODA_OSS_test_diePrintf_eq_ | ||
#undef CODA_OSS_test_diePrintf_ne_ | ||
#define CODA_OSS_test_diePrintf_eq_(X1, X2) test::diePrintf_eq(X1, X2) | ||
#define CODA_OSS_test_diePrintf_ne_(X1, X2) test::diePrintf_ne(X1, X2) | ||
|
||
template <typename TX1, typename TX2> | ||
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) test_assert_greater_(X1, X2) | ||
|
||
#undef TEST_ASSERT_ALMOST_EQ_EPS | ||
#define TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS) { Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(X1, X2, EPS); Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(X2, X1, EPS); } | ||
namespace test | ||
{ | ||
inline void assert_almost_eq(float X1, float X2) | ||
{ | ||
constexpr auto EPS = static_cast<float>(0.0001); | ||
TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS); | ||
} | ||
inline void assert_almost_eq(double X1, double X2) | ||
{ | ||
constexpr auto EPS = static_cast<double>(0.0001); | ||
TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS); | ||
} | ||
inline void assert_almost_eq(long double X1, long double X2) | ||
{ | ||
assert_almost_eq(static_cast<double>(X1), static_cast<double>(X2)); | ||
} | ||
} | ||
|
||
#undef TEST_ASSERT_ALMOST_EQ | ||
#define TEST_ASSERT_ALMOST_EQ(X1, X2) test::assert_almost_eq(X1, X2) | ||
|
||
#undef TEST_ASSERT_EQ_MSG | ||
#define TEST_ASSERT_EQ_MSG(msg, X1, X2) Microsoft::VisualStudio::CppUnitTestFramework::Logger::WriteMessage(msg.c_str()); TEST_ASSERT_EQ(X1, X2) | ||
|
||
#undef TEST_EXCEPTION | ||
#undef TEST_THROWS | ||
#define TEST_EXCEPTION(X) try { (X); TEST_ASSERT_FALSE(false); } catch (...) { TEST_ASSERT_TRUE(true); } | ||
#define TEST_THROWS(X) TEST_EXCEPTION(X) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>17.0</VCProjectVersion> | ||
<ProjectGuid>{34A31B3F-47C5-441D-AB22-3C85B3C5314E}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<RootNamespace>UnitTest</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
<ProjectSubType>NativeUnitTestProject</ProjectSubType> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
<UseOfMfc>false</UseOfMfc> | ||
<EnableASAN>true</EnableASAN> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
<UseOfMfc>false</UseOfMfc> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="Shared"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<WarningLevel>Level4</WarningLevel> | ||
<SDLCheck>true</SDLCheck> | ||
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;$(ProjectDir);$(SolutionDir)\modules\c++\;$(SolutionDir)\modules\c++\config\include\;$(SolutionDir)\modules\c++\coda_oss\include\;$(SolutionDir)\modules\c++\gsl\include\;$(SolutionDir)\modules\c++\std\include\;$(SolutionDir)\modules\c++\str\include\;$(SolutionDir)\modules\c++\sys\include\;$(SolutionDir)\modules\c++\except\include\;$(SolutionDir)\modules\c++\math\include\;$(SolutionDir)\modules\c++\math.linear\include\;$(SolutionDir)\modules\c++\mem\include\;$(SolutionDir)\modules\c++\types\include\;$(SolutionDir)\modules\c++\units\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);CODA_OSS_DLL</PreprocessorDefinitions> | ||
<UseFullPaths>true</UseFullPaths> | ||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> | ||
<MultiProcessorCompilation>true</MultiProcessorCompilation> | ||
<TreatWarningAsError>true</TreatWarningAsError> | ||
<ControlFlowGuard>Guard</ControlFlowGuard> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;$(ProjectDir);$(SolutionDir)\modules\c++\;$(SolutionDir)\modules\c++\config\include\;$(SolutionDir)\modules\c++\coda_oss\include\;$(SolutionDir)\modules\c++\gsl\include\;$(SolutionDir)\modules\c++\std\include\;$(SolutionDir)\modules\c++\str\include\;$(SolutionDir)\modules\c++\sys\include\;$(SolutionDir)\modules\c++\except\include\;$(SolutionDir)\modules\c++\math\include\;$(SolutionDir)\modules\c++\math.linear\include\;$(SolutionDir)\modules\c++\mem\include\;$(SolutionDir)\modules\c++\types\include\;$(SolutionDir)\modules\c++\units\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);CODA_OSS_DLL</PreprocessorDefinitions> | ||
<UseFullPaths>true</UseFullPaths> | ||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> | ||
<MultiProcessorCompilation>true</MultiProcessorCompilation> | ||
<ControlFlowGuard>Guard</ControlFlowGuard> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="CppUnitTestAssert.cpp" /> | ||
<ClCompile Include="math.linear.cpp" /> | ||
<ClCompile Include="mem.cpp" /> | ||
<ClCompile Include="pch.cpp"> | ||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> | ||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> | ||
</ClCompile> | ||
<ClCompile Include="math.cpp" /> | ||
<ClCompile Include="str.cpp" /> | ||
<ClCompile Include="units.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="pch.h" /> | ||
<ClInclude Include="TestCase.h" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\modules\c++\coda-oss-lite.vcxproj"> | ||
<Project>{9997e895-5161-4ddf-8f3f-099894cb2f21}</Project> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<ClCompile Include="pch.cpp" /> | ||
<ClCompile Include="math.cpp" /> | ||
<ClCompile Include="str.cpp" /> | ||
<ClCompile Include="units.cpp" /> | ||
<ClCompile Include="math.linear.cpp" /> | ||
<ClCompile Include="mem.cpp" /> | ||
<ClCompile Include="CppUnitTestAssert.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="pch.h" /> | ||
<ClInclude Include="TestCase.h" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.