diff --git a/OpenAssetTools.sln b/OpenAssetTools.sln index 1488f7d0..91b0bb21 100644 --- a/OpenAssetTools.sln +++ b/OpenAssetTools.sln @@ -67,6 +67,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Unlinker", "src\Unlinker\Un {2A92076F-6DFD-4FB1-9E6A-4542B4B049C7} = {2A92076F-6DFD-4FB1-9E6A-4542B4B049C7} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZoneCommonTests", "test\ZoneCommonTests\ZoneCommonTests.vcxproj", "{D85EBA7C-442B-4627-AEB9-6B5965DDC449}" + ProjectSection(ProjectDependencies) = postProject + {D1C20C32-9CB8-44B8-9DF7-F0CF8FB304D3} = {D1C20C32-9CB8-44B8-9DF7-F0CF8FB304D3} + {2A92076F-6DFD-4FB1-9E6A-4542B4B049C7} = {2A92076F-6DFD-4FB1-9E6A-4542B4B049C7} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -203,6 +209,14 @@ Global {ED93C237-A96A-4332-B131-CAB4E46F1C48}.Release|x64.Build.0 = Release|x64 {ED93C237-A96A-4332-B131-CAB4E46F1C48}.Release|x86.ActiveCfg = Release|Win32 {ED93C237-A96A-4332-B131-CAB4E46F1C48}.Release|x86.Build.0 = Release|Win32 + {D85EBA7C-442B-4627-AEB9-6B5965DDC449}.Debug|x64.ActiveCfg = Debug|x64 + {D85EBA7C-442B-4627-AEB9-6B5965DDC449}.Debug|x64.Build.0 = Debug|x64 + {D85EBA7C-442B-4627-AEB9-6B5965DDC449}.Debug|x86.ActiveCfg = Debug|Win32 + {D85EBA7C-442B-4627-AEB9-6B5965DDC449}.Debug|x86.Build.0 = Debug|Win32 + {D85EBA7C-442B-4627-AEB9-6B5965DDC449}.Release|x64.ActiveCfg = Release|x64 + {D85EBA7C-442B-4627-AEB9-6B5965DDC449}.Release|x64.Build.0 = Release|x64 + {D85EBA7C-442B-4627-AEB9-6B5965DDC449}.Release|x86.ActiveCfg = Release|Win32 + {D85EBA7C-442B-4627-AEB9-6B5965DDC449}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -224,6 +238,7 @@ Global {599A7D9D-0CB8-4B99-AA2E-EA5EC081CF77} = {562895A0-B72F-4A89-9A10-DF97A5D35269} {FC57DC08-3496-4DCF-B52F-6EDC568B333C} = {562895A0-B72F-4A89-9A10-DF97A5D35269} {ED93C237-A96A-4332-B131-CAB4E46F1C48} = {EB945BC9-2451-4AB5-B434-BD07FAA2D06A} + {D85EBA7C-442B-4627-AEB9-6B5965DDC449} = {4D65E9A0-1798-4E93-A12F-128FFDC6A690} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {FBB5097F-0C5C-439C-8E82-19EF614DE3BE} diff --git a/src/ZoneCodeGenerator/Generating/CodeGenerator.cs b/src/ZoneCodeGenerator/Generating/CodeGenerator.cs index c2494d4a..d1dfb6ce 100644 --- a/src/ZoneCodeGenerator/Generating/CodeGenerator.cs +++ b/src/ZoneCodeGenerator/Generating/CodeGenerator.cs @@ -29,6 +29,9 @@ namespace ZoneCodeGenerator.Generating }, { "ZoneWrite", new GeneratorPreset("$asset/$asset_write_db", "ZoneWrite.stg") + }, + { + "AssetStructTests", new GeneratorPreset("$asset_struct_test", "AssetStructTests.stg") } }; diff --git a/src/ZoneCodeGenerator/Generating/Templates/AssetStructTests.stg b/src/ZoneCodeGenerator/Generating/Templates/AssetStructTests.stg new file mode 100644 index 00000000..aee47485 --- /dev/null +++ b/src/ZoneCodeGenerator/Generating/Templates/AssetStructTests.stg @@ -0,0 +1,41 @@ +delimiters "$", "$" + +import "Common.stg" + +TestMethod(structure) ::= << +$if(structure.NonEmbeddedReferenceExists)$ +TEST_METHOD(Test_$structure.Type.Name$) +{ + Assert::AreEqual($structure.Type.Size$u, sizeof($structure.Type.FullName$)); + Assert::AreEqual($structure.Type.Alignment$u, alignof($structure.Type.FullName$)); +} +$endif$ +>> + +// ======================= +// Source file entry point +// ======================= +source(context) ::= << +// ==================================================================== +// This file has been generated by ZoneCodeGenerator. +// Do not modify. +// Any changes will be discarded when regenerating. +// ==================================================================== + +#include "CppUnitTest.h" +#include "Game/$context.Game$/$context.Game$.h" + +using namespace Microsoft::VisualStudio::CppUnitTestFramework; +using namespace $context.Game$; + +namespace ZoneCommonTests +{ + TEST_CLASS(AssetStructTest_$context.Asset.Type.Name$) + { + public: + $TestMethod(context.Asset)$ + $context.Structures:{structure | $if(!structure.IsAsset)$$TestMethod(structure)$ + $endif$}$ + }; +} +>> \ No newline at end of file diff --git a/src/ZoneCodeGenerator/ZoneCodeGenerator.csproj b/src/ZoneCodeGenerator/ZoneCodeGenerator.csproj index abb1b0a5..ac9c7b11 100644 --- a/src/ZoneCodeGenerator/ZoneCodeGenerator.csproj +++ b/src/ZoneCodeGenerator/ZoneCodeGenerator.csproj @@ -165,6 +165,7 @@ + diff --git a/src/ZoneLoading/Game/T6/XAssets/T6_Load.gen b/src/ZoneLoading/Game/T6/XAssets/T6_Load.gen index 49356bf9..7bd8cb1e 100644 --- a/src/ZoneLoading/Game/T6/XAssets/T6_Load.gen +++ b/src/ZoneLoading/Game/T6/XAssets/T6_Load.gen @@ -1 +1 @@ -# This file exists for automatically generator zone loading code. \ No newline at end of file +# This file exists for automatically generating zone loading code. \ No newline at end of file diff --git a/test/ZoneCommonTests/Game/T6/XAssets/T6_AssetStructTests.gen b/test/ZoneCommonTests/Game/T6/XAssets/T6_AssetStructTests.gen new file mode 100644 index 00000000..ae5e7c26 --- /dev/null +++ b/test/ZoneCommonTests/Game/T6/XAssets/T6_AssetStructTests.gen @@ -0,0 +1 @@ +# This file exists for automatically generating tests to ensure the asset structs match their intended sizes, alignments and offsets \ No newline at end of file diff --git a/test/ZoneCommonTests/ZoneCommonTests.vcxproj b/test/ZoneCommonTests/ZoneCommonTests.vcxproj new file mode 100644 index 00000000..67c49e2e --- /dev/null +++ b/test/ZoneCommonTests/ZoneCommonTests.vcxproj @@ -0,0 +1,236 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {D85EBA7C-442B-4627-AEB9-6B5965DDC449} + Win32Proj + ZoneCommonTests + 10.0.17763.0 + NativeUnitTestProject + + + + DynamicLibrary + true + v141 + Unicode + false + + + DynamicLibrary + false + v141 + true + Unicode + false + + + DynamicLibrary + true + v141 + Unicode + false + + + DynamicLibrary + false + v141 + true + Unicode + false + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)bin\$(Configuration)_$(Platform)\ + $(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\ + + + true + $(SolutionDir)bin\$(Configuration)_$(Platform)\ + $(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\ + + + true + $(SolutionDir)bin\$(Configuration)_$(Platform)\ + $(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\ + + + true + $(SolutionDir)bin\$(Configuration)_$(Platform)\ + $(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\ + + + + Level3 + Disabled + $(VCInstallDir)UnitTest\include;$(SolutionDir)src\ZoneCommon;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;%(PreprocessorDefinitions) + true + + + Windows + $(VCInstallDir)UnitTest\lib;$(SolutionDir)lib\$(Configuration)_$(Platform)\;%(AdditionalLibraryDirectories) + ZoneCommon.lib;%(AdditionalDependencies) + + + + + Level3 + Disabled + $(VCInstallDir)UnitTest\include;$(SolutionDir)src\ZoneCommon;%(AdditionalIncludeDirectories) + _DEBUG;%(PreprocessorDefinitions) + true + + + Windows + $(VCInstallDir)UnitTest\lib;$(SolutionDir)lib\$(Configuration)_$(Platform)\;%(AdditionalLibraryDirectories) + ZoneCommon.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + $(VCInstallDir)UnitTest\include;$(SolutionDir)src\ZoneCommon;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + $(VCInstallDir)UnitTest\lib;$(SolutionDir)lib\$(Configuration)_$(Platform)\;%(AdditionalLibraryDirectories) + ZoneCommon.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + $(VCInstallDir)UnitTest\include;$(SolutionDir)src\ZoneCommon;%(AdditionalIncludeDirectories) + NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + $(VCInstallDir)UnitTest\lib;$(SolutionDir)lib\$(Configuration)_$(Platform)\;%(AdditionalLibraryDirectories) + ZoneCommon.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Document + Generating asset struct tests: %(Filename) + Generating asset struct tests: %(Filename) + Generating asset struct tests: %(Filename) + Generating asset struct tests: %(Filename) + "$(SolutionDir)src\ZoneCodeGenerator\bin\$(Configuration)\ZoneCodeGenerator.exe" -h "$(SolutionDir)src\ZoneCode\T6\T6.h" -e "$(SolutionDir)src\ZoneCode\T6\T6_Commands.txt" -o "%(RelativeDir)gen" -g "*" "AssetStructTests" + "$(SolutionDir)src\ZoneCodeGenerator\bin\$(Configuration)\ZoneCodeGenerator.exe" -h "$(SolutionDir)src\ZoneCode\T6\T6.h" -e "$(SolutionDir)src\ZoneCode\T6\T6_Commands.txt" -o "%(RelativeDir)gen" -g "*" "AssetStructTests" + "$(SolutionDir)src\ZoneCodeGenerator\bin\$(Configuration)\ZoneCodeGenerator.exe" -h "$(SolutionDir)src\ZoneCode\T6\T6.h" -e "$(SolutionDir)src\ZoneCode\T6\T6_Commands.txt" -o "%(RelativeDir)gen" -g "*" "AssetStructTests" + "$(SolutionDir)src\ZoneCodeGenerator\bin\$(Configuration)\ZoneCodeGenerator.exe" -h "$(SolutionDir)src\ZoneCode\T6\T6.h" -e "$(SolutionDir)src\ZoneCode\T6\T6_Commands.txt" -o "%(RelativeDir)gen" -g "*" "AssetStructTests" + $(SolutionDir)src\ZoneCodeGenerator\bin\$(Configuration)\ZoneCodeGenerator.exe;$(SolutionDir)src\ZoneCode\T6\T6.h;$(SolutionDir)src\ZoneCode\T6\T6_Commands.txt;%(AdditionalInputs) + $(SolutionDir)src\ZoneCodeGenerator\bin\$(Configuration)\ZoneCodeGenerator.exe;$(SolutionDir)src\ZoneCode\T6\T6.h;$(SolutionDir)src\ZoneCode\T6\T6_Commands.txt;%(AdditionalInputs) + $(SolutionDir)src\ZoneCodeGenerator\bin\$(Configuration)\ZoneCodeGenerator.exe;$(SolutionDir)src\ZoneCode\T6\T6.h;$(SolutionDir)src\ZoneCode\T6\T6_Commands.txt;%(AdditionalInputs) + $(SolutionDir)src\ZoneCodeGenerator\bin\$(Configuration)\ZoneCodeGenerator.exe;$(SolutionDir)src\ZoneCode\T6\T6.h;$(SolutionDir)src\ZoneCode\T6\T6_Commands.txt;%(AdditionalInputs) + %(RelativeDir)gen\addonmapents_struct_test.cpp;%(Outputs) + %(RelativeDir)gen\addonmapents_struct_test.cpp;%(Outputs) + %(RelativeDir)gen\addonmapents_struct_test.cpp;%(Outputs) + %(RelativeDir)gen\addonmapents_struct_test.cpp;%(Outputs) + + + + + + \ No newline at end of file