diff options
author | svshevtsov <svshevtsov@yandex-team.ru> | 2022-02-10 16:49:37 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:37 +0300 |
commit | 657337012a264721d58c470b4e9e796611f3c492 (patch) | |
tree | 82753fd92cf7cc2dea4e522a945ed570131f920b /library/cpp/object_factory | |
parent | 44f31b316af517a4fbc6a82ebed8a1c51807deac (diff) | |
download | ydb-657337012a264721d58c470b4e9e796611f3c492.tar.gz |
Restoring authorship annotation for <svshevtsov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/object_factory')
-rw-r--r-- | library/cpp/object_factory/object_factory.h | 2 | ||||
-rw-r--r-- | library/cpp/object_factory/object_factory_ut.cpp | 98 | ||||
-rw-r--r-- | library/cpp/object_factory/ut/ya.make | 26 |
3 files changed, 63 insertions, 63 deletions
diff --git a/library/cpp/object_factory/object_factory.h b/library/cpp/object_factory/object_factory.h index 96cc11bcfd..e71cb05abb 100644 --- a/library/cpp/object_factory/object_factory.h +++ b/library/cpp/object_factory/object_factory.h @@ -1,7 +1,7 @@ #pragma once #include <util/system/guard.h> -#include <util/system/rwlock.h> +#include <util/system/rwlock.h> #include <util/generic/map.h> #include <util/generic/set.h> #include <util/generic/singleton.h> diff --git a/library/cpp/object_factory/object_factory_ut.cpp b/library/cpp/object_factory/object_factory_ut.cpp index 06fb0739ff..a5933c4ba9 100644 --- a/library/cpp/object_factory/object_factory_ut.cpp +++ b/library/cpp/object_factory/object_factory_ut.cpp @@ -1,69 +1,69 @@ #include <library/cpp/object_factory/object_factory.h> #include <library/cpp/testing/unittest/registar.h> - + #include <util/generic/noncopyable.h> #include <util/generic/string.h> -#include <util/generic/ptr.h> - -using namespace NObjectFactory; - -struct TArgument { +#include <util/generic/ptr.h> + +using namespace NObjectFactory; + +struct TArgument { TString Name; - void* Discarded; -}; - -class ICommonInterface { -public: + void* Discarded; +}; + +class ICommonInterface { +public: virtual ~ICommonInterface() { } - + virtual TString GetValue() const = 0; -}; - +}; + class TDirectOrder: public ICommonInterface { -public: +public: TDirectOrder(const TString& provider, float factor, TArgument& argument) - : Provider(provider) - , Factor(factor) - , Argument(argument) + : Provider(provider) + , Factor(factor) + , Argument(argument) { } - + TString GetValue() const override { - return Provider + ToString(Factor) + Argument.Name; - } + return Provider + ToString(Factor) + Argument.Name; + } -private: +private: const TString Provider; - const float Factor; - const TArgument Argument; -}; - + const float Factor; + const TArgument Argument; +}; + class TInverseOrder: public ICommonInterface { -public: +public: TInverseOrder(const TString& provider, float factor, TArgument& argument) - : Provider(provider) - , Factor(factor) - , Argument(argument) + : Provider(provider) + , Factor(factor) + , Argument(argument) { } - + TString GetValue() const override { - return Argument.Name + ToString(Factor) + Provider; - } + return Argument.Name + ToString(Factor) + Provider; + } -private: +private: const TString Provider; - const float Factor; - const TArgument Argument; -}; - + const float Factor; + const TArgument Argument; +}; + struct TDirectOrderCreator: public IFactoryObjectCreator<ICommonInterface, const TString&, float, TArgument&> { ICommonInterface* Create(const TString& provider, float factor, TArgument& argument) const override { ++CallsCounter; return new TDirectOrder(provider, factor, argument); } - + static int CallsCounter; }; int TDirectOrderCreator::CallsCounter = 0; @@ -71,8 +71,8 @@ int TDirectOrderCreator::CallsCounter = 0; using TTestFactory = TParametrizedObjectFactory<ICommonInterface, TString, const TString&, float, TArgument&>; static TTestFactory::TRegistrator<TDirectOrder> Direct("direct", new TDirectOrderCreator); -static TTestFactory::TRegistrator<TInverseOrder> Inverse("inverse"); - +static TTestFactory::TRegistrator<TInverseOrder> Inverse("inverse"); + class IMoveableOnlyInterface { @@ -148,15 +148,15 @@ Y_UNIT_TEST_SUITE(TestObjectFactory) { TArgument inverseArg{"Fake", nullptr}; THolder<ICommonInterface> direct(TTestFactory::Construct("direct", "prov", 0.42, directArg)); THolder<ICommonInterface> inverse(TTestFactory::Construct("inverse", "prov2", 1, inverseArg)); - - UNIT_ASSERT(!!direct); - UNIT_ASSERT(!!inverse); - - UNIT_ASSERT(direct->GetValue() == "prov0.42Name"); - UNIT_ASSERT(inverse->GetValue() == "Fake1prov2"); + + UNIT_ASSERT(!!direct); + UNIT_ASSERT(!!inverse); + + UNIT_ASSERT(direct->GetValue() == "prov0.42Name"); + UNIT_ASSERT(inverse->GetValue() == "Fake1prov2"); UNIT_ASSERT_EQUAL(TDirectOrderCreator::CallsCounter, 1); - } + } Y_UNIT_TEST(TestMoveableOnly) { TString v = "value1"; @@ -186,4 +186,4 @@ Y_UNIT_TEST_SUITE(TestObjectFactory) { UNIT_ASSERT_EQUAL(directDs->GetValue(), "prov0.01Name"); } -} +} diff --git a/library/cpp/object_factory/ut/ya.make b/library/cpp/object_factory/ut/ya.make index 5a870072fc..2452bfa632 100644 --- a/library/cpp/object_factory/ut/ya.make +++ b/library/cpp/object_factory/ut/ya.make @@ -1,15 +1,15 @@ -UNITTEST() - -OWNER(svshevtsov) - -PEERDIR( +UNITTEST() + +OWNER(svshevtsov) + +PEERDIR( ADDINCL library/cpp/object_factory -) - +) + SRCDIR(library/cpp/object_factory) - -SRCS( - object_factory_ut.cpp -) - -END() + +SRCS( + object_factory_ut.cpp +) + +END() |