mirror of
https://github.com/antopilo/Nuake.git
synced 2025-12-30 21:49:06 +03:00
Added catch2
This commit is contained in:
@@ -85,6 +85,11 @@ namespace Nuake
|
||||
cursor["file" + displayName] = value.file->GetRelativePath();
|
||||
}
|
||||
}
|
||||
else if (dataType.type() == entt::resolve<std::string>())
|
||||
{
|
||||
std::string value = fieldVal.cast<std::string>();
|
||||
cursor[displayName] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return jsonSnippet;
|
||||
|
||||
10
Test/.runsettings
Normal file
10
Test/.runsettings
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RunSettings>
|
||||
|
||||
<Catch2Adapter>
|
||||
<CombinedTimeout>30000</CombinedTimeout><!-- 30s in Milliseconds -->
|
||||
<FilenameFilter>.*</FilenameFilter>
|
||||
<DllRunnerCommandline>${catch2} ${dll}</DllRunnerCommandline>
|
||||
</Catch2Adapter>
|
||||
|
||||
</RunSettings>
|
||||
79
Test/NuakeTest/Source/SerializationTest.cpp
Normal file
79
Test/NuakeTest/Source/SerializationTest.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
#include "catch2/catch_amalgamated.hpp"
|
||||
#include "Nuake/Scene/Components/Component.h"
|
||||
#include "Nuake/Resource/Serializer/ComponentSerializer.h"
|
||||
|
||||
#include "entt/entt.hpp"
|
||||
|
||||
namespace Serialization
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
class TestData : public Component
|
||||
{
|
||||
NUAKECOMPONENT(TestData, "TestData");
|
||||
|
||||
public:
|
||||
int myInt;
|
||||
bool myBool;
|
||||
std::string myString;
|
||||
Vector2 myVec2;
|
||||
Vector3 myVec3;
|
||||
Vector4 myVec4;
|
||||
|
||||
static void InitializeComponentClass()
|
||||
{
|
||||
BindComponentField<&TestData::myInt>("myInt", "myInt");
|
||||
BindComponentField<&TestData::myBool>("myBool", "myBool");
|
||||
BindComponentField<&TestData::myString>("myString", "myString");
|
||||
BindComponentField<&TestData::myVec2>("myVec2", "myVec2");
|
||||
BindComponentField<&TestData::myVec3>("myVec3", "myVec3");
|
||||
BindComponentField<&TestData::myVec4>("myVec4", "myVec4");
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CASE("Serialize Struct", "[Serialization]")
|
||||
{
|
||||
// Initialize component
|
||||
TestData::InternalInitializeClass();
|
||||
TestData testData =
|
||||
{
|
||||
.myInt = 1337,
|
||||
.myBool = true,
|
||||
.myString = "Hello World",
|
||||
.myVec2 = Vector2(1, 2),
|
||||
.myVec3 = Vector3(3, 4, 5),
|
||||
.myVec4 = Vector4(6, 7, 8, 9)
|
||||
};
|
||||
|
||||
// Serialize into json
|
||||
ComponentSerializer serializer;
|
||||
json result = serializer.Serialize(testData);
|
||||
|
||||
// Test JSON result
|
||||
REQUIRE(result.contains("TestData"));
|
||||
|
||||
REQUIRE(result["TestData"].contains("myInt"));
|
||||
REQUIRE(result["TestData"]["myInt"] == testData.myInt);
|
||||
|
||||
REQUIRE(result["TestData"].contains("myBool"));
|
||||
REQUIRE(result["TestData"]["myBool"] == testData.myBool);
|
||||
|
||||
REQUIRE(result["TestData"].contains("myString"));
|
||||
REQUIRE(result["TestData"]["myString"] == testData.myString);
|
||||
|
||||
REQUIRE(result["TestData"].contains("myVec2"));
|
||||
REQUIRE(result["TestData"]["myVec2"]["x"] == testData.myVec2.x);
|
||||
REQUIRE(result["TestData"]["myVec2"]["y"] == testData.myVec2.y);
|
||||
|
||||
REQUIRE(result["TestData"].contains("myVec3"));
|
||||
REQUIRE(result["TestData"]["myVec3"]["x"] == testData.myVec3.x);
|
||||
REQUIRE(result["TestData"]["myVec3"]["y"] == testData.myVec3.y);
|
||||
REQUIRE(result["TestData"]["myVec3"]["z"] == testData.myVec3.z);
|
||||
|
||||
REQUIRE(result["TestData"].contains("myVec4"));
|
||||
REQUIRE(result["TestData"]["myVec4"]["x"] == testData.myVec4.x);
|
||||
REQUIRE(result["TestData"]["myVec4"]["y"] == testData.myVec4.y);
|
||||
REQUIRE(result["TestData"]["myVec4"]["z"] == testData.myVec4.z);
|
||||
REQUIRE(result["TestData"]["myVec4"]["w"] == testData.myVec4.w);
|
||||
}
|
||||
}
|
||||
24
Test/NuakeTest/Source/main.cpp
Normal file
24
Test/NuakeTest/Source/main.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "catch2/catch_amalgamated.hpp"
|
||||
#define CATCH_CONFIG_MAIN
|
||||
|
||||
#include "Engine.h"
|
||||
|
||||
|
||||
namespace Engine
|
||||
{
|
||||
TEST_CASE("Window creation", "[window]")
|
||||
{
|
||||
Nuake::Engine::Init();
|
||||
|
||||
REQUIRE(Nuake::Engine::GetCurrentWindow() != nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("Window shutdown", "[window]")
|
||||
{
|
||||
Nuake::Engine::Init();
|
||||
|
||||
Nuake::Engine::GetCurrentWindow()->Close();
|
||||
|
||||
REQUIRE(Nuake::Engine::GetCurrentWindow()->ShouldClose());
|
||||
}
|
||||
}
|
||||
11817
Test/NuakeTest/Vendors/catch2/catch_amalgamated.cpp
Normal file
11817
Test/NuakeTest/Vendors/catch2/catch_amalgamated.cpp
Normal file
File diff suppressed because it is too large
Load Diff
14135
Test/NuakeTest/Vendors/catch2/catch_amalgamated.hpp
Normal file
14135
Test/NuakeTest/Vendors/catch2/catch_amalgamated.hpp
Normal file
File diff suppressed because it is too large
Load Diff
76
Test/NuakeTest/premake5.lua
Normal file
76
Test/NuakeTest/premake5.lua
Normal file
@@ -0,0 +1,76 @@
|
||||
project "NuakeTest"
|
||||
kind "ConsoleApp"
|
||||
staticruntime "On"
|
||||
language "C++"
|
||||
cppdialect "C++20"
|
||||
|
||||
defines
|
||||
{
|
||||
table.unpack(globalDefines),
|
||||
|
||||
"_MBCS",
|
||||
"IMGUI_DEFINE_MATH_OPERATORS",
|
||||
"NK_VK",
|
||||
"IMGUI_IMPL_VULKAN_NO_PROTOTYPES"
|
||||
}
|
||||
|
||||
targetdir (binaryOutputDir)
|
||||
objdir (intBinaryOutputDir)
|
||||
debugdir (binaryOutputDir)
|
||||
|
||||
files
|
||||
{
|
||||
-- Main Sources
|
||||
"Source/**.cpp",
|
||||
"Source/**.h",
|
||||
"Vendors/**.h",
|
||||
"Vendors/**.cpp",
|
||||
}
|
||||
|
||||
includedirs
|
||||
{
|
||||
".",
|
||||
"Source",
|
||||
"Vendors",
|
||||
"../../Nuake/Source",
|
||||
"../../Nuake/Vendors",
|
||||
"../../Nuake/Thirdparty/entt/src"
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
"Nuake",
|
||||
"glad",
|
||||
"GLFW",
|
||||
"assimp",
|
||||
"JoltPhysics",
|
||||
"soloud",
|
||||
"Coral.Native",
|
||||
"DebugUtils",
|
||||
"Detour",
|
||||
"DetourCrowd",
|
||||
"DetourTileCache",
|
||||
"Recast",
|
||||
"tracy",
|
||||
"yoga",
|
||||
"msdf-gen",
|
||||
"msdf-atlas-gen",
|
||||
"Freetype",
|
||||
"vma"
|
||||
}
|
||||
|
||||
filter { "system:windows", "action:vs*"}
|
||||
flags
|
||||
{
|
||||
"MultiProcessorCompile",
|
||||
}
|
||||
|
||||
filter "configurations:Debug"
|
||||
runtime "Debug"
|
||||
symbols "on"
|
||||
|
||||
buildoptions { "/Zi" }
|
||||
|
||||
filter "configurations:Release"
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
1
Test/premake5.lua
Normal file
1
Test/premake5.lua
Normal file
@@ -0,0 +1 @@
|
||||
include "NuakeTest/premake5.lua"
|
||||
@@ -84,3 +84,4 @@ include "Runtime/premake5.lua"
|
||||
include "NuakeNet/premake5.lua"
|
||||
include "NuakeNetGenerator/premake5.lua"
|
||||
include "EditorNet/premake5.lua"
|
||||
include "Test/premake5.lua"
|
||||
|
||||
Reference in New Issue
Block a user