From 669717268201197412c69df36e65883b0af6fac8 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Mon, 5 Nov 2018 10:06:37 -0800 Subject: Tests work now, + other cleanup --- Test/Foo.cpp | 11 ----------- Test/RandomTests.cpp | 36 ++++++++++++++++++++++++++++++++++++ Test/Test.vcxproj | 46 +++++++++++++++++++--------------------------- Test/packages.config | 2 +- 4 files changed, 56 insertions(+), 39 deletions(-) delete mode 100644 Test/Foo.cpp create mode 100644 Test/RandomTests.cpp (limited to 'Test') 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 @@ -#include "gtest/gtest.h" -#include "Random.h" - -TEST(Foo, Bar) { - int random1 = Random::RandInt(0, 1 << 30); - int random2 = Random::RandInt(0, 1 << 30); - ASSERT_NE(random1, random2); - int random3 = Random::RandInt(random1, random2); - ASSERT_GE(random3, random1); - ASSERT_LT(random3, random2); -} 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 @@ +#include "gtest/gtest.h" +#include "Random.h" + +TEST(RandomTests, RandomInRange) { + int random1 = Random::RandInt(0, 1 << 30); + int random2 = Random::RandInt(0, 1 << 30); + ASSERT_NE(random1, random2); + if (random1 > random2) std::swap(random1, random2); + int random3 = Random::RandInt(random1, random2); + std::cout << random1 << " " << random2 << " " << random3 << std::endl; + ASSERT_GE(random3, random1); + ASSERT_LE(random3, random2); +} + +TEST(RandomTests, SeedWorks) { + Random::SetSeed(0); + ASSERT_EQ(2531011, Random::RandInt(0, 1 << 30)); + ASSERT_EQ(505908858, Random::RandInt(0, 1 << 30)); + ASSERT_EQ(318135124, Random::RandInt(0, 1 << 30)); + ASSERT_EQ(159719620, Random::RandInt(0, 1 << 30)); + Random::SetSeed(0); + ASSERT_EQ(2531011, Random::RandInt(0, 1 << 30)); +} + +TEST(RandomTests, SeedChangesInitialValue) { + Random::SetSeed(0); + int random1 = Random::RandInt(0, 1 << 30); + Random::SetSeed(1); + int random2 = Random::RandInt(0, 1 << 30); + ASSERT_NE(random1, random2); + + Random::SetSeed(2); + int random3 = Random::RandInt(0, 1 << 30); + ASSERT_NE(random3, random1); + ASSERT_NE(random3, random2); +} \ 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 @@ - {2208ee21-5366-4042-89d6-1a3c4bd79ad4} + {128784c2-9157-4291-8fd6-44637be162fb} Win32Proj 10.0.17134.0 Application @@ -32,38 +32,33 @@ - - $(IncludePath) - - - $(IncludePath) - + + + - {5c019bea-e0b4-4215-825f-6a228cd3ae27} + {6b5df051-a51a-48cb-8acd-c6fad726019f} - - - - + - Use + NotUsing pch.h Disabled WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebugDLL + MultiThreadedDebug Level3 + C:\Users\localhost\Documents\GitHub\WitnessRandomizer\Source;%(AdditionalIncludeDirectories) true @@ -78,11 +73,9 @@ X64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebugDLL - Level2 - 4996 - true - C:\Users\localhost\Documents\GitHub\witness-randomizer\Source;%(AdditionalIncludeDirectories) + MultiThreadedDebug + Level3 + C:\Users\localhost\Documents\GitHub\WitnessRandomizer\Source;%(AdditionalIncludeDirectories) true @@ -91,12 +84,13 @@ - Use + NotUsing pch.h WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL + MultiThreaded Level3 ProgramDatabase + C:\Users\localhost\Documents\GitHub\WitnessRandomizer\Source;%(AdditionalIncludeDirectories) true @@ -110,12 +104,10 @@ NotUsing pch.h X64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - Level2 + MultiThreaded + Level3 ProgramDatabase - 4996 - true - C:\Users\localhost\Documents\GitHub\witness-randomizer\Source;%(AdditionalIncludeDirectories) + C:\Users\localhost\Documents\GitHub\WitnessRandomizer\Source;%(AdditionalIncludeDirectories) true @@ -128,6 +120,6 @@ 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}. - + \ 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 @@  - + \ No newline at end of file -- cgit 1.4.1