Skip to content

Commit

Permalink
Unit testing framework complete!
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaFriend committed Oct 18, 2018
1 parent a46f515 commit 9f30f5e
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 7 deletions.
13 changes: 13 additions & 0 deletions Light Vox Engine.sln
Expand Up @@ -5,6 +5,11 @@ VisualStudioVersion = 15.0.28010.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Light Vox Engine", "Light Vox Engine\Light Vox Engine.vcxproj", "{5D4FABF3-0580-4263-B996-D711CC8064BE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LightVox_UnitTests", "LightVox_UnitTests\LightVox_UnitTests.vcxproj", "{7F443EDB-34C8-480F-A210-072357CEC8C9}"
ProjectSection(ProjectDependencies) = postProject
{5D4FABF3-0580-4263-B996-D711CC8064BE} = {5D4FABF3-0580-4263-B996-D711CC8064BE}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All @@ -21,6 +26,14 @@ Global
{5D4FABF3-0580-4263-B996-D711CC8064BE}.Release|x64.Build.0 = Release|x64
{5D4FABF3-0580-4263-B996-D711CC8064BE}.Release|x86.ActiveCfg = Release|Win32
{5D4FABF3-0580-4263-B996-D711CC8064BE}.Release|x86.Build.0 = Release|Win32
{7F443EDB-34C8-480F-A210-072357CEC8C9}.Debug|x64.ActiveCfg = Debug|x64
{7F443EDB-34C8-480F-A210-072357CEC8C9}.Debug|x64.Build.0 = Debug|x64
{7F443EDB-34C8-480F-A210-072357CEC8C9}.Debug|x86.ActiveCfg = Debug|Win32
{7F443EDB-34C8-480F-A210-072357CEC8C9}.Debug|x86.Build.0 = Debug|Win32
{7F443EDB-34C8-480F-A210-072357CEC8C9}.Release|x64.ActiveCfg = Release|x64
{7F443EDB-34C8-480F-A210-072357CEC8C9}.Release|x64.Build.0 = Release|x64
{7F443EDB-34C8-480F-A210-072357CEC8C9}.Release|x86.ActiveCfg = Release|Win32
{7F443EDB-34C8-480F-A210-072357CEC8C9}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions LightVox_UnitTests/LightVox_UnitTests.vcxproj
Expand Up @@ -152,6 +152,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\Light Vox Engine\JobSystem\ConcurrentQueue.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
Expand All @@ -164,6 +165,11 @@
</ClCompile>
<ClCompile Include="unittest1.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Light Vox Engine\Light Vox Engine.vcxproj">
<Project>{5d4fabf3-0580-4263-b996-d711cc8064be}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
6 changes: 6 additions & 0 deletions LightVox_UnitTests/LightVox_UnitTests.vcxproj.filters
Expand Up @@ -13,6 +13,9 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Source Files\Source">
<UniqueIdentifier>{8df04cd4-6a69-4680-a145-1998b49a90fc}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
Expand All @@ -21,6 +24,9 @@
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\Light Vox Engine\JobSystem\ConcurrentQueue.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
Expand Down
40 changes: 33 additions & 7 deletions LightVox_UnitTests/unittest1.cpp
@@ -1,19 +1,45 @@
#include "stdafx.h"
#include "CppUnitTest.h"

#include "../Light Vox Engine/JobSystem/ConcurrentQueue.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace LightVox_UnitTests
{
TEST_CLASS(UnitTest1)
TEST_CLASS( ConcurrentQueueTests )
{
public:

TEST_METHOD(TestMethod1)
{
// TODO: Your test code here
Assert::AreEqual( 1, 1 );
}

TEST_METHOD( EmplaceTest )
{
ConcurrentQueue<int> TestQueue;
size_t addedVals = 2;
int val1 = 10;
int val2 = 15;
//int val3 = 10;

TestQueue.emplace_front( val1 );
TestQueue.emplace_front( val2 );

int outVal;
TestQueue.pop_front( outVal );

// TODO: Your test code here
Assert::AreEqual( outVal, val2 );
}

TEST_METHOD( SizeTest )
{
ConcurrentQueue<int> TestQueue;
size_t addedVals = 2;

TestQueue.emplace_front( 10 );
TestQueue.emplace_front( 15 );

Assert::AreEqual( TestQueue.size(), addedVals );

}

};
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17134.0
Debug|x64|C:\Git_Fast\light-vox-engine\|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added LightVox_UnitTests/x64/Debug/vc141.idb
Binary file not shown.
22 changes: 22 additions & 0 deletions unitTesting.md
@@ -0,0 +1,22 @@
## Unit Testing Guide in Visual C++

Here are some steps for doing some basic Unit Testing using Visual C++'s
native framework.

You will notice that there are not two `vcprocj` files in the solution, the
`Light Vox Engine` and the `LightVox_UnitTests`

In order to write Unit Tests for your code, there are a few steps simple steps
to take.

1. Add the existing header and source files to the Unit Testing project if you
need to test a new file.
- Right click on the `Header Files` folder in the Unit Testing project, click
"Add Existing" and add the necessary `.h` file. This is necessary for proper
linking of the test project.
- Right click on the `Source` folder underneath the `Source Files` folder in
the Unit Testing project, and add the necessary `.cpp` file.
2. Create a new `TEST_CLASS` if you are testing a new class that doesn't have any existing unit tests.
3. Write you `TEST_METHOD`s inside that test class!
- There a lot of ways to write your unit tests, but the simplest way is with
the `Assert` functionality.
Binary file added x64/Debug/LightVox_UnitTests.exp
Binary file not shown.

0 comments on commit 9f30f5e

Please sign in to comment.