From a2153020b85fa92850294479764f087a2a8a3ad7 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 16 Feb 2022 19:21:59 +0600 Subject: [PATCH 01/13] Add `Get(True|False)` --- .../Setter[TResult, TDecision].h | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/cpp/Platform.Setters/Setter[TResult, TDecision].h b/cpp/Platform.Setters/Setter[TResult, TDecision].h index 4334692..d921f1b 100644 --- a/cpp/Platform.Setters/Setter[TResult, TDecision].h +++ b/cpp/Platform.Setters/Setter[TResult, TDecision].h @@ -4,20 +4,32 @@ template class Setter : public SetterBase { using base = SetterBase; - private: TDecision _trueValue {}; - private: TDecision _falseValue {}; + private: + TDecision _trueValue {}; + TDecision _falseValue {}; - public: Setter(TDecision trueValue, TDecision falseValue, TResult defaultValue) - : _trueValue(trueValue), _falseValue(falseValue), base(defaultValue) + public: Setter(TDecision _trueValue, TDecision _falseValue, TResult defaultValue) + : _trueValue(_trueValue), _falseValue(_falseValue), base(defaultValue) { } - public: Setter(TDecision trueValue, TDecision falseValue) : Setter(trueValue, falseValue, {}) { } + public: Setter(TDecision _trueValue, TDecision _falseValue) : Setter(_trueValue, _falseValue, {}) { } public: explicit Setter(TResult defaultValue) : base(defaultValue) { } public: Setter() = default; + public: + TDecision GetTrue() + { + return _trueValue; + } + + TDecision GetFalse() + { + return _falseValue; + } + public: TDecision SetAndReturnTrue(TResult value) { base::_result = value; From ad8721d57723eb24736c738b7167479527f4c90b Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 16 Feb 2022 19:22:08 +0600 Subject: [PATCH 02/13] Add `SetterExtensions` --- csharp/Platform.Setters/SetterExtensions.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/csharp/Platform.Setters/SetterExtensions.cs b/csharp/Platform.Setters/SetterExtensions.cs index 713f2e3..17535b3 100644 --- a/csharp/Platform.Setters/SetterExtensions.cs +++ b/csharp/Platform.Setters/SetterExtensions.cs @@ -7,43 +7,43 @@ public static class SetterExtensions public static TDecision SetFirstFromListAndReturnTrue(this Setter setter, IList list) { setter.Set(list[0]); - return setter.TrueValue; + return setter._trueValue; } public static TDecision SetFirstFromFirstListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list1[0]); - return setter.TrueValue; + return setter._trueValue; } public static TDecision SetSecondFromFirstListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list1[1]); - return setter.TrueValue; + return setter._trueValue; } public static TDecision SetThirdFromFirstListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list1[2]); - return setter.TrueValue; + return setter._trueValue; } public static TDecision SetFirstFromSecondListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list2[0]); - return setter.TrueValue; + return setter._trueValue; } public static TDecision SetSecondFromSecondListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list2[1]); - return setter.TrueValue; + return setter._trueValue; } public static TDecision SetThirdFromSecondListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list2[2]); - return setter.TrueValue; + return setter._trueValue; } } } From 3a7b414ea7aa18c8e91f16b8ee2a59ec500a33e2 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 16 Feb 2022 19:22:23 +0600 Subject: [PATCH 03/13] Add `SetterExtensionsTests` to `SetterTests` --- cpp/Platform.Setters.Tests/SetterTests.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/Platform.Setters.Tests/SetterTests.cpp b/cpp/Platform.Setters.Tests/SetterTests.cpp index d3079f0..85e41f0 100644 --- a/cpp/Platform.Setters.Tests/SetterTests.cpp +++ b/cpp/Platform.Setters.Tests/SetterTests.cpp @@ -1,5 +1,6 @@ #include #include +#include "SetterExtensionsTests.cpp" namespace Platform::Setters::Tests { From 1c786323d00c6a50d4e73e5c4dff0cc4a51533cc Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 16 Feb 2022 19:22:34 +0600 Subject: [PATCH 04/13] Add `SetterExtensions` --- cpp/Platform.Setters/SetterExtensions.h | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 cpp/Platform.Setters/SetterExtensions.h diff --git a/cpp/Platform.Setters/SetterExtensions.h b/cpp/Platform.Setters/SetterExtensions.h new file mode 100644 index 0000000..6631e32 --- /dev/null +++ b/cpp/Platform.Setters/SetterExtensions.h @@ -0,0 +1,49 @@ +namespace Platform::Setters +{ + template + class SetterExtensions + { + public: + static TDecision SetFirstFromListAndReturnTrue(Setter setter, IList list) + { + setter.Set(list[0]); + return setter.GetTrue(); + } + + static TDecision SetFirstFromFirstListAndReturnTrue(Setter setter, IList list1, IList list2) + { + setter.Set(list1[0]); + return setter.GetTrue(); + } + + static TDecision SetSecondFromFirstListAndReturnTrue(Setter setter, IList list1, IList list2) + { + setter.Set(list1[1]); + return setter.GetTrue(); + } + + static TDecision SetThirdFromFirstListAndReturnTrue(Setter setter, IList list1, IList list2) + { + setter.Set(list1[2]); + return setter.GetTrue(); + } + + static TDecision SetFirstFromSecondListAndReturnTrue(Setter setter, IList list1, IList list2) + { + setter.Set(list2[0]); + return setter.GetTrue(); + } + + static TDecision SetSecondFromSecondListAndReturnTrue(Setter setter, IList list1, IList list2) + { + setter.Set(list2[1]); + return setter.GetTrue(); + } + + static TDecision SetThirdFromSecondListAndReturnTrue(Setter setter, IList list1, IList list2) + { + setter.Set(list2[2]); + return setter.GetTrue(); + } + }; +} From aee3662d83575123d98e960c4e77e69c96d5fca4 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 16 Feb 2022 19:22:42 +0600 Subject: [PATCH 05/13] Add `SetterExtensionsTests` --- .../SetterExtensionsTests.cpp | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 cpp/Platform.Setters.Tests/SetterExtensionsTests.cpp diff --git a/cpp/Platform.Setters.Tests/SetterExtensionsTests.cpp b/cpp/Platform.Setters.Tests/SetterExtensionsTests.cpp new file mode 100644 index 0000000..0aad3b8 --- /dev/null +++ b/cpp/Platform.Setters.Tests/SetterExtensionsTests.cpp @@ -0,0 +1,98 @@ +namespace Platform::Setters::Tests +{ + TEST(SetterExtensionsTests, SetFirstFromListAndReturnTrue) + { + std::int32_t list { 1,2,3 }; + auto setter = Setter(); + bool decision = setter.SetFirstFromListAndReturnTrue(list); + ASSERT_EQ(setter.GetTrue(), decision); + ASSERT_EQ(list[0], setter.Result()); + } + + TEST(SetterExtensionsTests, SetFirstFromFirstListAndReturnTrue) + { + std::int32_t list { 1,2,3 }; + auto setter = Setter(); + bool decision = setter.SetFirstFromFirstListAndReturnTrue(list, list); + ASSERT_EQ(setter.GetTrue(), decision); + ASSERT_EQ(list[0], setter.Result()); + } + + TEST(SetterExtensionsTests, SetSecondFromFirstListAndReturnTrue) + { + std::int32_t list { 1,2,3 }; + auto setter = Setter(); + bool decision = setter.SetSecondFromFirstListAndReturnTrue(list, list); + ASSERT_EQ(setter.GetTrue(), decision); + ASSERT_EQ(list[1], setter.Result()); + } + + TEST(SetterExtensionsTests, SetThirdFromFirstListAndReturnTrue) + { + std::int32_t list { 1,2,3 }; + auto setter = Setter(); + bool decision = setter.SetThirdFromFirstListAndReturnTrue(list, list); + ASSERT_EQ(setter.GetTrue(), decision); + ASSERT_EQ(list[2], setter.Result()); + } + + TEST(SetterExtensionsTests, SetFirstFromFirstListAndReturnTrue) + { + std::int32_t list1 { 1,2,3 }; + std::int32_t list2 { 4,5,6 }; + auto setter = Setter(); + bool decision = setter.SetFirstFromFirstListAndReturnTrue(list1, list2); + ASSERT_EQ(setter.GetTrue(), decision); + ASSERT_EQ(list1[0], setter.Result()); + } + + TEST(SetterExtensionsTests, SetSecondFromFirstListAndReturnTrue) + { + std::int32_t list1 { 1,2,3 }; + std::int32_t list2 { 4,5,6 }; + auto setter = Setter(); + bool decision = setter.SetSecondFromFirstListAndReturnTrue(list1, list2); + ASSERT_EQ(setter.GetTrue(), decision); + ASSERT_EQ(list1[1], setter.Result()); + } + + TEST(SetterExtensionsTests, SetFirstFromFirstListAndReturnTrue) + { + std::int32_t list1 { 1,2,3 }; + std::int32_t list2 { 4,5,6 }; + auto setter = Setter(); + bool decision = setter.SetFirstFromFirstListAndReturnTrue(list1, list2); + ASSERT_EQ(setter.GetTrue(), decision); + ASSERT_EQ(list1[2], setter.Result()); + } + + TEST(SetterExtensionsTests, SetFirstFromSecondListAndReturnTrue) + { + std::int32_t list1 { 1,2,3 }; + std::int32_t list2 { 4,5,6 }; + auto setter = Setter(); + bool decision = setter.SetFirstFromSecondListAndReturnTrue(list1, list2); + ASSERT_EQ(setter.GetTrue(), decision); + ASSERT_EQ(list2[0], setter.Result()); + } + + TEST(SetterExtensionsTests, SetSecondFromSecondListAndReturnTrue) + { + std::int32_t list1 { 1,2,3 }; + std::int32_t list2 { 4,5,6 }; + auto setter = Setter(); + bool decision = setter.SetSecondFromSecondListAndReturnTrue(list1, list2); + ASSERT_EQ(setter.GetTrue(), decision); + ASSERT_EQ(list2[1], setter.Result()); + } + + TEST(SetterExtensionsTests, SetThirdFromSecondListAndReturnTrue) + { + std::int32_t list1 { 1,2,3 }; + std::int32_t list2 { 4,5,6 }; + auto setter = Setter(); + bool decision = setter.SetThirdFromSecondListAndReturnTrue(list1, list2); + ASSERT_EQ(setter.GetTrue(), decision); + ASSERT_EQ(list2[2], setter.Result()); + } +} From 0b2aa8e3857f1efa2d6abb946b1e470a1824ee89 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 16 Feb 2022 19:23:12 +0600 Subject: [PATCH 06/13] Revert "Add `SetterExtensions`" This reverts commit ad8721d57723eb24736c738b7167479527f4c90b. --- csharp/Platform.Setters/SetterExtensions.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/csharp/Platform.Setters/SetterExtensions.cs b/csharp/Platform.Setters/SetterExtensions.cs index 17535b3..713f2e3 100644 --- a/csharp/Platform.Setters/SetterExtensions.cs +++ b/csharp/Platform.Setters/SetterExtensions.cs @@ -7,43 +7,43 @@ public static class SetterExtensions public static TDecision SetFirstFromListAndReturnTrue(this Setter setter, IList list) { setter.Set(list[0]); - return setter._trueValue; + return setter.TrueValue; } public static TDecision SetFirstFromFirstListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list1[0]); - return setter._trueValue; + return setter.TrueValue; } public static TDecision SetSecondFromFirstListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list1[1]); - return setter._trueValue; + return setter.TrueValue; } public static TDecision SetThirdFromFirstListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list1[2]); - return setter._trueValue; + return setter.TrueValue; } public static TDecision SetFirstFromSecondListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list2[0]); - return setter._trueValue; + return setter.TrueValue; } public static TDecision SetSecondFromSecondListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list2[1]); - return setter._trueValue; + return setter.TrueValue; } public static TDecision SetThirdFromSecondListAndReturnTrue(this Setter setter, IList list1, IList list2) { setter.Set(list2[2]); - return setter._trueValue; + return setter.TrueValue; } } } From 9ab922cf277595d9fa1b50a02538080c38238607 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 16 Feb 2022 19:23:32 +0600 Subject: [PATCH 07/13] Add `SetterExtensions` to `Setters` --- cpp/Platform.Setters/Platform.Setters.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/Platform.Setters/Platform.Setters.h b/cpp/Platform.Setters/Platform.Setters.h index 4d52f5a..9a3b150 100644 --- a/cpp/Platform.Setters/Platform.Setters.h +++ b/cpp/Platform.Setters/Platform.Setters.h @@ -5,3 +5,4 @@ #include "SetterBase.h" #include "Setter[TResult].h" #include "Setter[TResult, TDecision].h" +#include "SetterExtensions.h" From 957cfc380b8553209c7c653454bfff385cf661b5 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 18 Feb 2022 23:44:04 +0600 Subject: [PATCH 08/13] Update `SetterExtensions` --- cpp/Platform.Setters/SetterExtensions.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cpp/Platform.Setters/SetterExtensions.h b/cpp/Platform.Setters/SetterExtensions.h index 6631e32..2d92859 100644 --- a/cpp/Platform.Setters/SetterExtensions.h +++ b/cpp/Platform.Setters/SetterExtensions.h @@ -4,43 +4,43 @@ namespace Platform::Setters class SetterExtensions { public: - static TDecision SetFirstFromListAndReturnTrue(Setter setter, IList list) + static TDecision SetFirstFromListAndReturnTrue(Setter setter, Interfaces::IArray list) { setter.Set(list[0]); return setter.GetTrue(); } - static TDecision SetFirstFromFirstListAndReturnTrue(Setter setter, IList list1, IList list2) + static TDecision SetFirstFromFirstListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) { setter.Set(list1[0]); return setter.GetTrue(); } - static TDecision SetSecondFromFirstListAndReturnTrue(Setter setter, IList list1, IList list2) + static TDecision SetSecondFromFirstListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) { setter.Set(list1[1]); return setter.GetTrue(); } - static TDecision SetThirdFromFirstListAndReturnTrue(Setter setter, IList list1, IList list2) + static TDecision SetThirdFromFirstListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) { setter.Set(list1[2]); return setter.GetTrue(); } - static TDecision SetFirstFromSecondListAndReturnTrue(Setter setter, IList list1, IList list2) + static TDecision SetFirstFromSecondListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) { setter.Set(list2[0]); return setter.GetTrue(); } - static TDecision SetSecondFromSecondListAndReturnTrue(Setter setter, IList list1, IList list2) + static TDecision SetSecondFromSecondListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) { setter.Set(list2[1]); return setter.GetTrue(); } - static TDecision SetThirdFromSecondListAndReturnTrue(Setter setter, IList list1, IList list2) + static TDecision SetThirdFromSecondListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) { setter.Set(list2[2]); return setter.GetTrue(); From fcf59f3ddcfe4cd25b445ec50801ccc6c64ec8b8 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 18 Feb 2022 23:56:58 +0600 Subject: [PATCH 09/13] Use `Interfaces::CArray` instead of `Interfaces::IArray` --- cpp/Platform.Setters/SetterExtensions.h | 14 +++++++------- cpp/Platform.Setters/Setter[TResult, TDecision].h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cpp/Platform.Setters/SetterExtensions.h b/cpp/Platform.Setters/SetterExtensions.h index 2d92859..d33303e 100644 --- a/cpp/Platform.Setters/SetterExtensions.h +++ b/cpp/Platform.Setters/SetterExtensions.h @@ -4,43 +4,43 @@ namespace Platform::Setters class SetterExtensions { public: - static TDecision SetFirstFromListAndReturnTrue(Setter setter, Interfaces::IArray list) + static TDecision SetFirstFromListAndReturnTrue(Setter setter, Interfaces::CArray list) { setter.Set(list[0]); return setter.GetTrue(); } - static TDecision SetFirstFromFirstListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) + static TDecision SetFirstFromFirstListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) { setter.Set(list1[0]); return setter.GetTrue(); } - static TDecision SetSecondFromFirstListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) + static TDecision SetSecondFromFirstListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) { setter.Set(list1[1]); return setter.GetTrue(); } - static TDecision SetThirdFromFirstListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) + static TDecision SetThirdFromFirstListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) { setter.Set(list1[2]); return setter.GetTrue(); } - static TDecision SetFirstFromSecondListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) + static TDecision SetFirstFromSecondListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) { setter.Set(list2[0]); return setter.GetTrue(); } - static TDecision SetSecondFromSecondListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) + static TDecision SetSecondFromSecondListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) { setter.Set(list2[1]); return setter.GetTrue(); } - static TDecision SetThirdFromSecondListAndReturnTrue(Setter setter, Interfaces::IArray list1, Interfaces::IArray list2) + static TDecision SetThirdFromSecondListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) { setter.Set(list2[2]); return setter.GetTrue(); diff --git a/cpp/Platform.Setters/Setter[TResult, TDecision].h b/cpp/Platform.Setters/Setter[TResult, TDecision].h index d921f1b..c844ead 100644 --- a/cpp/Platform.Setters/Setter[TResult, TDecision].h +++ b/cpp/Platform.Setters/Setter[TResult, TDecision].h @@ -42,13 +42,13 @@ return _falseValue; } - public: TDecision SetFirstAndReturnTrue(Interfaces::IArray auto&& list) + public: TDecision SetFirstAndReturnTrue(Interfaces::CArray auto&& list) { base::_result = list[0]; return _trueValue; } - public: TDecision SetFirstAndReturnFalse(Interfaces::IArray auto&& list) + public: TDecision SetFirstAndReturnFalse(Interfaces::CArray auto&& list) { base::_result = list[0]; return _falseValue; From d85441fadc7fc72f21d1ced73a2b4d2dada34b0c Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 19 Feb 2022 00:07:32 +0600 Subject: [PATCH 10/13] Use `platform.interfaces/0.2.5` --- cpp/conanfile.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/conanfile.txt b/cpp/conanfile.txt index b888b68..354dd3c 100644 --- a/cpp/conanfile.txt +++ b/cpp/conanfile.txt @@ -1,6 +1,6 @@ [requires] gtest/cci.20210126 -platform.interfaces/0.1.3 +platform.interfaces/0.2.5 [generators] -cmake \ No newline at end of file +cmake From c819991d12f6a0f4685c791538d4486e02877686 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 19 Feb 2022 13:34:45 +0600 Subject: [PATCH 11/13] Remove unused extensions --- cpp/Platform.Setters/SetterExtensions.h | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/cpp/Platform.Setters/SetterExtensions.h b/cpp/Platform.Setters/SetterExtensions.h index d33303e..ad61701 100644 --- a/cpp/Platform.Setters/SetterExtensions.h +++ b/cpp/Platform.Setters/SetterExtensions.h @@ -1,46 +1,45 @@ namespace Platform::Setters { - template class SetterExtensions { public: - static TDecision SetFirstFromListAndReturnTrue(Setter setter, Interfaces::CArray list) - { - setter.Set(list[0]); - return setter.GetTrue(); - } - - static TDecision SetFirstFromFirstListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) + template + static TDecision SetFirstFromFirstListAndReturnTrue(Setter& setter, Interfaces::CArray auto&& list1, Interfaces::CArray auto&& list2) { setter.Set(list1[0]); return setter.GetTrue(); } - static TDecision SetSecondFromFirstListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) + template + static TDecision SetSecondFromFirstListAndReturnTrue(Setter& setter, Interfaces::CArray auto&& list1, Interfaces::CArray auto&& list2) { setter.Set(list1[1]); return setter.GetTrue(); } - static TDecision SetThirdFromFirstListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) + template + static TDecision SetThirdFromFirstListAndReturnTrue(Setter& setter, Interfaces::CArray auto&& list1, Interfaces::CArray auto&& list2) { setter.Set(list1[2]); return setter.GetTrue(); } - static TDecision SetFirstFromSecondListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) + template + static TDecision SetFirstFromSecondListAndReturnTrue(Setter& setter, Interfaces::CArray auto&& list1, Interfaces::CArray auto&& list2) { setter.Set(list2[0]); return setter.GetTrue(); } - static TDecision SetSecondFromSecondListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) + template + static TDecision SetSecondFromSecondListAndReturnTrue(Setter& setter, Interfaces::CArray auto&& list1, Interfaces::CArray auto&& list2) { setter.Set(list2[1]); return setter.GetTrue(); } - static TDecision SetThirdFromSecondListAndReturnTrue(Setter setter, Interfaces::CArray list1, Interfaces::CArray list2) + template + static TDecision SetThirdFromSecondListAndReturnTrue(Setter& setter, Interfaces::CArray auto&& list1, Interfaces::CArray auto&& list2) { setter.Set(list2[2]); return setter.GetTrue(); From a884c0390891ee4e6612ec7ece85e9013f97ee93 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 19 Feb 2022 13:34:55 +0600 Subject: [PATCH 12/13] Update `SetterExtensionsTests` --- .../SetterExtensionsTests.cpp | 88 +++++-------------- 1 file changed, 22 insertions(+), 66 deletions(-) diff --git a/cpp/Platform.Setters.Tests/SetterExtensionsTests.cpp b/cpp/Platform.Setters.Tests/SetterExtensionsTests.cpp index 0aad3b8..77cb581 100644 --- a/cpp/Platform.Setters.Tests/SetterExtensionsTests.cpp +++ b/cpp/Platform.Setters.Tests/SetterExtensionsTests.cpp @@ -1,97 +1,53 @@ +using TLinkAddress = std::int32_t; + namespace Platform::Setters::Tests { - TEST(SetterExtensionsTests, SetFirstFromListAndReturnTrue) - { - std::int32_t list { 1,2,3 }; - auto setter = Setter(); - bool decision = setter.SetFirstFromListAndReturnTrue(list); - ASSERT_EQ(setter.GetTrue(), decision); - ASSERT_EQ(list[0], setter.Result()); - } - - TEST(SetterExtensionsTests, SetFirstFromFirstListAndReturnTrue) - { - std::int32_t list { 1,2,3 }; - auto setter = Setter(); - bool decision = setter.SetFirstFromFirstListAndReturnTrue(list, list); - ASSERT_EQ(setter.GetTrue(), decision); - ASSERT_EQ(list[0], setter.Result()); - } - - TEST(SetterExtensionsTests, SetSecondFromFirstListAndReturnTrue) - { - std::int32_t list { 1,2,3 }; - auto setter = Setter(); - bool decision = setter.SetSecondFromFirstListAndReturnTrue(list, list); - ASSERT_EQ(setter.GetTrue(), decision); - ASSERT_EQ(list[1], setter.Result()); - } - - TEST(SetterExtensionsTests, SetThirdFromFirstListAndReturnTrue) - { - std::int32_t list { 1,2,3 }; - auto setter = Setter(); - bool decision = setter.SetThirdFromFirstListAndReturnTrue(list, list); - ASSERT_EQ(setter.GetTrue(), decision); - ASSERT_EQ(list[2], setter.Result()); - } - TEST(SetterExtensionsTests, SetFirstFromFirstListAndReturnTrue) { - std::int32_t list1 { 1,2,3 }; - std::int32_t list2 { 4,5,6 }; - auto setter = Setter(); - bool decision = setter.SetFirstFromFirstListAndReturnTrue(list1, list2); + TLinkAddress list1[] { 1,2,3 }; + TLinkAddress list2[] { 4,5,6 }; + Setter setter {}; + bool decision { SetterExtensions::SetFirstFromFirstListAndReturnTrue(setter, list1, list2) }; ASSERT_EQ(setter.GetTrue(), decision); ASSERT_EQ(list1[0], setter.Result()); } TEST(SetterExtensionsTests, SetSecondFromFirstListAndReturnTrue) { - std::int32_t list1 { 1,2,3 }; - std::int32_t list2 { 4,5,6 }; - auto setter = Setter(); - bool decision = setter.SetSecondFromFirstListAndReturnTrue(list1, list2); + TLinkAddress list1[] { 1,2,3 }; + TLinkAddress list2[] { 4,5,6 }; + Setter setter {}; + bool decision { SetterExtensions::SetSecondFromFirstListAndReturnTrue(setter, list1, list2) }; ASSERT_EQ(setter.GetTrue(), decision); ASSERT_EQ(list1[1], setter.Result()); } - TEST(SetterExtensionsTests, SetFirstFromFirstListAndReturnTrue) - { - std::int32_t list1 { 1,2,3 }; - std::int32_t list2 { 4,5,6 }; - auto setter = Setter(); - bool decision = setter.SetFirstFromFirstListAndReturnTrue(list1, list2); - ASSERT_EQ(setter.GetTrue(), decision); - ASSERT_EQ(list1[2], setter.Result()); - } - TEST(SetterExtensionsTests, SetFirstFromSecondListAndReturnTrue) { - std::int32_t list1 { 1,2,3 }; - std::int32_t list2 { 4,5,6 }; - auto setter = Setter(); - bool decision = setter.SetFirstFromSecondListAndReturnTrue(list1, list2); + TLinkAddress list1[] { 1,2,3 }; + TLinkAddress list2[] { 4,5,6 }; + Setter setter {}; + bool decision { SetterExtensions::SetFirstFromSecondListAndReturnTrue(setter, list1, list2) }; ASSERT_EQ(setter.GetTrue(), decision); ASSERT_EQ(list2[0], setter.Result()); } TEST(SetterExtensionsTests, SetSecondFromSecondListAndReturnTrue) { - std::int32_t list1 { 1,2,3 }; - std::int32_t list2 { 4,5,6 }; - auto setter = Setter(); - bool decision = setter.SetSecondFromSecondListAndReturnTrue(list1, list2); + TLinkAddress list1[] { 1,2,3 }; + TLinkAddress list2[] { 4,5,6 }; + Setter setter {}; + bool decision { SetterExtensions::SetSecondFromSecondListAndReturnTrue(setter, list1, list2) }; ASSERT_EQ(setter.GetTrue(), decision); ASSERT_EQ(list2[1], setter.Result()); } TEST(SetterExtensionsTests, SetThirdFromSecondListAndReturnTrue) { - std::int32_t list1 { 1,2,3 }; - std::int32_t list2 { 4,5,6 }; - auto setter = Setter(); - bool decision = setter.SetThirdFromSecondListAndReturnTrue(list1, list2); + TLinkAddress list1[] { 1,2,3 }; + TLinkAddress list2[] { 4,5,6 }; + Setter setter {}; + bool decision { SetterExtensions::SetThirdFromSecondListAndReturnTrue(setter, list1, list2) }; ASSERT_EQ(setter.GetTrue(), decision); ASSERT_EQ(list2[2], setter.Result()); } From 7919fa7cf8e694ca61851e73c987d84760c0c0b0 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 19 Feb 2022 13:35:18 +0600 Subject: [PATCH 13/13] Use `CSetter` instead of `ISetter` in `~SetterBase requires` --- cpp/Platform.Setters/SetterBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/Platform.Setters/SetterBase.h b/cpp/Platform.Setters/SetterBase.h index bcf380b..af98428 100644 --- a/cpp/Platform.Setters/SetterBase.h +++ b/cpp/Platform.Setters/SetterBase.h @@ -15,6 +15,6 @@ public: void Set(TResult value) { _result = value; } - public: ~SetterBase() requires Interfaces::ISetter = default; + public: ~SetterBase() requires Interfaces::CSetter = default; }; }