summary refs log tree commit diff stats
path: root/Test
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2018-11-05 10:06:37 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2018-11-05 10:06:37 -0800
commit669717268201197412c69df36e65883b0af6fac8 (patch)
tree6345c3acd1ca42bbd31c3702e649a09512e5aed6 /Test
parenta828620c6447e8c51f6e9d1767eabe0fc5ade0a0 (diff)
downloadwitness-tutorializer-669717268201197412c69df36e65883b0af6fac8.tar.gz
witness-tutorializer-669717268201197412c69df36e65883b0af6fac8.tar.bz2
witness-tutorializer-669717268201197412c69df36e65883b0af6fac8.zip
Tests work now, + other cleanup
Diffstat (limited to 'Test')
-rw-r--r--Test/Foo.cpp11
-rw-r--r--Test/RandomTests.cpp36
-rw-r--r--Test/Test.vcxproj46
-rw-r--r--Test/packages.config2
4 files changed, 56 insertions, 39 deletions
diff --git a/Test/Foo.cpp b/Test/Foo.cpp deleted file mode 100644 index d9d155e..0000000 --- a/Test/Foo.cpp +++ /dev/null
@@ -1,11 +0,0 @@
1#include "gtest/gtest.h"
2#include "Random.h"
3
4TEST(Foo, Bar) {
5 int random1 = Random::RandInt(0, 1 << 30);
6 int random2 = Random::RandInt(0, 1 << 30);
7 ASSERT_NE(random1, random2);
8 int random3 = Random::RandInt(random1, random2);
9 ASSERT_GE(random3, random1);
10 ASSERT_LT(random3, random2);
11}
diff --git a/Test/RandomTests.cpp b/Test/RandomTests.cpp new file mode 100644 index 0000000..a322752 --- /dev/null +++ b/Test/RandomTests.cpp
@@ -0,0 +1,36 @@
1#include "gtest/gtest.h"
2#include "Random.h"
3
4TEST(RandomTests, RandomInRange) {
5 int random1 = Random::RandInt(0, 1 << 30);
6 int random2 = Random::RandInt(0, 1 << 30);
7 ASSERT_NE(random1, random2);
8 if (random1 > random2) std::swap(random1, random2);
9 int random3 = Random::RandInt(random1, random2);
10 std::cout << random1 << " " << random2 << " " << random3 << std::endl;
11 ASSERT_GE(random3, random1);
12 ASSERT_LE(random3, random2);
13}
14
15TEST(RandomTests, SeedWorks) {
16 Random::SetSeed(0);
17 ASSERT_EQ(2531011, Random::RandInt(0, 1 << 30));
18 ASSERT_EQ(505908858, Random::RandInt(0, 1 << 30));
19 ASSERT_EQ(318135124, Random::RandInt(0, 1 << 30));
20 ASSERT_EQ(159719620, Random::RandInt(0, 1 << 30));
21 Random::SetSeed(0);
22 ASSERT_EQ(2531011, Random::RandInt(0, 1 << 30));
23}
24
25TEST(RandomTests, SeedChangesInitialValue) {
26 Random::SetSeed(0);
27 int random1 = Random::RandInt(0, 1 << 30);
28 Random::SetSeed(1);
29 int random2 = Random::RandInt(0, 1 << 30);
30 ASSERT_NE(random1, random2);
31
32 Random::SetSeed(2);
33 int random3 = Random::RandInt(0, 1 << 30);
34 ASSERT_NE(random3, random1);
35 ASSERT_NE(random3, random2);
36} \ No newline at end of file
diff --git a/Test/Test.vcxproj b/Test/Test.vcxproj index 36b192a..b53800b 100644 --- a/Test/Test.vcxproj +++ b/Test/Test.vcxproj
@@ -19,7 +19,7 @@
19 </ProjectConfiguration> 19 </ProjectConfiguration>
20 </ItemGroup> 20 </ItemGroup>
21 <PropertyGroup Label="Globals"> 21 <PropertyGroup Label="Globals">
22 <ProjectGuid>{2208ee21-5366-4042-89d6-1a3c4bd79ad4}</ProjectGuid> 22 <ProjectGuid>{128784c2-9157-4291-8fd6-44637be162fb}</ProjectGuid>
23 <Keyword>Win32Proj</Keyword> 23 <Keyword>Win32Proj</Keyword>
24 <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion> 24 <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
25 <ConfigurationType>Application</ConfigurationType> 25 <ConfigurationType>Application</ConfigurationType>
@@ -32,38 +32,33 @@
32 <ImportGroup Label="Shared" /> 32 <ImportGroup Label="Shared" />
33 <ImportGroup Label="PropertySheets" /> 33 <ImportGroup Label="PropertySheets" />
34 <PropertyGroup Label="UserMacros" /> 34 <PropertyGroup Label="UserMacros" />
35 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> 35 <ItemGroup>
36 <IncludePath>$(IncludePath)</IncludePath> 36 <ClCompile Include="RandomTests.cpp" />
37 </PropertyGroup> 37 </ItemGroup>
38 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
39 <IncludePath>$(IncludePath)</IncludePath>
40 </PropertyGroup>
41 <ItemGroup> 38 <ItemGroup>
42 <ProjectReference Include="..\Source\Source.vcxproj"> 39 <ProjectReference Include="..\Source\Source.vcxproj">
43 <Project>{5c019bea-e0b4-4215-825f-6a228cd3ae27}</Project> 40 <Project>{6b5df051-a51a-48cb-8acd-c6fad726019f}</Project>
44 </ProjectReference> 41 </ProjectReference>
45 </ItemGroup> 42 </ItemGroup>
46 <ItemGroup> 43 <ItemGroup>
47 <None Include="packages.config" /> 44 <None Include="packages.config" />
48 </ItemGroup> 45 </ItemGroup>
49 <ItemGroup>
50 <ClCompile Include="Foo.cpp" />
51 </ItemGroup>
52 <ItemDefinitionGroup /> 46 <ItemDefinitionGroup />
53 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> 47 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
54 <ImportGroup Label="ExtensionTargets"> 48 <ImportGroup Label="ExtensionTargets">
55 <Import Project="..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets" Condition="Exists('..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets')" /> 49 <Import Project="..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-static.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-static.targets" Condition="Exists('..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-static.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-static.targets')" />
56 </ImportGroup> 50 </ImportGroup>
57 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> 51 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
58 <ClCompile> 52 <ClCompile>
59 <PrecompiledHeader>Use</PrecompiledHeader> 53 <PrecompiledHeader>NotUsing</PrecompiledHeader>
60 <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> 54 <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
61 <Optimization>Disabled</Optimization> 55 <Optimization>Disabled</Optimization>
62 <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> 56 <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
63 <MinimalRebuild>true</MinimalRebuild> 57 <MinimalRebuild>true</MinimalRebuild>
64 <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> 58 <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
65 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> 59 <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
66 <WarningLevel>Level3</WarningLevel> 60 <WarningLevel>Level3</WarningLevel>
61 <AdditionalIncludeDirectories>C:\Users\localhost\Documents\GitHub\WitnessRandomizer\Source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
67 </ClCompile> 62 </ClCompile>
68 <Link> 63 <Link>
69 <GenerateDebugInformation>true</GenerateDebugInformation> 64 <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -78,11 +73,9 @@
78 <PreprocessorDefinitions>X64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> 73 <PreprocessorDefinitions>X64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
79 <MinimalRebuild>true</MinimalRebuild> 74 <MinimalRebuild>true</MinimalRebuild>
80 <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> 75 <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
81 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> 76 <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
82 <WarningLevel>Level2</WarningLevel> 77 <WarningLevel>Level3</WarningLevel>
83 <DisableSpecificWarnings>4996</DisableSpecificWarnings> 78 <AdditionalIncludeDirectories>C:\Users\localhost\Documents\GitHub\WitnessRandomizer\Source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
84 <TreatWarningAsError>true</TreatWarningAsError>
85 <AdditionalIncludeDirectories>C:\Users\localhost\Documents\GitHub\witness-randomizer\Source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
86 </ClCompile> 79 </ClCompile>
87 <Link> 80 <Link>
88 <GenerateDebugInformation>true</GenerateDebugInformation> 81 <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -91,12 +84,13 @@
91 </ItemDefinitionGroup> 84 </ItemDefinitionGroup>
92 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> 85 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
93 <ClCompile> 86 <ClCompile>
94 <PrecompiledHeader>Use</PrecompiledHeader> 87 <PrecompiledHeader>NotUsing</PrecompiledHeader>
95 <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> 88 <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
96 <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> 89 <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
97 <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> 90 <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
98 <WarningLevel>Level3</WarningLevel> 91 <WarningLevel>Level3</WarningLevel>
99 <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> 92 <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
93 <AdditionalIncludeDirectories>C:\Users\localhost\Documents\GitHub\WitnessRandomizer\Source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
100 </ClCompile> 94 </ClCompile>
101 <Link> 95 <Link>
102 <GenerateDebugInformation>true</GenerateDebugInformation> 96 <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -110,12 +104,10 @@
110 <PrecompiledHeader>NotUsing</PrecompiledHeader> 104 <PrecompiledHeader>NotUsing</PrecompiledHeader>
111 <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> 105 <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
112 <PreprocessorDefinitions>X64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> 106 <PreprocessorDefinitions>X64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
113 <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> 107 <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
114 <WarningLevel>Level2</WarningLevel> 108 <WarningLevel>Level3</WarningLevel>
115 <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> 109 <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
116 <DisableSpecificWarnings>4996</DisableSpecificWarnings> 110 <AdditionalIncludeDirectories>C:\Users\localhost\Documents\GitHub\WitnessRandomizer\Source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
117 <TreatWarningAsError>true</TreatWarningAsError>
118 <AdditionalIncludeDirectories>C:\Users\localhost\Documents\GitHub\witness-randomizer\Source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
119 </ClCompile> 111 </ClCompile>
120 <Link> 112 <Link>
121 <GenerateDebugInformation>true</GenerateDebugInformation> 113 <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -128,6 +120,6 @@
128 <PropertyGroup> 120 <PropertyGroup>
129 <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> 121 <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
130 </PropertyGroup> 122 </PropertyGroup>
131 <Error Condition="!Exists('..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets'))" /> 123 <Error Condition="!Exists('..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-static.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-static.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-static.1.8.0\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-static.targets'))" />
132 </Target> 124 </Target>
133</Project> \ No newline at end of file 125</Project> \ No newline at end of file
diff --git a/Test/packages.config b/Test/packages.config index 0acd30a..1dcab87 100644 --- a/Test/packages.config +++ b/Test/packages.config
@@ -1,4 +1,4 @@
1<?xml version="1.0" encoding="utf-8"?> 1<?xml version="1.0" encoding="utf-8"?>
2<packages> 2<packages>
3 <package id="Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn" version="1.8.0" targetFramework="native" /> 3 <package id="Microsoft.googletest.v140.windesktop.msvcstl.static.rt-static" version="1.8.0" targetFramework="native" />
4</packages> \ No newline at end of file 4</packages> \ No newline at end of file