mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 14:58:10 -05:00
Change cpp unit test framework to catch2 for all cpp unit test projects
This commit is contained in:
@ -1,12 +1,16 @@
|
||||
ObjCommonTests = {}
|
||||
|
||||
function ObjCommonTests:include()
|
||||
|
||||
if References:include(self:name()) then
|
||||
includedirs {
|
||||
path.join(TestFolder(), "ObjCommonTests")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function ObjCommonTests:link()
|
||||
if References:link("ObjCommonTests") then
|
||||
links "ObjCommonTests"
|
||||
if References:link(self:name()) then
|
||||
links(self:name())
|
||||
end
|
||||
end
|
||||
|
||||
@ -14,14 +18,18 @@ function ObjCommonTests:use()
|
||||
|
||||
end
|
||||
|
||||
function ObjCommonTests:name()
|
||||
return "ObjCommonTests"
|
||||
end
|
||||
|
||||
function ObjCommonTests:project()
|
||||
References:reset()
|
||||
local folder = TestFolder();
|
||||
|
||||
project "ObjCommonTests"
|
||||
project(self:name())
|
||||
targetdir(TargetDirectoryTest)
|
||||
location "%{wks.location}/test/%{prj.name}"
|
||||
kind "SharedLib"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
|
||||
files {
|
||||
@ -38,6 +46,7 @@ function ObjCommonTests:project()
|
||||
|
||||
self:include()
|
||||
ObjCommon:include()
|
||||
catch2:include()
|
||||
|
||||
ObjCommon:link()
|
||||
end
|
||||
|
@ -1,22 +1,17 @@
|
||||
#include "CppUnitTest.h"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include "Image/ImageFormat.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace ObjCommonTests
|
||||
namespace image::image_format
|
||||
{
|
||||
TEST_CLASS(ImageFormatTests)
|
||||
TEST_CASE("ImageFormat: EnsureAllFormatsArrayIndicesAreIds", "[image]")
|
||||
{
|
||||
public:
|
||||
TEST_METHOD(EnsureAllFormatsArrayIndicesAreIds)
|
||||
{
|
||||
Assert::AreEqual(static_cast<unsigned int>(ImageFormatId::MAX), _countof(ImageFormat::ALL_FORMATS));
|
||||
REQUIRE(static_cast<unsigned int>(ImageFormatId::MAX) == _countof(ImageFormat::ALL_FORMATS));
|
||||
|
||||
for(unsigned i = 0; i < _countof(ImageFormat::ALL_FORMATS); i++)
|
||||
{
|
||||
Assert::IsNotNull(ImageFormat::ALL_FORMATS[i]);
|
||||
Assert::AreEqual(i, static_cast<unsigned>(ImageFormat::ALL_FORMATS[i]->GetId()));
|
||||
}
|
||||
for(unsigned i = 0; i < _countof(ImageFormat::ALL_FORMATS); i++)
|
||||
{
|
||||
REQUIRE(ImageFormat::ALL_FORMATS[i] != nullptr);
|
||||
REQUIRE(i == static_cast<unsigned>(ImageFormat::ALL_FORMATS[i]->GetId()));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
2
test/ObjCommonTests/main.cpp
Normal file
2
test/ObjCommonTests/main.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
@ -1,12 +1,16 @@
|
||||
ZoneCommonTests = {}
|
||||
|
||||
function ZoneCommonTests:include()
|
||||
|
||||
if References:include(self:name()) then
|
||||
includedirs {
|
||||
path.join(TestFolder(), "ZoneCommonTests")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function ZoneCommonTests:link()
|
||||
if References:link("ZoneCommonTests") then
|
||||
links "ZoneCommonTests"
|
||||
if References:link(self:name()) then
|
||||
links(self:name())
|
||||
end
|
||||
end
|
||||
|
||||
@ -14,14 +18,18 @@ function ZoneCommonTests:use()
|
||||
|
||||
end
|
||||
|
||||
function ZoneCommonTests:name()
|
||||
return "ZoneCommonTests"
|
||||
end
|
||||
|
||||
function ZoneCommonTests:project()
|
||||
References:reset()
|
||||
local folder = TestFolder();
|
||||
|
||||
project "ZoneCommonTests"
|
||||
project(self:name())
|
||||
targetdir(TargetDirectoryTest)
|
||||
location "%{wks.location}/test/%{prj.name}"
|
||||
kind "SharedLib"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
|
||||
files {
|
||||
@ -39,6 +47,7 @@ function ZoneCommonTests:project()
|
||||
|
||||
self:include()
|
||||
ZoneCommon:include()
|
||||
catch2:include()
|
||||
|
||||
ZoneCommon:link()
|
||||
|
||||
|
2
test/ZoneCommonTests/main.cpp
Normal file
2
test/ZoneCommonTests/main.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
Reference in New Issue
Block a user