From 1908e24a066965cfe3b1414058fbcb2c264ae372 Mon Sep 17 00:00:00 2001 From: Oleg Sych Date: Sun, 20 Dec 2015 11:21:29 -0800 Subject: [PATCH 1/3] - Change test to use simply.random instead of magic literals. - Upgrade test to latest versions of simply.assert and simply.utility. --- .gitignore | 1 + simply.collections.sln | 3 +- test/iterator_test.cpp | 87 +++++++++++++++++++++++------------------- test/packages.config | 5 ++- test/range_test.cpp | 9 +++-- test/stdafx.h | 1 + test/test.vcxproj | 10 +++-- 7 files changed, 65 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index 472455a..e099ea4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.*sdf *.user *.suo +*.VC.opendb /ipch /.vs /packages diff --git a/simply.collections.sln b/simply.collections.sln index bedceec..b20f394 100644 --- a/simply.collections.sln +++ b/simply.collections.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "src", "src\src.vcxproj", "{F99792FC-9EE5-4540-8D22-84AB92910790}" EndProject @@ -9,6 +9,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CAEF9C05-2AE8-471F-8301-5D158CDECCAC}" ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore appveyor.yml = appveyor.yml common.props = common.props README.md = README.md diff --git a/test/iterator_test.cpp b/test/iterator_test.cpp index dd4b9d1..16fb544 100644 --- a/test/iterator_test.cpp +++ b/test/iterator_test.cpp @@ -1,7 +1,9 @@ #include "stdafx.h" #include #include +#include #include +#include #include "stub_enumerable.h" #include "stub_enumerator.h" @@ -63,7 +65,7 @@ namespace simply TEST_METHOD(iterator_supports_standard_equal_algorithm) { - initializer_list expected { 40, 41, 42 }; + initializer_list expected { random(), random(), random() }; shared_ptr> enumerable { create_enumerable(expected) }; iterator begin { enumerable, iterator_position::before_first }; iterator end { enumerable, iterator_position::after_last }; @@ -98,15 +100,15 @@ namespace simply TEST_METHOD(copy_constructor_copies_enumerable_from_source) { - iterator source { create_enumerable({ 42 }), iterator_position::before_first }; + iterator source { create_enumerable({ random() }), iterator_position::before_first }; iterator sut { source }; assert::is_equal(*source, *sut); } TEST_METHOD(copy_constructor_copies_current_element_from_source) { - const int expected = 42; - iterator source { create_enumerable({ expected - 1, expected }), iterator_position::before_first }; + const int expected { random() }; + iterator source { create_enumerable({ random(), expected }), iterator_position::before_first }; ++source; iterator sut { source }; assert::is_equal(expected, *sut); @@ -114,8 +116,8 @@ namespace simply TEST_METHOD(copy_constructor_copies_enumerator_from_source) { - const int expected = 42; - iterator source { create_enumerable({ expected - 1, expected }), iterator_position::before_first }; + const int expected { random() }; + iterator source { create_enumerable({ random(), expected }), iterator_position::before_first }; *source; iterator sut { source }; ++sut; @@ -151,7 +153,7 @@ namespace simply TEST_METHOD(copy_assignment_operator_copies_enumerable_from_source) { - const int expected { 42 }; + const int expected { random() }; iterator source { create_enumerable({ expected }), iterator_position::before_first }; iterator target { create_enumerable({}), iterator_position::before_first };; target = source; @@ -160,8 +162,8 @@ namespace simply TEST_METHOD(copy_assignment_operator_copies_current_element_from_source) { - const int expected { 42 }; - iterator source { create_enumerable({ expected -1, expected }), iterator_position::before_first }; + const int expected { random() }; + iterator source { create_enumerable({ random(), expected }), iterator_position::before_first }; ++source; iterator target { create_enumerable({}), iterator_position::before_first }; target = source; @@ -170,8 +172,8 @@ namespace simply TEST_METHOD(copy_assignment_operator_copies_enumerator_from_source) { - const int expected { 42 }; - iterator source { create_enumerable({ expected - 1, expected }), iterator_position::before_first }; + const int expected { random() }; + iterator source { create_enumerable({ random(), expected }), iterator_position::before_first }; *source; iterator target { create_enumerable({}), iterator_position::before_first }; target = source; @@ -235,7 +237,7 @@ namespace simply TEST_METHOD(dereferencing_operator_throws_logic_error_when_invoked_after_last_element) { - iterator sut { create_enumerable({ 42 }), iterator_position::before_first }; + iterator sut { create_enumerable({ random() }), iterator_position::before_first }; ++sut; auto e = assert::throws([&] { *sut; }); assert::find("iterator cannot be dereferenced when it points after last enumerable element", e->what()); @@ -243,15 +245,17 @@ namespace simply TEST_METHOD(dereferencing_operator_creates_enumerator_and_gets_next_value_when_called_first_time) { - iterator sut { create_enumerable({ 42 }), iterator_position::before_first }; - assert::is_equal(42, *sut); + const int expected { random() }; + iterator sut { create_enumerable({ expected }), iterator_position::before_first }; + assert::is_equal(expected, *sut); } TEST_METHOD(dereferencing_operator_returns_same_value_when_called_second_time) { - iterator sut { create_enumerable({ 42 }), iterator_position::before_first }; + const int expected { random() }; + iterator sut { create_enumerable({ expected }), iterator_position::before_first }; *sut; - assert::is_equal(42, *sut); + assert::is_equal(expected, *sut); } #pragma endregion @@ -267,7 +271,7 @@ namespace simply TEST_METHOD(increment_operator_returns_reference_to_itself) { - iterator expected { create_enumerable({ 42 }), iterator_position::before_first }; + iterator expected { create_enumerable({ random() }), iterator_position::before_first }; iterator& actual = ++expected; assert::is_equal(&expected, &actual); } @@ -288,7 +292,7 @@ namespace simply TEST_METHOD(increment_operator_throws_logic_error_when_invoked_after_last_element) { - iterator sut { create_enumerable({ 42 }), iterator_position::before_first }; + iterator sut { create_enumerable({ random() }), iterator_position::before_first }; ++sut; auto e = assert::throws([&] { ++sut; }); assert::find("iterator cannot be incremented when it points after last enumerable element", e->what()); @@ -296,25 +300,28 @@ namespace simply TEST_METHOD(increment_operator_gets_first_element_before_getting_next) { - iterator sut { create_enumerable({ 41, 42 }), iterator_position::before_first }; + const int expected { random() }; + iterator sut { create_enumerable({ random(), expected }), iterator_position::before_first }; ++sut; - assert::is_equal(42, *sut); + assert::is_equal(expected, *sut); } TEST_METHOD(increment_operator_doesnt_get_first_element_after_previous_dereferencing) { - iterator sut { create_enumerable({ 41, 42 }), iterator_position::before_first }; + const int expected { random() }; + iterator sut { create_enumerable({ random(), expected }), iterator_position::before_first }; *sut; ++sut; - assert::is_equal(42, *sut); + assert::is_equal(expected, *sut); } TEST_METHOD(increment_operator_doesnt_get_first_element_after_previous_increment) { - iterator sut { create_enumerable({ 40, 41, 42 }), iterator_position::before_first }; + const int expected { random() }; + iterator sut { create_enumerable({ random(), random(), expected }), iterator_position::before_first }; ++sut; ++sut; - assert::is_equal(42, *sut); + assert::is_equal(expected, *sut); } TEST_METHOD(increment_operator_destroys_previouly_created_current_element) @@ -327,29 +334,29 @@ namespace simply TEST_METHOD(increment_operator_throws_logic_error_when_iterator_was_constructor_copied_from_previously_incremented_iterator_to_avoid_calling_get_next_of_enumerator_after_last_element) { - iterator source { create_enumerable({ 40, 41, 42 }), iterator_position::before_first }; - ++source; // enumerator.get_next(41) + iterator source { create_enumerable({ random(), random(), random() }), iterator_position::before_first }; + ++source; // enumerator.get_next(second) iterator sut { source }; // both sut and source now share the same enumerator - auto e = assert::throws([&] { ++sut; }); // attempt to enumerator.get_next(42) + auto e = assert::throws([&] { ++sut; }); // attempt to enumerator.get_next(third) assert::find("Incrementing iterator copied from previously incremented iterator is not supported.", e->what()); } TEST_METHOD(increment_operator_throws_logic_error_when_iterator_was_assignment_copied_from_previously_incremented_iterator_to_avoid_calling_get_next_of_enumerator_after_last_element) { - iterator source { create_enumerable({ 40, 41, 42 }), iterator_position::before_first }; - ++source; // enumerator.get_next(41) + iterator source { create_enumerable({ random(), random(), random() }), iterator_position::before_first }; + ++source; // enumerator.get_next(second) iterator sut { create_enumerable(), iterator_position::before_first }; sut = source; // both sut and source now share the same enumerator - auto e = assert::throws([&] { ++sut; }); // attempt to enumerator.get_next(42) + auto e = assert::throws([&] { ++sut; }); // attempt to enumerator.get_next(third) assert::find("Incrementing iterator copied from previously incremented iterator is not supported.", e->what()); } TEST_METHOD(increment_operator_throws_logic_error_when_constructor_copy_was_already_incremented_to_avoid_calling_get_next_of_enumerator_after_last_element) { - iterator sut { create_enumerable({ 41, 42 }), iterator_position::before_first }; - iterator target { sut }; // both sut and source now share the same enumerator - ++target; // enumerator.get_next(42) - auto e = assert::throws([&] { ++sut; }); // attempt to enumerator.get_next(41) + iterator sut { create_enumerable({ random(), random() }), iterator_position::before_first }; + iterator target { sut }; // both sut and target now share the same enumerator + ++target; // enumerator.get_next(second) + auto e = assert::throws([&] { ++sut; }); // attempt to enumerator.get_next(first) assert::find("Incrementing iterator copied from previously incremented iterator is not supported.", e->what()); } @@ -359,7 +366,7 @@ namespace simply TEST_METHOD(iterators_are_equal_when_they_are_both_before_first_element_of_same_enumerable) { - auto enumerable = create_enumerable({ 42 }); + auto enumerable = create_enumerable({ random() }); iterator x { enumerable, iterator_position::before_first }; iterator y { enumerable, iterator_position::before_first }; assert::is_true(x == y); @@ -368,7 +375,7 @@ namespace simply TEST_METHOD(iterators_are_equal_when_they_are_both_after_last_element_of_same_enumerable) { - auto enumerable = create_enumerable({ 42 }); + auto enumerable = create_enumerable({ random() }); iterator x { enumerable, iterator_position::after_last }; iterator y { enumerable, iterator_position::after_last }; assert::is_true(x == y); @@ -377,15 +384,15 @@ namespace simply TEST_METHOD(iterators_are_not_equal_when_they_point_to_different_enumerables_in_same_position) { - iterator x { create_enumerable({ 42 }), iterator_position::before_first }; - iterator y { create_enumerable({ 42 }), iterator_position::before_first }; + iterator x { create_enumerable({ random() }), iterator_position::before_first }; + iterator y { create_enumerable({ random() }), iterator_position::before_first }; assert::is_false(x == y); assert::is_true(x != y); } TEST_METHOD(iterators_are_not_equal_when_they_point_to_different_position_in_same_enumerables) { - auto enumerable = create_enumerable({ 42 }); + auto enumerable = create_enumerable({ random() }); iterator x { enumerable, iterator_position::before_first }; iterator y { enumerable, iterator_position::after_last }; assert::is_false(x == y); @@ -394,7 +401,7 @@ namespace simply TEST_METHOD(iterators_are_not_equal_when_they_point_in_range_of_same_enumerable_because_exact_position_is_undefined) { - auto enumerable = create_enumerable({ 41, 42 }); + auto enumerable = create_enumerable({ random(), random() }); iterator x { enumerable, iterator_position::before_first }; iterator y { enumerable, iterator_position::before_first }; ++x; diff --git a/test/packages.config b/test/packages.config index 1016f6b..54efb17 100644 --- a/test/packages.config +++ b/test/packages.config @@ -1,5 +1,6 @@  - - + + + \ No newline at end of file diff --git a/test/range_test.cpp b/test/range_test.cpp index 4cb83a0..75afdd6 100644 --- a/test/range_test.cpp +++ b/test/range_test.cpp @@ -27,14 +27,15 @@ namespace simply TEST_METHOD(begin_returns_iterator_pointing_before_first_element_of_enumerable) { - range sut { create_enumerable({ 42 }) }; + const int expected { random() }; + range sut { create_enumerable({ expected }) }; iterator result { sut.begin() }; - assert::is_equal(42, *result); + assert::is_equal(expected, *result); } TEST_METHOD(end_returns_iterator_pointing_after_last_element_of_enumerable) { - shared_ptr> enumerable { create_enumerable({ 42 }) }; + shared_ptr> enumerable { create_enumerable({ random() }) }; range sut { enumerable }; iterator result { sut.end() }; iterator expected { enumerable, iterator_position::after_last }; @@ -43,7 +44,7 @@ namespace simply TEST_METHOD(range_can_be_used_in_for_loop) { - initializer_list expected { 40, 41, 42 }; + initializer_list expected { random(), random(), random() }; vector actual; range sut { create_enumerable(expected) }; for (int value : sut) diff --git a/test/stdafx.h b/test/stdafx.h index 7f1972a..21ba7a9 100644 --- a/test/stdafx.h +++ b/test/stdafx.h @@ -11,4 +11,5 @@ #include #include #include +#include #include diff --git a/test/test.vcxproj b/test/test.vcxproj index 6f1c50d..b04879f 100644 --- a/test/test.vcxproj +++ b/test/test.vcxproj @@ -175,14 +175,16 @@ - - + + + 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 From 93991b9d647bbe9a3edef6c367bf53e8a788390a Mon Sep 17 00:00:00 2001 From: Oleg Sych Date: Sun, 20 Dec 2015 11:26:31 -0800 Subject: [PATCH 2/3] - Remove unused Release configurations from solution and projects. --- simply.collections.sln | 10 ------ src/src.vcxproj | 62 ---------------------------------- test/test.vcxproj | 76 ------------------------------------------ 3 files changed, 148 deletions(-) diff --git a/simply.collections.sln b/simply.collections.sln index b20f394..5e02218 100644 --- a/simply.collections.sln +++ b/simply.collections.sln @@ -19,26 +19,16 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {F99792FC-9EE5-4540-8D22-84AB92910790}.Debug|x64.ActiveCfg = Debug|x64 {F99792FC-9EE5-4540-8D22-84AB92910790}.Debug|x64.Build.0 = Debug|x64 {F99792FC-9EE5-4540-8D22-84AB92910790}.Debug|x86.ActiveCfg = Debug|Win32 {F99792FC-9EE5-4540-8D22-84AB92910790}.Debug|x86.Build.0 = Debug|Win32 - {F99792FC-9EE5-4540-8D22-84AB92910790}.Release|x64.ActiveCfg = Release|x64 - {F99792FC-9EE5-4540-8D22-84AB92910790}.Release|x64.Build.0 = Release|x64 - {F99792FC-9EE5-4540-8D22-84AB92910790}.Release|x86.ActiveCfg = Release|Win32 - {F99792FC-9EE5-4540-8D22-84AB92910790}.Release|x86.Build.0 = Release|Win32 {863ED068-C319-4F18-90E6-FF9F282576CA}.Debug|x64.ActiveCfg = Debug|x64 {863ED068-C319-4F18-90E6-FF9F282576CA}.Debug|x64.Build.0 = Debug|x64 {863ED068-C319-4F18-90E6-FF9F282576CA}.Debug|x86.ActiveCfg = Debug|Win32 {863ED068-C319-4F18-90E6-FF9F282576CA}.Debug|x86.Build.0 = Debug|Win32 - {863ED068-C319-4F18-90E6-FF9F282576CA}.Release|x64.ActiveCfg = Release|x64 - {863ED068-C319-4F18-90E6-FF9F282576CA}.Release|x64.Build.0 = Release|x64 - {863ED068-C319-4F18-90E6-FF9F282576CA}.Release|x86.ActiveCfg = Release|Win32 - {863ED068-C319-4F18-90E6-FF9F282576CA}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/src.vcxproj b/src/src.vcxproj index 5783d4c..3b8738d 100644 --- a/src/src.vcxproj +++ b/src/src.vcxproj @@ -5,18 +5,10 @@ Debug Win32 - - Release - Win32 - Debug x64 - - Release - x64 - @@ -46,26 +38,12 @@ v140 Unicode - - StaticLibrary - false - v140 - true - Unicode - StaticLibrary true v140 Unicode - - StaticLibrary - false - v140 - true - Unicode - @@ -74,15 +52,9 @@ - - - - - - @@ -111,40 +83,6 @@ true - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - true - true - - diff --git a/test/test.vcxproj b/test/test.vcxproj index b04879f..323ba85 100644 --- a/test/test.vcxproj +++ b/test/test.vcxproj @@ -5,18 +5,10 @@ Debug Win32 - - Release - Win32 - Debug x64 - - Release - x64 - {863ED068-C319-4F18-90E6-FF9F282576CA} @@ -32,14 +24,6 @@ Unicode false - - DynamicLibrary - false - v140 - true - Unicode - false - DynamicLibrary true @@ -47,14 +31,6 @@ Unicode false - - DynamicLibrary - false - v140 - true - Unicode - false - @@ -64,15 +40,9 @@ - - - - - - true @@ -80,12 +50,6 @@ true - - true - - - true - Use @@ -116,44 +80,6 @@ $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) - - - Level3 - Use - MaxSpeed - true - true - $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) - - - - - Level3 - Use - MaxSpeed - true - true - $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) - NDEBUG;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) - - @@ -165,8 +91,6 @@ Create Create - Create - Create From 2b0c1a7782f58b450bb53cd74a1e48c685f12dca Mon Sep 17 00:00:00 2001 From: Oleg Sych Date: Sun, 20 Dec 2015 11:34:04 -0800 Subject: [PATCH 3/3] - Remove pre-compiled headers. - Remove junk from project files. --- src/src.vcxproj | 49 ++++--------------------------------- test/iterator_test.cpp | 2 +- test/range_test.cpp | 4 ++- test/stdafx.cpp | 4 --- test/stdafx.h | 15 ------------ test/test.vcxproj | 55 ++++-------------------------------------- 6 files changed, 14 insertions(+), 115 deletions(-) delete mode 100644 test/stdafx.cpp delete mode 100644 test/stdafx.h diff --git a/src/src.vcxproj b/src/src.vcxproj index 3b8738d..d46848b 100644 --- a/src/src.vcxproj +++ b/src/src.vcxproj @@ -19,9 +19,7 @@ - - Designer - + @@ -29,54 +27,19 @@ Win32Proj src 8.1 - - - - - StaticLibrary - true - v140 - Unicode - - StaticLibrary true v140 Unicode + + - - - - - - - - - - - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - + - - Level3 Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) + %(PreprocessorDefinitions) Windows @@ -84,6 +47,4 @@ - - \ No newline at end of file diff --git a/test/iterator_test.cpp b/test/iterator_test.cpp index 16fb544..8ce5983 100644 --- a/test/iterator_test.cpp +++ b/test/iterator_test.cpp @@ -1,5 +1,5 @@ -#include "stdafx.h" #include +#include #include #include #include diff --git a/test/range_test.cpp b/test/range_test.cpp index 75afdd6..db263e5 100644 --- a/test/range_test.cpp +++ b/test/range_test.cpp @@ -1,7 +1,9 @@ -#include "stdafx.h" +#include #include #include +#include #include +#include #include "stub_enumerable.h" #include "stub_enumerator.h" diff --git a/test/stdafx.cpp b/test/stdafx.cpp deleted file mode 100644 index e8bddf4..0000000 --- a/test/stdafx.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// Reference any additional headers you need in stdafx.h and not in this file - -#include "stdafx.h" diff --git a/test/stdafx.h b/test/stdafx.h deleted file mode 100644 index 21ba7a9..0000000 --- a/test/stdafx.h +++ /dev/null @@ -1,15 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include diff --git a/test/test.vcxproj b/test/test.vcxproj index 323ba85..64fb3ad 100644 --- a/test/test.vcxproj +++ b/test/test.vcxproj @@ -15,63 +15,23 @@ Win32Proj test 8.1 - - - - DynamicLibrary - true - v140 - Unicode - false - - DynamicLibrary true v140 Unicode false + true + - - - - - - - - - - - - - true - - - true - - + - Use + NotUsing Level3 Disabled $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;%(PreprocessorDefinitions) - true - - - Windows - true - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) - - - - - Use - Level3 - Disabled - $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) - _DEBUG;%(PreprocessorDefinitions) + %(PreprocessorDefinitions) true @@ -81,17 +41,12 @@ - - - Create - Create -