diff options
author | bulatman <bulatman@yandex-team.ru> | 2022-02-10 16:45:50 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:50 +0300 |
commit | 2f6ca198245aeffd5e2d82b65927c2465b68b4f5 (patch) | |
tree | 9142afc54d335ea52910662635b898e79e192e49 /library/cpp/testing/common/probe.h | |
parent | 6560e4993b14d193f8c879e33a3de5e5eba6e21d (diff) | |
download | ydb-2f6ca198245aeffd5e2d82b65927c2465b68b4f5.tar.gz |
Restoring authorship annotation for <bulatman@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/testing/common/probe.h')
-rw-r--r-- | library/cpp/testing/common/probe.h | 264 |
1 files changed, 132 insertions, 132 deletions
diff --git a/library/cpp/testing/common/probe.h b/library/cpp/testing/common/probe.h index ba5a83a83e..19910979b5 100644 --- a/library/cpp/testing/common/probe.h +++ b/library/cpp/testing/common/probe.h @@ -1,140 +1,140 @@ #pragma once -#include <util/system/yassert.h> +#include <util/system/yassert.h> namespace NTesting { - //////////////////////////////////////////////////////////////////////////////// - - // Below there is a serie of probe classes for testing construction/destruction copying/moving of class. - // for examples see tests in probe_ut.cpp - - struct TProbeState { - int Constructors = 0; - int Destructors = 0; - int ShadowDestructors = 0; - int CopyConstructors = 0; - int CopyAssignments = 0; - int MoveConstructors = 0; - int MoveAssignments = 0; - int Touches = 0; - - TProbeState() = default; - - void Reset() { - *this = TProbeState{}; - } - }; - - // Used for probing the number of copies that occur if a type must be coerced. - class TCoercibleToProbe { - public: - TProbeState* State; - TProbeState* ShadowState; - - public: - explicit TCoercibleToProbe(TProbeState* state) - : State(state) - , ShadowState(state) - {} - - private: - TCoercibleToProbe(const TCoercibleToProbe&); - TCoercibleToProbe(TCoercibleToProbe&&); - TCoercibleToProbe& operator=(const TCoercibleToProbe&); - TCoercibleToProbe& operator=(TCoercibleToProbe&&); - }; - - // Used for probing the number of copies in an argument. - class TProbe { - public: - TProbeState* State; - TProbeState* ShadowState; - - public: - static TProbe ExplicitlyCreateInvalidProbe() { - return TProbe(); - } - - explicit TProbe(TProbeState* state) - : State(state) - , ShadowState(state) - { - Y_ASSERT(State); - ++State->Constructors; - } - - ~TProbe() { - if (State) { - ++State->Destructors; - } - if (ShadowState) { - ++ShadowState->ShadowDestructors; - } - } - - TProbe(const TProbe& other) - : State(other.State) - , ShadowState(other.ShadowState) - { - Y_ASSERT(State); - ++State->CopyConstructors; - } - - TProbe(TProbe&& other) - : State(other.State) - , ShadowState(other.ShadowState) - { - Y_ASSERT(State); - other.State = nullptr; - ++State->MoveConstructors; - } - - TProbe(const TCoercibleToProbe& other) - : State(other.State) - , ShadowState(other.ShadowState) - { - Y_ASSERT(State); - ++State->CopyConstructors; + //////////////////////////////////////////////////////////////////////////////// + + // Below there is a serie of probe classes for testing construction/destruction copying/moving of class. + // for examples see tests in probe_ut.cpp + + struct TProbeState { + int Constructors = 0; + int Destructors = 0; + int ShadowDestructors = 0; + int CopyConstructors = 0; + int CopyAssignments = 0; + int MoveConstructors = 0; + int MoveAssignments = 0; + int Touches = 0; + + TProbeState() = default; + + void Reset() { + *this = TProbeState{}; + } + }; + + // Used for probing the number of copies that occur if a type must be coerced. + class TCoercibleToProbe { + public: + TProbeState* State; + TProbeState* ShadowState; + + public: + explicit TCoercibleToProbe(TProbeState* state) + : State(state) + , ShadowState(state) + {} + + private: + TCoercibleToProbe(const TCoercibleToProbe&); + TCoercibleToProbe(TCoercibleToProbe&&); + TCoercibleToProbe& operator=(const TCoercibleToProbe&); + TCoercibleToProbe& operator=(TCoercibleToProbe&&); + }; + + // Used for probing the number of copies in an argument. + class TProbe { + public: + TProbeState* State; + TProbeState* ShadowState; + + public: + static TProbe ExplicitlyCreateInvalidProbe() { + return TProbe(); + } + + explicit TProbe(TProbeState* state) + : State(state) + , ShadowState(state) + { + Y_ASSERT(State); + ++State->Constructors; + } + + ~TProbe() { + if (State) { + ++State->Destructors; + } + if (ShadowState) { + ++ShadowState->ShadowDestructors; + } + } + + TProbe(const TProbe& other) + : State(other.State) + , ShadowState(other.ShadowState) + { + Y_ASSERT(State); + ++State->CopyConstructors; + } + + TProbe(TProbe&& other) + : State(other.State) + , ShadowState(other.ShadowState) + { + Y_ASSERT(State); + other.State = nullptr; + ++State->MoveConstructors; + } + + TProbe(const TCoercibleToProbe& other) + : State(other.State) + , ShadowState(other.ShadowState) + { + Y_ASSERT(State); + ++State->CopyConstructors; + } + + TProbe(TCoercibleToProbe&& other) + : State(other.State) + , ShadowState(other.ShadowState) + { + Y_ASSERT(State); + other.State = nullptr; + ++State->MoveConstructors; + } + + TProbe& operator=(const TProbe& other) { + State = other.State; + ShadowState = other.ShadowState; + Y_ASSERT(State); + ++State->CopyAssignments; + return *this; + } + + TProbe& operator=(TProbe&& other) { + State = other.State; + ShadowState = other.ShadowState; + Y_ASSERT(State); + other.State = nullptr; + ++State->MoveAssignments; + return *this; } - - TProbe(TCoercibleToProbe&& other) - : State(other.State) - , ShadowState(other.ShadowState) - { - Y_ASSERT(State); - other.State = nullptr; - ++State->MoveConstructors; + + void Touch() const { + Y_ASSERT(State); + ++State->Touches; + } + + bool IsValid() const { + return nullptr != State; } - TProbe& operator=(const TProbe& other) { - State = other.State; - ShadowState = other.ShadowState; - Y_ASSERT(State); - ++State->CopyAssignments; - return *this; - } - - TProbe& operator=(TProbe&& other) { - State = other.State; - ShadowState = other.ShadowState; - Y_ASSERT(State); - other.State = nullptr; - ++State->MoveAssignments; - return *this; - } - - void Touch() const { - Y_ASSERT(State); - ++State->Touches; - } - - bool IsValid() const { - return nullptr != State; - } - - private: - TProbe() - : State(nullptr) - {} - }; + private: + TProbe() + : State(nullptr) + {} + }; } // namespace NTesting |