diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:48 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:48 +0300 |
commit | 9abfb1a53b7f7b791444d1378e645d8fad9b06ed (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /library/cpp | |
parent | 8cbc307de0221f84c80c42dcbe07d40727537e2c (diff) | |
download | ydb-9abfb1a53b7f7b791444d1378e645d8fad9b06ed.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
567 files changed, 5561 insertions, 5561 deletions
diff --git a/library/cpp/accurate_accumulate/accurate_accumulate.h b/library/cpp/accurate_accumulate/accurate_accumulate.h index 04e362019a..dacced17e9 100644 --- a/library/cpp/accurate_accumulate/accurate_accumulate.h +++ b/library/cpp/accurate_accumulate/accurate_accumulate.h @@ -1,37 +1,37 @@ #pragma once -#include <util/ysaveload.h> +#include <util/ysaveload.h> #include <util/generic/vector.h> #include <util/system/yassert.h> -//! See more details here http://en.wikipedia.org/wiki/Kahan_summation_algorithm +//! See more details here http://en.wikipedia.org/wiki/Kahan_summation_algorithm template <typename TAccumulateType> class TKahanAccumulator { public: using TValueType = TAccumulateType; - template <typename TFloatType> + template <typename TFloatType> explicit TKahanAccumulator(const TFloatType x) - : Sum_(x) - , Compensation_() - { - } - + : Sum_(x) + , Compensation_() + { + } + TKahanAccumulator() - : Sum_() - , Compensation_() + : Sum_() + , Compensation_() { } template <typename TFloatType> - TKahanAccumulator& operator=(const TFloatType& rhs) { - Sum_ = TValueType(rhs); - Compensation_ = TValueType(); + TKahanAccumulator& operator=(const TFloatType& rhs) { + Sum_ = TValueType(rhs); + Compensation_ = TValueType(); return *this; } TValueType Get() const { - return Sum_ + Compensation_; + return Sum_ + Compensation_; } template <typename TFloatType> @@ -40,77 +40,77 @@ public: } template <typename TFloatType> - inline bool operator<(const TKahanAccumulator<TFloatType>& other) const { + inline bool operator<(const TKahanAccumulator<TFloatType>& other) const { return Get() < other.Get(); } template <typename TFloatType> - inline bool operator<=(const TKahanAccumulator<TFloatType>& other) const { + inline bool operator<=(const TKahanAccumulator<TFloatType>& other) const { return !(other < *this); } template <typename TFloatType> - inline bool operator>(const TKahanAccumulator<TFloatType>& other) const { + inline bool operator>(const TKahanAccumulator<TFloatType>& other) const { return other < *this; } template <typename TFloatType> - inline bool operator>=(const TKahanAccumulator<TFloatType>& other) const { + inline bool operator>=(const TKahanAccumulator<TFloatType>& other) const { return !(*this < other); } template <typename TFloatType> - inline TKahanAccumulator& operator+=(const TFloatType x) { - const TValueType y = TValueType(x) - Compensation_; - const TValueType t = Sum_ + y; - Compensation_ = (t - Sum_) - y; - Sum_ = t; + inline TKahanAccumulator& operator+=(const TFloatType x) { + const TValueType y = TValueType(x) - Compensation_; + const TValueType t = Sum_ + y; + Compensation_ = (t - Sum_) - y; + Sum_ = t; return *this; } template <typename TFloatType> - inline TKahanAccumulator& operator-=(const TFloatType x) { - return *this += -TValueType(x); + inline TKahanAccumulator& operator-=(const TFloatType x) { + return *this += -TValueType(x); } template <typename TFloatType> - inline TKahanAccumulator& operator*=(const TFloatType x) { - return *this = TValueType(*this) * TValueType(x); + inline TKahanAccumulator& operator*=(const TFloatType x) { + return *this = TValueType(*this) * TValueType(x); } template <typename TFloatType> - inline TKahanAccumulator& operator/=(const TFloatType x) { - return *this = TValueType(*this) / TValueType(x); + inline TKahanAccumulator& operator/=(const TFloatType x) { + return *this = TValueType(*this) / TValueType(x); } - - Y_SAVELOAD_DEFINE(Sum_, Compensation_) - + + Y_SAVELOAD_DEFINE(Sum_, Compensation_) + private: - TValueType Sum_; - TValueType Compensation_; + TValueType Sum_; + TValueType Compensation_; }; template <typename TAccumulateType, typename TFloatType> inline const TKahanAccumulator<TAccumulateType> -operator+(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { - return lhs += rhs; -} - +operator+(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { + return lhs += rhs; +} + template <typename TAccumulateType, typename TFloatType> inline const TKahanAccumulator<TAccumulateType> -operator-(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { - return lhs -= rhs; -} - +operator-(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { + return lhs -= rhs; +} + template <typename TAccumulateType, typename TFloatType> inline const TKahanAccumulator<TAccumulateType> -operator*(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { +operator*(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { return lhs *= rhs; } template <typename TAccumulateType, typename TFloatType> inline const TKahanAccumulator<TAccumulateType> -operator/(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { +operator/(TKahanAccumulator<TAccumulateType> lhs, const TFloatType rhs) { return lhs /= rhs; } @@ -190,7 +190,7 @@ static inline double FastAccumulate(const TVector<T>& sequence) { template <typename It> static inline double FastKahanAccumulate(It begin, It end) { - return TypedFastAccumulate<TKahanAccumulator<double>>(begin, end); + return TypedFastAccumulate<TKahanAccumulator<double>>(begin, end); } template <typename T> @@ -205,17 +205,17 @@ static inline double FastInnerProduct(It1 begin1, It1 end1, It2 begin2) { template <typename T> static inline double FastInnerProduct(const TVector<T>& lhs, const TVector<T>& rhs) { - Y_ASSERT(lhs.size() == rhs.size()); + Y_ASSERT(lhs.size() == rhs.size()); return FastInnerProduct(lhs.begin(), lhs.end(), rhs.begin()); } template <typename It1, typename It2> static inline double FastKahanInnerProduct(It1 begin1, It1 end1, It2 begin2) { - return TypedFastInnerProduct<TKahanAccumulator<double>>(begin1, end1, begin2); + return TypedFastInnerProduct<TKahanAccumulator<double>>(begin1, end1, begin2); } template <typename T> static inline double FastKahanInnerProduct(const TVector<T>& lhs, const TVector<T>& rhs) { - Y_ASSERT(lhs.size() == rhs.size()); + Y_ASSERT(lhs.size() == rhs.size()); return FastKahanInnerProduct(lhs.begin(), lhs.end(), rhs.begin()); } diff --git a/library/cpp/accurate_accumulate/benchmark/main.cpp b/library/cpp/accurate_accumulate/benchmark/main.cpp index 6dcd8a9635..3c5e6e775d 100644 --- a/library/cpp/accurate_accumulate/benchmark/main.cpp +++ b/library/cpp/accurate_accumulate/benchmark/main.cpp @@ -1,97 +1,97 @@ #include <library/cpp/accurate_accumulate/accurate_accumulate.h> #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/algorithm.h> -#include <util/generic/singleton.h> -#include <util/generic/vector.h> -#include <util/generic/xrange.h> -#include <util/random/fast.h> - -namespace { - template <typename T, size_t N> - struct TNormalizedExamplesHolder { + +#include <util/generic/algorithm.h> +#include <util/generic/singleton.h> +#include <util/generic/vector.h> +#include <util/generic/xrange.h> +#include <util/random/fast.h> + +namespace { + template <typename T, size_t N> + struct TNormalizedExamplesHolder { TVector<T> Examples; - TNormalizedExamplesHolder() - : Examples(N) - { - TFastRng<ui64> prng{sizeof(T) * N * 42u}; - for (auto& x : Examples) { - x = prng.GenRandReal4(); - } - } - }; - - template <typename T, size_t N> - struct TExamplesHolder { + TNormalizedExamplesHolder() + : Examples(N) + { + TFastRng<ui64> prng{sizeof(T) * N * 42u}; + for (auto& x : Examples) { + x = prng.GenRandReal4(); + } + } + }; + + template <typename T, size_t N> + struct TExamplesHolder { TVector<T> Examples; - TExamplesHolder() - : Examples(N) - { - TFastRng<ui64> prng{sizeof(T) * N * 42u + 100500u}; - for (auto& x : Examples) { - // operations with non-normalized floating point numbers are rumored to work slower - x = prng.GenRandReal4() + prng.Uniform(1024u); - } - } - }; -} - -#define DEFINE_BENCHMARK(type, count) \ - Y_CPU_BENCHMARK(SimpleNorm_##type##_##count, iface) { \ - const auto& examples = Default<TNormalizedExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - Y_DO_NOT_OPTIMIZE_AWAY( \ - (type)Accumulate(std::cbegin(examples), std::cend(examples), type{})); \ - } \ - } \ - \ - Y_CPU_BENCHMARK(KahanNorm_##type##_##count, iface) { \ - const auto& examples = Default<TNormalizedExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - Y_DO_NOT_OPTIMIZE_AWAY( \ - (type)Accumulate(std::cbegin(examples), std::cend(examples), TKahanAccumulator<type>{})); \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Simple_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - Y_DO_NOT_OPTIMIZE_AWAY( \ - (type)Accumulate(std::cbegin(examples), std::cend(examples), type{})); \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Kahan_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - Y_DO_NOT_OPTIMIZE_AWAY( \ - (type)Accumulate(std::cbegin(examples), std::cend(examples), TKahanAccumulator<type>{})); \ - } \ - } - -DEFINE_BENCHMARK(float, 2) -DEFINE_BENCHMARK(float, 4) -DEFINE_BENCHMARK(float, 8) -DEFINE_BENCHMARK(float, 16) -DEFINE_BENCHMARK(float, 32) -DEFINE_BENCHMARK(float, 64) -DEFINE_BENCHMARK(float, 128) -DEFINE_BENCHMARK(float, 256) -DEFINE_BENCHMARK(float, 512) -DEFINE_BENCHMARK(float, 1024) -DEFINE_BENCHMARK(double, 2) -DEFINE_BENCHMARK(double, 4) -DEFINE_BENCHMARK(double, 8) -DEFINE_BENCHMARK(double, 16) -DEFINE_BENCHMARK(double, 32) -DEFINE_BENCHMARK(double, 64) -DEFINE_BENCHMARK(double, 128) -DEFINE_BENCHMARK(double, 256) -DEFINE_BENCHMARK(double, 512) -DEFINE_BENCHMARK(double, 1024) - -#undef DEFINE_BENCHMARK + TExamplesHolder() + : Examples(N) + { + TFastRng<ui64> prng{sizeof(T) * N * 42u + 100500u}; + for (auto& x : Examples) { + // operations with non-normalized floating point numbers are rumored to work slower + x = prng.GenRandReal4() + prng.Uniform(1024u); + } + } + }; +} + +#define DEFINE_BENCHMARK(type, count) \ + Y_CPU_BENCHMARK(SimpleNorm_##type##_##count, iface) { \ + const auto& examples = Default<TNormalizedExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + Y_DO_NOT_OPTIMIZE_AWAY( \ + (type)Accumulate(std::cbegin(examples), std::cend(examples), type{})); \ + } \ + } \ + \ + Y_CPU_BENCHMARK(KahanNorm_##type##_##count, iface) { \ + const auto& examples = Default<TNormalizedExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + Y_DO_NOT_OPTIMIZE_AWAY( \ + (type)Accumulate(std::cbegin(examples), std::cend(examples), TKahanAccumulator<type>{})); \ + } \ + } \ + \ + Y_CPU_BENCHMARK(Simple_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + Y_DO_NOT_OPTIMIZE_AWAY( \ + (type)Accumulate(std::cbegin(examples), std::cend(examples), type{})); \ + } \ + } \ + \ + Y_CPU_BENCHMARK(Kahan_##type##_##count, iface) { \ + const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ + for (const auto i : xrange(iface.Iterations())) { \ + Y_UNUSED(i); \ + Y_DO_NOT_OPTIMIZE_AWAY( \ + (type)Accumulate(std::cbegin(examples), std::cend(examples), TKahanAccumulator<type>{})); \ + } \ + } + +DEFINE_BENCHMARK(float, 2) +DEFINE_BENCHMARK(float, 4) +DEFINE_BENCHMARK(float, 8) +DEFINE_BENCHMARK(float, 16) +DEFINE_BENCHMARK(float, 32) +DEFINE_BENCHMARK(float, 64) +DEFINE_BENCHMARK(float, 128) +DEFINE_BENCHMARK(float, 256) +DEFINE_BENCHMARK(float, 512) +DEFINE_BENCHMARK(float, 1024) +DEFINE_BENCHMARK(double, 2) +DEFINE_BENCHMARK(double, 4) +DEFINE_BENCHMARK(double, 8) +DEFINE_BENCHMARK(double, 16) +DEFINE_BENCHMARK(double, 32) +DEFINE_BENCHMARK(double, 64) +DEFINE_BENCHMARK(double, 128) +DEFINE_BENCHMARK(double, 256) +DEFINE_BENCHMARK(double, 512) +DEFINE_BENCHMARK(double, 1024) + +#undef DEFINE_BENCHMARK diff --git a/library/cpp/accurate_accumulate/benchmark/metrics/main.py b/library/cpp/accurate_accumulate/benchmark/metrics/main.py index dc90060625..311fc219ce 100644 --- a/library/cpp/accurate_accumulate/benchmark/metrics/main.py +++ b/library/cpp/accurate_accumulate/benchmark/metrics/main.py @@ -1,7 +1,7 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark( +import yatest.common as yc + + +def test_export_metrics(metrics): + metrics.set_benchmark(yc.execute_benchmark( 'library/cpp/accurate_accumulate/benchmark/benchmark', - threads=8)) + threads=8)) diff --git a/library/cpp/accurate_accumulate/benchmark/metrics/ya.make b/library/cpp/accurate_accumulate/benchmark/metrics/ya.make index 45ef7a464e..5d532e1479 100644 --- a/library/cpp/accurate_accumulate/benchmark/metrics/ya.make +++ b/library/cpp/accurate_accumulate/benchmark/metrics/ya.make @@ -1,17 +1,17 @@ OWNER(yazevnul) - + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(library/cpp/accurate_accumulate/benchmark) - -END() + +END() diff --git a/library/cpp/accurate_accumulate/benchmark/ya.make b/library/cpp/accurate_accumulate/benchmark/ya.make index 48b8486966..20fd877389 100644 --- a/library/cpp/accurate_accumulate/benchmark/ya.make +++ b/library/cpp/accurate_accumulate/benchmark/ya.make @@ -1,13 +1,13 @@ OWNER(yazevnul) - + Y_BENCHMARK() - -SRCS( - main.cpp -) - -PEERDIR( + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/accurate_accumulate -) - -END() +) + +END() diff --git a/library/cpp/actors/core/actor_coroutine_ut.cpp b/library/cpp/actors/core/actor_coroutine_ut.cpp index cbbb332635..951512b877 100644 --- a/library/cpp/actors/core/actor_coroutine_ut.cpp +++ b/library/cpp/actors/core/actor_coroutine_ut.cpp @@ -11,7 +11,7 @@ using namespace NActors; -Y_UNIT_TEST_SUITE(ActorCoro) { +Y_UNIT_TEST_SUITE(ActorCoro) { enum { Begin = EventSpaceBegin(TEvents::ES_USERSPACE), Request, @@ -127,7 +127,7 @@ Y_UNIT_TEST_SUITE(ActorCoro) { actorSystem.Stop(); } - Y_UNIT_TEST(Basic) { + Y_UNIT_TEST(Basic) { if (NSan::TSanIsOn()) { // TODO https://st.yandex-team.ru/DEVTOOLS-3154 return; @@ -135,7 +135,7 @@ Y_UNIT_TEST_SUITE(ActorCoro) { Check(MakeHolder<TEvEnough>()); } - Y_UNIT_TEST(PoisonPill) { + Y_UNIT_TEST(PoisonPill) { Check(MakeHolder<TEvents::TEvPoisonPill>()); } } diff --git a/library/cpp/actors/core/actorid.h b/library/cpp/actors/core/actorid.h index 4b35790ab8..d972b1a0ff 100644 --- a/library/cpp/actors/core/actorid.h +++ b/library/cpp/actors/core/actorid.h @@ -1,7 +1,7 @@ #pragma once #include "defs.h" -#include <util/stream/output.h> // for IOutputStream +#include <util/stream/output.h> // for IOutputStream #include <util/generic/hash.h> namespace NActors { @@ -175,7 +175,7 @@ namespace NActors { }; TString ToString() const; - void Out(IOutputStream& o) const; + void Out(IOutputStream& o) const; bool Parse(const char* buf, ui32 sz); }; diff --git a/library/cpp/actors/core/callstack.cpp b/library/cpp/actors/core/callstack.cpp index 2819999aa2..9297c1a079 100644 --- a/library/cpp/actors/core/callstack.cpp +++ b/library/cpp/actors/core/callstack.cpp @@ -5,11 +5,11 @@ namespace NActors { namespace { - void (*PreviousFormatBackTrace)(IOutputStream*) = 0; + void (*PreviousFormatBackTrace)(IOutputStream*) = 0; ui32 ActorBackTraceEnableCounter = 0; } - void ActorFormatBackTrace(IOutputStream* out) { + void ActorFormatBackTrace(IOutputStream* out) { TStringStream str; PreviousFormatBackTrace(&str); str << Endl; diff --git a/library/cpp/actors/core/event_pb_ut.cpp b/library/cpp/actors/core/event_pb_ut.cpp index 56f5adb401..a16c3092b3 100644 --- a/library/cpp/actors/core/event_pb_ut.cpp +++ b/library/cpp/actors/core/event_pb_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/actors/protos/unittests.pb.h> -Y_UNIT_TEST_SUITE(TEventSerialization) { +Y_UNIT_TEST_SUITE(TEventSerialization) { struct TMockEvent: public NActors::IEventBase { TBigMessage* msg; bool @@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(TEventSerialization) { }; }; - Y_UNIT_TEST(Coroutine) { + Y_UNIT_TEST(Coroutine) { TString strA(507, 'a'); TString strB(814, 'b'); TString strC(198, 'c'); diff --git a/library/cpp/actors/core/executor_pool_basic.cpp b/library/cpp/actors/core/executor_pool_basic.cpp index f9709a4c78..4dce16939a 100644 --- a/library/cpp/actors/core/executor_pool_basic.cpp +++ b/library/cpp/actors/core/executor_pool_basic.cpp @@ -323,7 +323,7 @@ namespace NActors { void TBasicExecutorPool::SetRealTimeMode() const { // TODO: musl-libc version of `sched_param` struct is for some reason different from pthread // version in Ubuntu 12.04 -#if defined(_linux_) && !defined(_musl_) +#if defined(_linux_) && !defined(_musl_) if (RealtimePriority != 0) { pthread_t threadSelf = pthread_self(); sched_param param = {RealtimePriority}; diff --git a/library/cpp/actors/core/executor_thread.cpp b/library/cpp/actors/core/executor_thread.cpp index 9f155c30bc..446b651efd 100644 --- a/library/cpp/actors/core/executor_thread.cpp +++ b/library/cpp/actors/core/executor_thread.cpp @@ -475,7 +475,7 @@ namespace NActors { else if (state == TExecutionState::FreeExecuting) AtomicStore(&ExecutionState, (ui32)TExecutionState::FreeLeaving); else - Y_FAIL(); + Y_FAIL(); AtomicBarrier(); } diff --git a/library/cpp/actors/core/executor_thread.h b/library/cpp/actors/core/executor_thread.h index 0ecc640438..9d3c573f0d 100644 --- a/library/cpp/actors/core/executor_thread.h +++ b/library/cpp/actors/core/executor_thread.h @@ -14,7 +14,7 @@ namespace NActors { - class TExecutorThread: public ISimpleThread { + class TExecutorThread: public ISimpleThread { public: static constexpr TDuration DEFAULT_TIME_PER_MAILBOX = TDuration::MilliSeconds(10); diff --git a/library/cpp/actors/core/log.cpp b/library/cpp/actors/core/log.cpp index 8879083f19..5f63b5af58 100644 --- a/library/cpp/actors/core/log.cpp +++ b/library/cpp/actors/core/log.cpp @@ -236,7 +236,7 @@ namespace NActors { } void TLoggerActor::HandleIgnoredEvent(TLogIgnored::TPtr& ev, const NActors::TActorContext& ctx) { - Y_UNUSED(ev); + Y_UNUSED(ev); LogIgnoredCount(ctx.Now()); IgnoredCount = 0; PassedCount = 0; @@ -309,7 +309,7 @@ namespace NActors { ctx.Send(ev->Sender, new TLogComponentLevelResponse(code, explanation)); } - void TLoggerActor::RenderComponentPriorities(IOutputStream& str) { + void TLoggerActor::RenderComponentPriorities(IOutputStream& str) { using namespace NLog; HTML(str) { H4() { @@ -690,7 +690,7 @@ namespace NActors { isOk = true; } catch (TSystemError err) { // Interrupted system call - Y_UNUSED(err); + Y_UNUSED(err); } } while (!isOk); } diff --git a/library/cpp/actors/core/log.h b/library/cpp/actors/core/log.h index a7d8ec058a..c11a7cf3c1 100644 --- a/library/cpp/actors/core/log.h +++ b/library/cpp/actors/core/log.h @@ -252,7 +252,7 @@ namespace NActors { void HandleMonInfo(NMon::TEvHttpInfo::TPtr& ev, const TActorContext& ctx); void HandleWakeup(); [[nodiscard]] bool OutputRecord(TInstant time, NLog::EPrio priority, NLog::EComponent component, const TString& formatted) noexcept; - void RenderComponentPriorities(IOutputStream& str); + void RenderComponentPriorities(IOutputStream& str); void LogIgnoredCount(TInstant now); void WriteMessageStat(const NLog::TEvLog& ev); static const char* FormatLocalTimestamp(TInstant time, char* buf); diff --git a/library/cpp/actors/core/log_settings.cpp b/library/cpp/actors/core/log_settings.cpp index bfc5143a3e..f52f2fc5d2 100644 --- a/library/cpp/actors/core/log_settings.cpp +++ b/library/cpp/actors/core/log_settings.cpp @@ -50,7 +50,7 @@ namespace NActors { void TSettings::Append(EComponent minVal, EComponent maxVal, EComponentToStringFunc func) { Y_VERIFY(minVal >= 0, "NLog::TSettings: minVal must be non-negative"); - Y_VERIFY(maxVal > minVal, "NLog::TSettings: maxVal must be greater than minVal"); + Y_VERIFY(maxVal > minVal, "NLog::TSettings: maxVal must be greater than minVal"); // update bounds if (!MaxVal || minVal < MinVal) { diff --git a/library/cpp/actors/core/log_settings.h b/library/cpp/actors/core/log_settings.h index f8aade260a..7fe4504edd 100644 --- a/library/cpp/actors/core/log_settings.h +++ b/library/cpp/actors/core/log_settings.h @@ -144,13 +144,13 @@ namespace NActors { } inline TComponentSettings GetComponentSettings(EComponent component) const { - Y_VERIFY_DEBUG((component & Mask) == component); + Y_VERIFY_DEBUG((component & Mask) == component); // by using Mask we don't get outside of array boundaries return TComponentSettings(AtomicGet(ComponentInfo[component & Mask])); } const char* ComponentName(EComponent component) const { - Y_VERIFY_DEBUG((component & Mask) == component); + Y_VERIFY_DEBUG((component & Mask) == component); return ComponentNames[component & Mask].data(); } diff --git a/library/cpp/actors/core/mon.h b/library/cpp/actors/core/mon.h index a159c89469..c450f2338e 100644 --- a/library/cpp/actors/core/mon.h +++ b/library/cpp/actors/core/mon.h @@ -53,7 +53,7 @@ namespace NActors { virtual ~IEvHttpInfoRes() { } - virtual void Output(IOutputStream& out) const = 0; + virtual void Output(IOutputStream& out) const = 0; virtual EContentType GetContentType() const = 0; }; @@ -66,7 +66,7 @@ namespace NActors { { } - void Output(IOutputStream& out) const override { + void Output(IOutputStream& out) const override { out << Answer; } diff --git a/library/cpp/actors/core/scheduler_actor_ut.cpp b/library/cpp/actors/core/scheduler_actor_ut.cpp index 23e292cd2d..09b7369d36 100644 --- a/library/cpp/actors/core/scheduler_actor_ut.cpp +++ b/library/cpp/actors/core/scheduler_actor_ut.cpp @@ -13,7 +13,7 @@ using namespace NActors; -Y_UNIT_TEST_SUITE(SchedulerActor) { +Y_UNIT_TEST_SUITE(SchedulerActor) { class TTestActor: public TActorBootstrapped<TTestActor> { TManualEvent& DoneEvent; TAtomic& EventsProcessed; @@ -86,15 +86,15 @@ Y_UNIT_TEST_SUITE(SchedulerActor) { actorSystem.Stop(); } - Y_UNIT_TEST(LongEvents) { + Y_UNIT_TEST(LongEvents) { Test(10, 500); } - Y_UNIT_TEST(MediumEvents) { + Y_UNIT_TEST(MediumEvents) { Test(100, 50); } - Y_UNIT_TEST(QuickEvents) { + Y_UNIT_TEST(QuickEvents) { Test(1000, 5); } } diff --git a/library/cpp/actors/dnscachelib/dnscache.cpp b/library/cpp/actors/dnscachelib/dnscache.cpp index 886637046c..649339ddb2 100644 --- a/library/cpp/actors/dnscachelib/dnscache.cpp +++ b/library/cpp/actors/dnscachelib/dnscache.cpp @@ -176,7 +176,7 @@ TDnsCache::Resolve(const TString& hostname, int family, bool cacheOnly) { THostCache::iterator p; - Y_ASSERT(family == AF_INET || family == AF_INET6); + Y_ASSERT(family == AF_INET || family == AF_INET6); { TGuard<TMutex> lock(CacheMtx); @@ -317,7 +317,7 @@ void TDnsCache::WaitTask(TAtomic& flag) { } } - Y_ASSERT(nfds != 0); + Y_ASSERT(nfds != 0); const TDuration left = TInstant(TTimeKeeper::GetTimeval()) - start; const TDuration wait = Max(Timeout - left, TDuration::Zero()); @@ -363,7 +363,7 @@ void TDnsCache::GHBNCallback(void* arg, int status, int, struct hostent* info) { TGuard<TMutex> lock(ctx->Owner->CacheMtx); THostCache::iterator p = ctx->Owner->HostCache.find(ctx->Hostname); - Y_ASSERT(p != ctx->Owner->HostCache.end()); + Y_ASSERT(p != ctx->Owner->HostCache.end()); time_t& resolved = (ctx->Family == AF_INET ? p->second.ResolvedV4 : p->second.ResolvedV6); time_t& notfound = (ctx->Family == AF_INET ? p->second.NotFoundV4 : p->second.NotFoundV6); @@ -387,7 +387,7 @@ void TDnsCache::GHBNCallback(void* arg, int status, int, struct hostent* info) { p->second.AddrsV6.push_back(*(struct in6_addr*)(info->h_addr_list[i])); } } else { - Y_FAIL("unknown address type in ares callback"); + Y_FAIL("unknown address type in ares callback"); } resolved = TTimeKeeper::GetTime(); notfound = 0; @@ -403,7 +403,7 @@ void TDnsCache::GHBACallback(void* arg, int status, int, struct hostent* info) { TGuard<TMutex> lock(ctx->Owner->CacheMtx); TAddrCache::iterator p = ctx->Owner->AddrCache.find(ctx->Addr); - Y_ASSERT(p != ctx->Owner->AddrCache.end()); + Y_ASSERT(p != ctx->Owner->AddrCache.end()); if (status == ARES_SUCCESS) { p->second.Hostname = info->h_name; diff --git a/library/cpp/actors/helpers/selfping_actor_ut.cpp b/library/cpp/actors/helpers/selfping_actor_ut.cpp index 397da9d8eb..459635fa24 100644 --- a/library/cpp/actors/helpers/selfping_actor_ut.cpp +++ b/library/cpp/actors/helpers/selfping_actor_ut.cpp @@ -13,8 +13,8 @@ THolder<TTestActorRuntimeBase> CreateRuntime() { return runtime; } -Y_UNIT_TEST_SUITE(TSelfPingTest) { - Y_UNIT_TEST(Basic) +Y_UNIT_TEST_SUITE(TSelfPingTest) { + Y_UNIT_TEST(Basic) { auto runtime = CreateRuntime(); diff --git a/library/cpp/actors/http/http_ut.cpp b/library/cpp/actors/http/http_ut.cpp index 592a341276..4c922f8d0f 100644 --- a/library/cpp/actors/http/http_ut.cpp +++ b/library/cpp/actors/http/http_ut.cpp @@ -37,8 +37,8 @@ void EatPartialString(TIntrusivePtr<HttpType>& request, const TString& data) { } -Y_UNIT_TEST_SUITE(HttpProxy) { - Y_UNIT_TEST(BasicParsing) { +Y_UNIT_TEST_SUITE(HttpProxy) { + Y_UNIT_TEST(BasicParsing) { NHttp::THttpIncomingRequestPtr request = new NHttp::THttpIncomingRequest(); EatWholeString(request, "GET /test HTTP/1.1\r\nHost: test\r\nSome-Header: 32344\r\n\r\n"); UNIT_ASSERT_EQUAL(request->Stage, NHttp::THttpIncomingRequest::EParseStage::Done); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_EQUAL(request->Headers, "Host: test\r\nSome-Header: 32344\r\n\r\n"); } - Y_UNIT_TEST(BasicParsingChunkedBody) { + Y_UNIT_TEST(BasicParsingChunkedBody) { NHttp::THttpOutgoingRequestPtr request = nullptr; //new NHttp::THttpOutgoingRequest(); NHttp::THttpIncomingResponsePtr response = new NHttp::THttpIncomingResponse(request); EatWholeString(response, "HTTP/1.1 200 OK\r\nConnection: close\r\nTransfer-Encoding: chunked\r\n\r\n4\r\nthis\r\n4\r\n is \r\n5\r\ntest.\r\n0\r\n\r\n"); @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_VALUES_EQUAL(compressedBody, response->Body); } - Y_UNIT_TEST(BasicPartialParsing) { + Y_UNIT_TEST(BasicPartialParsing) { NHttp::THttpIncomingRequestPtr request = new NHttp::THttpIncomingRequest(); EatPartialString(request, "GET /test HTTP/1.1\r\nHost: test\r\nSome-Header: 32344\r\n\r\n"); UNIT_ASSERT_EQUAL(request->Stage, NHttp::THttpIncomingRequest::EParseStage::Done); @@ -106,7 +106,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_EQUAL(request->Headers, "Host: test\r\nSome-Header: 32344\r\n\r\n"); } - Y_UNIT_TEST(BasicPartialParsingChunkedBody) { + Y_UNIT_TEST(BasicPartialParsingChunkedBody) { NHttp::THttpOutgoingRequestPtr request = nullptr; //new NHttp::THttpOutgoingRequest(); NHttp::THttpIncomingResponsePtr response = new NHttp::THttpIncomingResponse(request); EatPartialString(response, "HTTP/1.1 200 OK\r\nConnection: close\r\nTransfer-Encoding: chunked\r\n\r\n4\r\nthis\r\n4\r\n is \r\n5\r\ntest.\r\n0\r\n\r\n"); @@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_EQUAL(response->Body, "this is test."); } - Y_UNIT_TEST(AdvancedParsing) { + Y_UNIT_TEST(AdvancedParsing) { NHttp::THttpIncomingRequestPtr request = new NHttp::THttpIncomingRequest(); EatWholeString(request, "GE"); EatWholeString(request, "T"); @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_EQUAL(request->Headers, "Host: test\r\nSome-Header: 32344\r\n\r\n"); } - Y_UNIT_TEST(AdvancedPartialParsing) { + Y_UNIT_TEST(AdvancedPartialParsing) { NHttp::THttpIncomingRequestPtr request = new NHttp::THttpIncomingRequest(); EatPartialString(request, "GE"); EatPartialString(request, "T"); @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { UNIT_ASSERT_VALUES_EQUAL(requestData, "GET /data/url HTTP/1.1\r\nHost: www.yandex.ru\r\nAccept: */*\r\nCookie: cookie1=123456; cookie2=45678;\r\n"); } - Y_UNIT_TEST(BasicRunning) { + Y_UNIT_TEST(BasicRunning) { NActors::TTestActorRuntimeBase actorSystem; TPortManager portManager; TIpPort port = portManager.GetTcpPort(); @@ -304,7 +304,7 @@ CRA/5XcX13GJwHHj6LCoc3sL7mt8qV9HKY2AOZ88mpObzISZxgPpdKCfjsrdm63V UNIT_ASSERT_EQUAL(response->Response->Body, "passed"); } - /*Y_UNIT_TEST(AdvancedRunning) { + /*Y_UNIT_TEST(AdvancedRunning) { THolder<NActors::TActorSystemSetup> setup = MakeHolder<NActors::TActorSystemSetup>(); setup->NodeId = 1; setup->ExecutorsCount = 1; diff --git a/library/cpp/actors/interconnect/ut_fat/main.cpp b/library/cpp/actors/interconnect/ut_fat/main.cpp index c399254904..5d19bc3003 100644 --- a/library/cpp/actors/interconnect/ut_fat/main.cpp +++ b/library/cpp/actors/interconnect/ut_fat/main.cpp @@ -15,7 +15,7 @@ #include <util/system/atomic.h> #include <util/generic/set.h> -Y_UNIT_TEST_SUITE(InterconnectUnstableConnection) { +Y_UNIT_TEST_SUITE(InterconnectUnstableConnection) { using namespace NActors; class TSenderActor: public TSenderBaseActor { @@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(InterconnectUnstableConnection) { } }; - Y_UNIT_TEST(InterconnectTestWithProxyUnsureUndelivered) { + Y_UNIT_TEST(InterconnectTestWithProxyUnsureUndelivered) { ui32 numNodes = 2; double bandWidth = 1000000; ui16 flags = IEventHandle::FlagTrackDelivery | IEventHandle::FlagGenerateUnsureUndelivered; @@ -115,7 +115,7 @@ Y_UNIT_TEST_SUITE(InterconnectUnstableConnection) { NanoSleep(30ULL * 1000 * 1000 * 1000); } - Y_UNIT_TEST(InterconnectTestWithProxy) { + Y_UNIT_TEST(InterconnectTestWithProxy) { ui32 numNodes = 2; double bandWidth = 1000000; ui16 flags = IEventHandle::FlagTrackDelivery; diff --git a/library/cpp/actors/testlib/test_runtime.cpp b/library/cpp/actors/testlib/test_runtime.cpp index d876229f1f..6fa25b9965 100644 --- a/library/cpp/actors/testlib/test_runtime.cpp +++ b/library/cpp/actors/testlib/test_runtime.cpp @@ -95,7 +95,7 @@ namespace NActors { } STFUNC(StateFunc) { - Y_UNUSED(ctx); + Y_UNUSED(ctx); TGuard<TMutex> guard(Runtime->Mutex); bool verbose = (Runtime->CurrentDispatchContext ? !Runtime->CurrentDispatchContext->Options->Quiet : true) && VERBOSE; if (Runtime->BlockedOutput.find(ev->Sender) != Runtime->BlockedOutput.end()) { @@ -109,7 +109,7 @@ namespace NActors { if (!Runtime->EventFilterFunc(*Runtime, ev)) { ui32 nodeId = ev->GetRecipientRewrite().NodeId(); - Y_VERIFY(nodeId != 0); + Y_VERIFY(nodeId != 0); ui32 mailboxHint = ev->GetRecipientRewrite().Hint(); Runtime->GetMailbox(nodeId, mailboxHint).Send(ev); Runtime->MailboxesHasEvents.Signal(); @@ -128,7 +128,7 @@ namespace NActors { void TEventMailBox::Send(TAutoPtr<IEventHandle> ev) { IEventHandle* ptr = ev.Get(); - Y_VERIFY(ptr); + Y_VERIFY(ptr); #ifdef DEBUG_ORDER_EVENTS ui64 counter = NextToSend++; TrackSent[ptr] = counter; @@ -142,7 +142,7 @@ namespace NActors { #ifdef DEBUG_ORDER_EVENTS auto it = TrackSent.find(result.Get()); if (it != TrackSent.end()) { - Y_VERIFY(ExpectedReceive == it->second); + Y_VERIFY(ExpectedReceive == it->second); TrackSent.erase(result.Get()); ++ExpectedReceive; } @@ -239,18 +239,18 @@ namespace NActors { : Runtime(runtime) , Node(node) { - Y_UNUSED(Runtime); + Y_UNUSED(Runtime); } void Prepare(TActorSystem *actorSystem, volatile ui64 *currentTimestamp, volatile ui64 *currentMonotonic) override { - Y_UNUSED(actorSystem); + Y_UNUSED(actorSystem); Node->ActorSystemTimestamp = currentTimestamp; Node->ActorSystemMonotonic = currentMonotonic; } void PrepareSchedules(NSchedulerQueue::TReader **readers, ui32 scheduleReadersCount) override { - Y_UNUSED(readers); - Y_UNUSED(scheduleReadersCount); + Y_UNUSED(readers); + Y_UNUSED(scheduleReadersCount); } void Start() override { @@ -284,8 +284,8 @@ namespace NActors { // for threads ui32 GetReadyActivation(TWorkerContext& wctx, ui64 revolvingCounter) override { Y_UNUSED(wctx); - Y_UNUSED(revolvingCounter); - Y_FAIL(); + Y_UNUSED(revolvingCounter); + Y_FAIL(); } void ReclaimMailbox(TMailboxType::EType mailboxType, ui32 hint, TWorkerId workerId, ui64 revolvingCounter) override { @@ -357,7 +357,7 @@ namespace NActors { if (!Runtime->EventFilterFunc(*Runtime, ev)) { ui32 nodeId = ev->GetRecipientRewrite().NodeId(); - Y_VERIFY(nodeId != 0); + Y_VERIFY(nodeId != 0); TNodeDataBase* node = Runtime->Nodes[nodeId].Get(); if (!AllowSendFrom(node, ev)) { @@ -394,12 +394,12 @@ namespace NActors { } void ScheduleActivation(ui32 activation) override { - Y_UNUSED(activation); + Y_UNUSED(activation); } void ScheduleActivationEx(ui32 activation, ui64 revolvingCounter) override { - Y_UNUSED(activation); - Y_UNUSED(revolvingCounter); + Y_UNUSED(activation); + Y_UNUSED(revolvingCounter); } TActorId Register(IActor *actor, TMailboxType::EType mailboxType, ui64 revolvingCounter, @@ -413,9 +413,9 @@ namespace NActors { // lifecycle stuff void Prepare(TActorSystem *actorSystem, NSchedulerQueue::TReader **scheduleReaders, ui32 *scheduleSz) override { - Y_UNUSED(actorSystem); - Y_UNUSED(scheduleReaders); - Y_UNUSED(scheduleSz); + Y_UNUSED(actorSystem); + Y_UNUSED(scheduleReaders); + Y_UNUSED(scheduleSz); } void Start() override { @@ -433,7 +433,7 @@ namespace NActors { // generic TAffinity* Affinity() const override { - Y_FAIL(); + Y_FAIL(); } private: @@ -553,20 +553,20 @@ namespace NActors { } TTestActorRuntimeBase::EEventAction TTestActorRuntimeBase::DefaultObserverFunc(TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { - Y_UNUSED(runtime); - Y_UNUSED(event); + Y_UNUSED(runtime); + Y_UNUSED(event); return EEventAction::PROCESS; } void TTestActorRuntimeBase::DroppingScheduledEventsSelector(TTestActorRuntimeBase& runtime, TScheduledEventsList& scheduledEvents, TEventsList& queue) { - Y_UNUSED(runtime); - Y_UNUSED(queue); + Y_UNUSED(runtime); + Y_UNUSED(queue); scheduledEvents.clear(); } bool TTestActorRuntimeBase::DefaultFilterFunc(TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { - Y_UNUSED(runtime); - Y_UNUSED(event); + Y_UNUSED(runtime); + Y_UNUSED(event); return false; } @@ -618,7 +618,7 @@ namespace NActors { } } - void Print(IOutputStream& stream, const TString& prefix) { + void Print(IOutputStream& stream, const TString& prefix) { for (auto it = Children.begin(); it != Children.end(); ++it) { bool lastChild = (std::next(it) == Children.end()); TString connectionPrefix = lastChild ? "└─ " : "├─ "; @@ -628,7 +628,7 @@ namespace NActors { } } - void Print(IOutputStream& stream) { + void Print(IOutputStream& stream) { stream << Name << " (" << Count << ")\n"; Print(stream, TString()); } @@ -726,8 +726,8 @@ namespace NActors { } void TTestActorRuntimeBase::AddLocalService(const TActorId& actorId, const TActorSetupCmd& cmd, ui32 nodeIndex) { - Y_VERIFY(!IsInitialized); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(!IsInitialized); + Y_VERIFY(nodeIndex < NodeCount); auto node = Nodes[nodeIndex + FirstNodeId]; if (!node) { node = GetNodeFactory().CreateNode(); @@ -793,7 +793,7 @@ namespace NActors { TInstant TTestActorRuntimeBase::GetCurrentTime() const { TGuard<TMutex> guard(Mutex); - Y_VERIFY(!UseRealThreads); + Y_VERIFY(!UseRealThreads); return TInstant::MicroSeconds(CurrentTimestamp); } @@ -804,7 +804,7 @@ namespace NActors { Cerr << "UpdateCurrentTime(" << counter << "," << newTime << ")\n"; } TGuard<TMutex> guard(Mutex); - Y_VERIFY(!UseRealThreads); + Y_VERIFY(!UseRealThreads); if (newTime.MicroSeconds() > CurrentTimestamp) { CurrentTimestamp = newTime.MicroSeconds(); for (auto& kv : Nodes) { @@ -819,12 +819,12 @@ namespace NActors { } TIntrusivePtr<ITimeProvider> TTestActorRuntimeBase::GetTimeProvider() { - Y_VERIFY(!UseRealThreads); + Y_VERIFY(!UseRealThreads); return TimeProvider; } ui32 TTestActorRuntimeBase::GetNodeId(ui32 index) const { - Y_VERIFY(index < NodeCount); + Y_VERIFY(index < NodeCount); return FirstNodeId + index; } @@ -859,11 +859,11 @@ namespace NActors { TActorId TTestActorRuntimeBase::Register(IActor* actor, ui32 nodeIndex, ui32 poolId, TMailboxType::EType mailboxType, ui64 revolvingCounter, const TActorId& parentId) { - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); TGuard<TMutex> guard(Mutex); TNodeDataBase* node = Nodes[FirstNodeId + nodeIndex].Get(); if (UseRealThreads) { - Y_VERIFY(poolId < node->ExecutorPools.size()); + Y_VERIFY(poolId < node->ExecutorPools.size()); return node->ExecutorPools[poolId]->Register(actor, mailboxType, revolvingCounter, parentId); } @@ -927,11 +927,11 @@ namespace NActors { TActorId TTestActorRuntimeBase::Register(IActor *actor, ui32 nodeIndex, ui32 poolId, TMailboxHeader *mailbox, ui32 hint, const TActorId& parentId) { - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); TGuard<TMutex> guard(Mutex); TNodeDataBase* node = Nodes[FirstNodeId + nodeIndex].Get(); if (UseRealThreads) { - Y_VERIFY(poolId < node->ExecutorPools.size()); + Y_VERIFY(poolId < node->ExecutorPools.size()); return node->ExecutorPools[poolId]->Register(actor, mailbox, hint, parentId); } @@ -951,7 +951,7 @@ namespace NActors { TActorId TTestActorRuntimeBase::RegisterService(const TActorId& serviceId, const TActorId& actorId, ui32 nodeIndex) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); TNodeDataBase* node = Nodes[FirstNodeId + nodeIndex].Get(); if (!UseRealThreads) { IActor* actor = FindActor(actorId, node); @@ -964,7 +964,7 @@ namespace NActors { TActorId TTestActorRuntimeBase::AllocateEdgeActor(ui32 nodeIndex) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); TActorId edgeActor = Register(new TEdgeActor(this), nodeIndex); EdgeActors.insert(edgeActor); EdgeActorByMailbox[TEventMailboxId(edgeActor.NodeId(), edgeActor.Hint())] = edgeActor; @@ -983,7 +983,7 @@ namespace NActors { TEventsList TTestActorRuntimeBase::CaptureMailboxEvents(ui32 hint, ui32 nodeId) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeId >= FirstNodeId && nodeId < FirstNodeId + NodeCount); + Y_VERIFY(nodeId >= FirstNodeId && nodeId < FirstNodeId + NodeCount); TEventsList result; GetMailbox(nodeId, hint).Capture(result); return result; @@ -992,7 +992,7 @@ namespace NActors { void TTestActorRuntimeBase::PushFront(TAutoPtr<IEventHandle>& ev) { TGuard<TMutex> guard(Mutex); ui32 nodeId = ev->GetRecipientRewrite().NodeId(); - Y_VERIFY(nodeId != 0); + Y_VERIFY(nodeId != 0); GetMailbox(nodeId, ev->GetRecipientRewrite().Hint()).PushFront(ev); } @@ -1002,7 +1002,7 @@ namespace NActors { if (*rit) { auto& ev = *rit; ui32 nodeId = ev->GetRecipientRewrite().NodeId(); - Y_VERIFY(nodeId != 0); + Y_VERIFY(nodeId != 0); GetMailbox(nodeId, ev->GetRecipientRewrite().Hint()).PushFront(ev); } } @@ -1012,7 +1012,7 @@ namespace NActors { void TTestActorRuntimeBase::PushMailboxEventsFront(ui32 hint, ui32 nodeId, TEventsList& events) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeId >= FirstNodeId && nodeId < FirstNodeId + NodeCount); + Y_VERIFY(nodeId >= FirstNodeId && nodeId < FirstNodeId + NodeCount); TEventsList result; GetMailbox(nodeId, hint).PushFront(events); events.clear(); @@ -1081,7 +1081,7 @@ namespace NActors { Runtime.GetMailbox(edgeActor.NodeId(), edgeActor.Hint()).Capture(events); auto mboxId = TEventMailboxId(edgeActor.NodeId(), edgeActor.Hint()); auto storeIt = Store.find(mboxId); - Y_VERIFY(storeIt == Store.end()); + Y_VERIFY(storeIt == Store.end()); storeIt = Store.insert(std::make_pair(mboxId, new TEventMailBox)).first; storeIt->second->PushFront(events); if (!events.empty()) @@ -1213,13 +1213,13 @@ namespace NActors { break; } default: - Y_FAIL("Unknown action"); + Y_FAIL("Unknown action"); } } } } - Y_VERIFY(mboxIt != currentMailboxes.end()); + Y_VERIFY(mboxIt != currentMailboxes.end()); if (!isIgnored && !CurrentDispatchContext->PrevContext && !restrictedMailboxes && mboxIt->second->IsEmpty() && mboxIt->second->IsScheduledEmpty() && @@ -1230,7 +1230,7 @@ namespace NActors { if (mboxIt == currentMailboxes.end()) { mboxIt = currentMailboxes.begin(); } - Y_VERIFY(endWithMboxIt != currentMailboxes.end()); + Y_VERIFY(endWithMboxIt != currentMailboxes.end()); if (mboxIt == endWithMboxIt) { break; } @@ -1384,14 +1384,14 @@ namespace NActors { void TTestActorRuntimeBase::Send(IEventHandle* ev, ui32 senderNodeIndex, bool viaActorSystem) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(senderNodeIndex < NodeCount, "senderNodeIndex# %" PRIu32 " < NodeCount# %" PRIu32, + Y_VERIFY(senderNodeIndex < NodeCount, "senderNodeIndex# %" PRIu32 " < NodeCount# %" PRIu32, senderNodeIndex, NodeCount); SendInternal(ev, senderNodeIndex, viaActorSystem); } void TTestActorRuntimeBase::Schedule(IEventHandle* ev, const TDuration& duration, ui32 nodeIndex) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); ui32 nodeId = FirstNodeId + nodeIndex; ui32 mailboxHint = ev->GetRecipientRewrite().Hint(); TInstant deadline = TInstant::MicroSeconds(CurrentTimestamp) + duration; @@ -1416,7 +1416,7 @@ namespace NActors { TActorId TTestActorRuntimeBase::GetLocalServiceId(const TActorId& serviceId, ui32 nodeIndex) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); TNodeDataBase* node = Nodes[FirstNodeId + nodeIndex].Get(); return node->ActorSystem->LookupLocalService(serviceId); } @@ -1456,15 +1456,15 @@ namespace NActors { } } - Y_VERIFY(dispatchCount < 1000, "Hard limit to prevent endless loop"); + Y_VERIFY(dispatchCount < 1000, "Hard limit to prevent endless loop"); } } TActorId TTestActorRuntimeBase::GetInterconnectProxy(ui32 nodeIndexFrom, ui32 nodeIndexTo) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndexFrom < NodeCount); - Y_VERIFY(nodeIndexTo < NodeCount); - Y_VERIFY(nodeIndexFrom != nodeIndexTo); + Y_VERIFY(nodeIndexFrom < NodeCount); + Y_VERIFY(nodeIndexTo < NodeCount); + Y_VERIFY(nodeIndexFrom != nodeIndexTo); TNodeDataBase* node = Nodes[FirstNodeId + nodeIndexFrom].Get(); return node->ActorSystem->InterconnectProxy(FirstNodeId + nodeIndexTo); } @@ -1483,13 +1483,13 @@ namespace NActors { IActor* TTestActorRuntimeBase::FindActor(const TActorId& actorId, ui32 nodeIndex) const { TGuard<TMutex> guard(Mutex); if (nodeIndex == Max<ui32>()) { - Y_VERIFY(actorId.NodeId()); + Y_VERIFY(actorId.NodeId()); nodeIndex = actorId.NodeId() - FirstNodeId; } - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); auto nodeIt = Nodes.find(FirstNodeId + nodeIndex); - Y_VERIFY(nodeIt != Nodes.end()); + Y_VERIFY(nodeIt != Nodes.end()); TNodeDataBase* node = nodeIt->second.Get(); return FindActor(actorId, node); } @@ -1516,7 +1516,7 @@ namespace NActors { TIntrusivePtr<NMonitoring::TDynamicCounters> TTestActorRuntimeBase::GetDynamicCounters(ui32 nodeIndex) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); ui32 nodeId = FirstNodeId + nodeIndex; TNodeDataBase* node = Nodes[nodeId].Get(); return node->DynamicCounters; @@ -1527,7 +1527,7 @@ namespace NActors { } void TTestActorRuntimeBase::SendInternal(IEventHandle* ev, ui32 nodeIndex, bool viaActorSystem) { - Y_VERIFY(nodeIndex < NodeCount); + Y_VERIFY(nodeIndex < NodeCount); ui32 nodeId = FirstNodeId + nodeIndex; TNodeDataBase* node = Nodes[nodeId].Get(); ui32 targetNode = ev->GetRecipientRewrite().NodeId(); @@ -1536,7 +1536,7 @@ namespace NActors { targetNodeIndex = nodeIndex; } else { targetNodeIndex = targetNode - FirstNodeId; - Y_VERIFY(targetNodeIndex < NodeCount); + Y_VERIFY(targetNodeIndex < NodeCount); } if (viaActorSystem || UseRealThreads || ev->GetRecipientRewrite().IsService() || (targetNodeIndex != nodeIndex)) { @@ -1544,7 +1544,7 @@ namespace NActors { return; } - Y_VERIFY(!ev->GetRecipientRewrite().IsService() && (targetNodeIndex == nodeIndex)); + Y_VERIFY(!ev->GetRecipientRewrite().IsService() && (targetNodeIndex == nodeIndex)); TAutoPtr<IEventHandle> evHolder(ev); if (!AllowSendFrom(node, evHolder)) { @@ -1705,7 +1705,7 @@ namespace NActors { for (auto& x : Nodes) { return x.second->ActorSystem.Get(); } - Y_FAIL("Don't use this method."); + Y_FAIL("Don't use this method."); } TActorSystem* TTestActorRuntimeBase::GetActorSystem(ui32 nodeId) { @@ -1785,7 +1785,7 @@ namespace NActors { , ReplyChecker(createReplyChecker()) { if (IsSync) { - Y_VERIFY(!runtime->IsRealThreads()); + Y_VERIFY(!runtime->IsRealThreads()); } } @@ -1811,7 +1811,7 @@ namespace NActors { } STFUNC(Reply) { - Y_VERIFY(!HasReply); + Y_VERIFY(!HasReply); IEventHandle *requestEv = Context->Queue->Head(); TActorId originalSender = requestEv->Sender; HasReply = !ReplyChecker->IsWaitingForMoreResponses(ev.Get()); diff --git a/library/cpp/actors/testlib/test_runtime.h b/library/cpp/actors/testlib/test_runtime.h index ee85ddadfa..26e3b45c98 100644 --- a/library/cpp/actors/testlib/test_runtime.h +++ b/library/cpp/actors/testlib/test_runtime.h @@ -292,7 +292,7 @@ namespace NActors { handle.Destroy(); const ui32 eventType = TEvent::EventType; WaitForEdgeEvents([&](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { - Y_UNUSED(runtime); + Y_UNUSED(runtime); if (event->GetTypeRewrite() != eventType) return false; @@ -306,7 +306,7 @@ namespace NActors { }, {}, simTimeout); if (simTimeout == TDuration::Max()) - Y_VERIFY(handle); + Y_VERIFY(handle); if (handle) { return reinterpret_cast<TAutoPtr<TEventHandle<TEvent>>&>(handle)->Get(); diff --git a/library/cpp/actors/util/affinity.cpp b/library/cpp/actors/util/affinity.cpp index 95ff465f37..cc1b6e70ec 100644 --- a/library/cpp/actors/util/affinity.cpp +++ b/library/cpp/actors/util/affinity.cpp @@ -12,7 +12,7 @@ public: TImpl() { #ifdef _linux_ int ar = sched_getaffinity(0, sizeof(cpu_set_t), &Mask); - Y_VERIFY_DEBUG(ar == 0); + Y_VERIFY_DEBUG(ar == 0); #endif } @@ -33,7 +33,7 @@ public: void Set() const { #ifdef _linux_ int ar = sched_setaffinity(0, sizeof(cpu_set_t), &Mask); - Y_VERIFY_DEBUG(ar == 0); + Y_VERIFY_DEBUG(ar == 0); #endif } diff --git a/library/cpp/actors/util/queue_oneone_inplace.h b/library/cpp/actors/util/queue_oneone_inplace.h index e00f05b20d..d7ec8bb21c 100644 --- a/library/cpp/actors/util/queue_oneone_inplace.h +++ b/library/cpp/actors/util/queue_oneone_inplace.h @@ -48,7 +48,7 @@ public: } ~TOneOneQueueInplace() { - Y_VERIFY_DEBUG(Head() == 0); + Y_VERIFY_DEBUG(Head() == 0); delete ReadFrom; } diff --git a/library/cpp/actors/util/ticket_lock.h b/library/cpp/actors/util/ticket_lock.h index bf0e3d795b..3b1fa80393 100644 --- a/library/cpp/actors/util/ticket_lock.h +++ b/library/cpp/actors/util/ticket_lock.h @@ -23,7 +23,7 @@ public: ui32 revolves = 0; const ui32 ticket = AtomicUi32Increment(&TicketIn) - 1; while (ticket != AtomicLoad(&TicketOut)) { - Y_VERIFY_DEBUG(ticket >= AtomicLoad(&TicketOut)); + Y_VERIFY_DEBUG(ticket >= AtomicLoad(&TicketOut)); SpinLockPause(); ++revolves; } diff --git a/library/cpp/actors/util/unordered_cache.h b/library/cpp/actors/util/unordered_cache.h index 06e4571452..76f036c0cf 100644 --- a/library/cpp/actors/util/unordered_cache.h +++ b/library/cpp/actors/util/unordered_cache.h @@ -100,7 +100,7 @@ private: } void WriteOne(TLockedWriter& lock, T x) { - Y_VERIFY_DEBUG(x != 0); + Y_VERIFY_DEBUG(x != 0); const ui32 pos = AtomicLoad(&lock.Slot->WritePosition); if (pos != TChunk::EntriesCount) { @@ -127,7 +127,7 @@ public: } ~TUnorderedCache() { - Y_VERIFY(!Pop(0)); + Y_VERIFY(!Pop(0)); for (ui64 i = 0; i < Concurrency; ++i) { if (ReadSlots[i].ReadFrom) { diff --git a/library/cpp/actors/wilson/wilson_event.h b/library/cpp/actors/wilson/wilson_event.h index 1810582675..7d89c33b51 100644 --- a/library/cpp/actors/wilson/wilson_event.h +++ b/library/cpp/actors/wilson/wilson_event.h @@ -76,7 +76,7 @@ namespace NWilson { using TParamPack = N##EVENT_NAME##Params::TParamPack; \ TParamPack ParamPack; \ \ - void Output(IOutputStream& str) { \ + void Output(IOutputStream& str) { \ str << #EVENT_NAME << "{"; \ __UNROLL_PARAMS(__OUTPUT_PARAM, ##__VA_ARGS__) \ str << "}"; \ diff --git a/library/cpp/actors/wilson/wilson_trace.h b/library/cpp/actors/wilson/wilson_trace.h index 997d7e2462..3d1ca50562 100644 --- a/library/cpp/actors/wilson/wilson_trace.h +++ b/library/cpp/actors/wilson/wilson_trace.h @@ -101,7 +101,7 @@ namespace NWilson { } // Output trace id into a string stream - void Output(IOutputStream& s, const TTraceId& parentTraceId) const { + void Output(IOutputStream& s, const TTraceId& parentTraceId) const { union { ui8 buffer[3 * sizeof(ui64)]; struct { @@ -122,7 +122,7 @@ namespace NWilson { } // output just span id into stream - void OutputSpanId(IOutputStream& s) const { + void OutputSpanId(IOutputStream& s) const { const size_t base64size = Base64EncodeBufSize(sizeof(SpanId)); char base64[base64size]; char* end = Base64Encode(base64, reinterpret_cast<const ui8*>(&SpanId), sizeof(SpanId)); diff --git a/library/cpp/archive/yarchive.cpp b/library/cpp/archive/yarchive.cpp index 78aaa17525..1becc3e5da 100644 --- a/library/cpp/archive/yarchive.cpp +++ b/library/cpp/archive/yarchive.cpp @@ -2,33 +2,33 @@ #include <util/generic/algorithm.h> #include <util/generic/hash.h> -#include <util/generic/utility.h> +#include <util/generic/utility.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> -#include <util/memory/blob.h> -#include <util/memory/tempbuf.h> -#include <util/stream/input.h> -#include <util/stream/length.h> -#include <util/stream/mem.h> -#include <util/stream/output.h> -#include <util/stream/zlib.h> -#include <util/system/byteorder.h> -#include <util/ysaveload.h> +#include <util/memory/blob.h> +#include <util/memory/tempbuf.h> +#include <util/stream/input.h> +#include <util/stream/length.h> +#include <util/stream/mem.h> +#include <util/stream/output.h> +#include <util/stream/zlib.h> +#include <util/system/byteorder.h> +#include <util/ysaveload.h> template <class T> -static inline void ESSave(IOutputStream* out, const T& t_in) { +static inline void ESSave(IOutputStream* out, const T& t_in) { T t = HostToLittle(t_in); out->Write((const void*)&t, sizeof(t)); } -static inline void ESSave(IOutputStream* out, const TString& s) { +static inline void ESSave(IOutputStream* out, const TString& s) { ESSave(out, (ui32) s.size()); out->Write(s.data(), s.size()); } template <class T> -static inline T ESLoad(IInputStream* in) { +static inline T ESLoad(IInputStream* in) { T t = T(); if (in->Load(&t, sizeof(t)) != sizeof(t)) { @@ -39,7 +39,7 @@ static inline T ESLoad(IInputStream* in) { } template <> -inline TString ESLoad<TString>(IInputStream* in) { +inline TString ESLoad<TString>(IInputStream* in) { size_t len = ESLoad<ui32>(in); TString ret; TTempBuf tmp; @@ -69,7 +69,7 @@ namespace { { } - inline TArchiveRecordDescriptor(IInputStream* in) + inline TArchiveRecordDescriptor(IInputStream* in) : Off_(ESLoad<ui64>(in)) , Len_(ESLoad<ui64>(in)) , Name_(ESLoad<TString>(in)) @@ -78,7 +78,7 @@ namespace { inline ~TArchiveRecordDescriptor() = default; - inline void SaveTo(IOutputStream* out) const { + inline void SaveTo(IOutputStream* out) const { ESSave(out, Off_); ESSave(out, Len_); ESSave(out, Name_); @@ -109,7 +109,7 @@ class TArchiveWriter::TImpl { using TDict = THashMap<TString, TArchiveRecordDescriptorRef>; public: - inline TImpl(IOutputStream& out, bool compress) + inline TImpl(IOutputStream& out, bool compress) : Off_(0) , Out_(&out) , UseCompression(compress) @@ -123,15 +123,15 @@ public: } inline void Finish() { - TCountingOutput out(Out_); + TCountingOutput out(Out_); { TZLibCompress compress(&out); ESSave(&compress, (ui32)Dict_.size()); - for (const auto& kv : Dict_) { - kv.second->SaveTo(&compress); + for (const auto& kv : Dict_) { + kv.second->SaveTo(&compress); } ESSave(&compress, static_cast<ui8>(UseCompression)); @@ -139,15 +139,15 @@ public: compress.Finish(); } - ESSave(Out_, out.Counter()); + ESSave(Out_, out.Counter()); Out_->Flush(); } - inline void Add(const TString& key, IInputStream* src) { + inline void Add(const TString& key, IInputStream* src) { Y_ENSURE(!Dict_.contains(key), "key " << key.data() << " already stored"); - TCountingOutput out(Out_); + TCountingOutput out(Out_); if (UseCompression) { TZLibCompress compress(&out); TransferData(src, &compress); @@ -166,10 +166,10 @@ public: out.Finish(); } - TArchiveRecordDescriptorRef descr(new TArchiveRecordDescriptor(Off_, out.Counter(), key)); + TArchiveRecordDescriptorRef descr(new TArchiveRecordDescriptor(Off_, out.Counter(), key)); Dict_[key] = descr; - Off_ += out.Counter(); + Off_ += out.Counter(); } inline void AddSynonym(const TString& existingKey, const TString& newKey) { @@ -184,12 +184,12 @@ public: private: ui64 Off_; - IOutputStream* Out_; + IOutputStream* Out_; TDict Dict_; const bool UseCompression; }; -TArchiveWriter::TArchiveWriter(IOutputStream* out, bool compress) +TArchiveWriter::TArchiveWriter(IOutputStream* out, bool compress) : Impl_(new TImpl(*out, compress)) { } @@ -214,7 +214,7 @@ void TArchiveWriter::Finish() { } } -void TArchiveWriter::Add(const TString& key, IInputStream* src) { +void TArchiveWriter::Add(const TString& key, IInputStream* src) { Y_ENSURE(Impl_.Get(), "archive already closed"); Impl_->Add(key, src); @@ -287,8 +287,8 @@ public: Recs_.push_back(descr); Dict_[descr->Name()] = descr; } - Sort(Recs_.begin(), Recs_.end(), [](const auto& lhs, const auto& rhs) -> bool { - return lhs->Offset() < rhs->Offset(); + Sort(Recs_.begin(), Recs_.end(), [](const auto& lhs, const auto& rhs) -> bool { + return lhs->Offset() < rhs->Offset(); }); try { @@ -311,11 +311,11 @@ public: ythrow yexception() << "incorrect index"; } - inline bool Has(const TStringBuf key) const { + inline bool Has(const TStringBuf key) const { return Dict_.contains(key); } - inline TAutoPtr<IInputStream> ObjectByKey(const TStringBuf key) const { + inline TAutoPtr<IInputStream> ObjectByKey(const TStringBuf key) const { TBlob subBlob = BlobByKey(key); if (UseDecompression) { @@ -325,7 +325,7 @@ public: } } - inline TBlob ObjectBlobByKey(const TStringBuf key) const { + inline TBlob ObjectBlobByKey(const TStringBuf key) const { TBlob subBlob = BlobByKey(key); if (UseDecompression) { @@ -336,8 +336,8 @@ public: } } - inline TBlob BlobByKey(const TStringBuf key) const { - const auto it = Dict_.find(key); + inline TBlob BlobByKey(const TStringBuf key) const { + const auto it = Dict_.find(key); Y_ENSURE(it != Dict_.end(), "key " << key.data() << " not found"); @@ -377,19 +377,19 @@ TString TArchiveReader::KeyByIndex(size_t n) const { return Impl_->KeyByIndex(n); } -bool TArchiveReader::Has(const TStringBuf key) const { +bool TArchiveReader::Has(const TStringBuf key) const { return Impl_->Has(key); } -TAutoPtr<IInputStream> TArchiveReader::ObjectByKey(const TStringBuf key) const { +TAutoPtr<IInputStream> TArchiveReader::ObjectByKey(const TStringBuf key) const { return Impl_->ObjectByKey(key); } -TBlob TArchiveReader::ObjectBlobByKey(const TStringBuf key) const { +TBlob TArchiveReader::ObjectBlobByKey(const TStringBuf key) const { return Impl_->ObjectBlobByKey(key); } -TBlob TArchiveReader::BlobByKey(const TStringBuf key) const { +TBlob TArchiveReader::BlobByKey(const TStringBuf key) const { return Impl_->BlobByKey(key); } diff --git a/library/cpp/archive/yarchive.h b/library/cpp/archive/yarchive.h index 50aaa253f2..8120bcb940 100644 --- a/library/cpp/archive/yarchive.h +++ b/library/cpp/archive/yarchive.h @@ -2,15 +2,15 @@ #include "models_archive_reader.h" -#include <util/generic/fwd.h> +#include <util/generic/fwd.h> #include <util/generic/ptr.h> -class IInputStream; -class IOutputStream; - -class TBlob; - +class IInputStream; +class IOutputStream; + +class TBlob; + //noncompressed data will be stored with default alignment DEVTOOLS-4384 static constexpr size_t ArchiveWriterDefaultDataAlignment = 16; @@ -21,7 +21,7 @@ public: void Flush(); void Finish(); - void Add(const TString& key, IInputStream* src); + void Add(const TString& key, IInputStream* src); void AddSynonym(const TString& existingKey, const TString& newKey); private: diff --git a/library/cpp/archive/yarchive_ut.cpp b/library/cpp/archive/yarchive_ut.cpp index 21b9eec40f..602a1cdbbd 100644 --- a/library/cpp/archive/yarchive_ut.cpp +++ b/library/cpp/archive/yarchive_ut.cpp @@ -5,7 +5,7 @@ #include <util/string/cast.h> #include <util/stream/file.h> #include <util/system/tempfile.h> -#include <util/memory/blob.h> +#include <util/memory/blob.h> class TArchiveTest: public TTestBase { UNIT_TEST_SUITE(TArchiveTest) @@ -56,7 +56,7 @@ void TArchiveTest::TestRead() { for (size_t i = 0; i < 1000; ++i) { const TString key = "/" + ToString(i); - TAutoPtr<IInputStream> is = r.ObjectByKey(key); + TAutoPtr<IInputStream> is = r.ObjectByKey(key); const TString data = is->ReadAll(); UNIT_ASSERT_EQUAL(data, "data" + ToString(i * 1000) + "dataend"); diff --git a/library/cpp/balloc/balloc.cpp b/library/cpp/balloc/balloc.cpp index 6b96e943b7..fab489db4c 100644 --- a/library/cpp/balloc/balloc.cpp +++ b/library/cpp/balloc/balloc.cpp @@ -248,7 +248,7 @@ extern "C" void* realloc(void* oldPtr, size_t newSize) { NBalloc::TAllocHeader* header = (NBalloc::TAllocHeader*)oldPtr - 1; const size_t oldSize = header->AllocSize & ~NBalloc::SIGNATURE_MASK; const size_t signature = header->AllocSize & NBalloc::SIGNATURE_MASK; - if (Y_LIKELY((signature == NBalloc::ALIVE_SIGNATURE) || (signature == NBalloc::DISABLED_SIGNATURE))) { + if (Y_LIKELY((signature == NBalloc::ALIVE_SIGNATURE) || (signature == NBalloc::DISABLED_SIGNATURE))) { memcpy(newPtr, oldPtr, oldSize < newSize ? oldSize : newSize); NBalloc::Free(oldPtr); return newPtr; diff --git a/library/cpp/balloc/ya.make b/library/cpp/balloc/ya.make index 5238973d49..d4457fbba9 100644 --- a/library/cpp/balloc/ya.make +++ b/library/cpp/balloc/ya.make @@ -8,20 +8,20 @@ OWNER( NO_UTIL() NO_COMPILER_WARNINGS() -IF (OS_WINDOWS) - PEERDIR( +IF (OS_WINDOWS) + PEERDIR( library/cpp/lfalloc - ) -ELSE() - SRCS( - balloc.cpp - malloc-info.cpp - ) + ) +ELSE() + SRCS( + balloc.cpp + malloc-info.cpp + ) PEERDIR( library/cpp/balloc/lib ) -ENDIF() +ENDIF() END() diff --git a/library/cpp/binsaver/bin_saver.cpp b/library/cpp/binsaver/bin_saver.cpp index 9bc28d1490..fe0775af9f 100644 --- a/library/cpp/binsaver/bin_saver.cpp +++ b/library/cpp/binsaver/bin_saver.cpp @@ -3,7 +3,7 @@ TClassFactory<IObjectBase>* pSaverClasses; void StartRegisterSaveload() { if (!pSaverClasses) - pSaverClasses = new TClassFactory<IObjectBase>; + pSaverClasses = new TClassFactory<IObjectBase>; } struct SBasicChunkInit { ~SBasicChunkInit() { @@ -15,7 +15,7 @@ struct SBasicChunkInit { ////////////////////////////////////////////////////////////////////////// void IBinSaver::StoreObject(IObjectBase* pObject) { if (pObject) { - Y_ASSERT(pSaverClasses->GetObjectTypeID(pObject) != -1 && "trying to save unregistered object"); + Y_ASSERT(pSaverClasses->GetObjectTypeID(pObject) != -1 && "trying to save unregistered object"); } ui64 ptrId = ((char*)pObject) - ((char*)nullptr); @@ -62,7 +62,7 @@ IObjectBase* IBinSaver::LoadObject() { int typeId; DataChunk(&typeId, sizeof(typeId)); IObjectBase* pObj = pSaverClasses->CreateObject(typeId); - Y_ASSERT(pObj != nullptr); + Y_ASSERT(pObj != nullptr); if (pObj == nullptr) { fprintf(stderr, "IBinSaver: trying to load unregistered object\n"); abort(); diff --git a/library/cpp/binsaver/bin_saver.h b/library/cpp/binsaver/bin_saver.h index f37612c4fc..412424889f 100644 --- a/library/cpp/binsaver/bin_saver.h +++ b/library/cpp/binsaver/bin_saver.h @@ -6,13 +6,13 @@ #include <library/cpp/containers/2d_array/2d_array.h> #include <util/generic/hash_set.h> -#include <util/generic/buffer.h> +#include <util/generic/buffer.h> #include <util/generic/list.h> #include <util/generic/maybe.h> #include <util/generic/bitmap.h> #include <util/generic/variant.h> #include <util/generic/ylimits.h> -#include <util/memory/blob.h> +#include <util/memory/blob.h> #include <util/digest/murmur.h> #include <array> @@ -267,7 +267,7 @@ private: // storing/loading pointers to objects void StoreObject(IObjectBase* pObject); - IObjectBase* LoadObject(); + IObjectBase* LoadObject(); bool bRead; TBufferedStream<> File; @@ -310,21 +310,21 @@ public: return 0; } int Add(const chunk_id, TBlob* blob) { - if (bRead) { - ui64 size = 0; - File.Read(&size, sizeof(size)); + if (bRead) { + ui64 size = 0; + File.Read(&size, sizeof(size)); TBuffer buffer; buffer.Advance(size); - if (size > 0) - File.Read(buffer.Data(), buffer.Size()); + if (size > 0) + File.Read(buffer.Data(), buffer.Size()); (*blob) = TBlob::FromBuffer(buffer); - } else { - const ui64 size = blob->Size(); - File.Write(&size, sizeof(size)); - File.Write(blob->Data(), blob->Size()); - } - return 0; - } + } else { + const ui64 size = blob->Size(); + File.Write(&size, sizeof(size)); + File.Write(blob->Data(), blob->Size()); + } + return 0; + } template <class T1, class TA> int Add(const chunk_id, TVector<T1, TA>* pVec) { if (HasNonTrivialSerializer<T1>(0u)) @@ -629,7 +629,7 @@ struct TRegisterSaveLoadType { int operator&(IBinSaver& f) override { \ f.AddMulti(__VA_ARGS__); \ return 0; \ - } + } #define SAVELOAD_OVERRIDE(base, ...) \ int operator&(IBinSaver& f) override { \ diff --git a/library/cpp/binsaver/blob_io.h b/library/cpp/binsaver/blob_io.h index e0b7956a88..abe518ef30 100644 --- a/library/cpp/binsaver/blob_io.h +++ b/library/cpp/binsaver/blob_io.h @@ -10,7 +10,7 @@ class TYaBlobStream: public IBinaryStream { i64 Pos; int WriteImpl(const void*, int) override { - Y_ASSERT(0); + Y_ASSERT(0); return 0; } int ReadImpl(void* userBuffer, int size) override { diff --git a/library/cpp/binsaver/buffered_io.cpp b/library/cpp/binsaver/buffered_io.cpp index 073ba0c46e..dd88b04bc5 100644 --- a/library/cpp/binsaver/buffered_io.cpp +++ b/library/cpp/binsaver/buffered_io.cpp @@ -1,31 +1,31 @@ #include "buffered_io.h" i64 IBinaryStream::LongWrite(const void* userBuffer, i64 size) { - Y_VERIFY(size >= 0, "IBinaryStream::Write() called with a negative buffer size."); + Y_VERIFY(size >= 0, "IBinaryStream::Write() called with a negative buffer size."); i64 leftToWrite = size; while (leftToWrite != 0) { int writeSz = static_cast<int>(Min<i64>(leftToWrite, std::numeric_limits<int>::max())); int written = WriteImpl(userBuffer, writeSz); - Y_ASSERT(written <= writeSz); + Y_ASSERT(written <= writeSz); leftToWrite -= written; // Assumption: if WriteImpl(buf, writeSz) returns < writeSz, the stream is // full and there's no sense in continuing. if (written < writeSz) break; } - Y_ASSERT(size >= leftToWrite); + Y_ASSERT(size >= leftToWrite); return size - leftToWrite; } i64 IBinaryStream::LongRead(void* userBuffer, i64 size) { - Y_VERIFY(size >= 0, "IBinaryStream::Read() called with a negative buffer size."); + Y_VERIFY(size >= 0, "IBinaryStream::Read() called with a negative buffer size."); i64 leftToRead = size; while (leftToRead != 0) { int readSz = static_cast<int>(Min<i64>(leftToRead, std::numeric_limits<int>::max())); int read = ReadImpl(userBuffer, readSz); - Y_ASSERT(read <= readSz); + Y_ASSERT(read <= readSz); leftToRead -= read; // Assumption: if ReadImpl(buf, readSz) returns < readSz, the stream is // full and there's no sense in continuing. @@ -34,6 +34,6 @@ i64 IBinaryStream::LongRead(void* userBuffer, i64 size) { break; } } - Y_ASSERT(size >= leftToRead); + Y_ASSERT(size >= leftToRead); return size - leftToRead; } diff --git a/library/cpp/binsaver/buffered_io.h b/library/cpp/binsaver/buffered_io.h index bc5456923d..75465c9c5c 100644 --- a/library/cpp/binsaver/buffered_io.h +++ b/library/cpp/binsaver/buffered_io.h @@ -97,7 +97,7 @@ public: Flush(); } void Flush() { - Y_ASSERT(!bIsReading); + Y_ASSERT(!bIsReading); if (bIsReading) return; Stream.Write(Buf, Pos); @@ -108,7 +108,7 @@ public: return bIsEof; } inline void Read(void* userBuffer, i64 size) { - Y_ASSERT(bIsReading); + Y_ASSERT(bIsReading); if (!bIsEof && size + Pos <= BufSize) { memcpy(userBuffer, Buf + Pos, size); Pos += size; @@ -117,7 +117,7 @@ public: ReadComplex(userBuffer, size); } inline void Write(const void* userBuffer, i64 size) { - Y_ASSERT(!bIsReading); + Y_ASSERT(!bIsReading); if (Pos + size < N_SIZE) { memcpy(Buf + Pos, userBuffer, size); Pos += size; diff --git a/library/cpp/binsaver/class_factory.h b/library/cpp/binsaver/class_factory.h index 5069b5f161..e83512331b 100644 --- a/library/cpp/binsaver/class_factory.h +++ b/library/cpp/binsaver/class_factory.h @@ -77,8 +77,8 @@ public: template <class T> void TClassFactory<T>::RegisterTypeBase(int nTypeID, newFunc func, VFT vft) { if (typeInfo.find(nTypeID) != typeInfo.end()) { - TObj<IObjectBase> o1 = typeInfo[nTypeID](); - TObj<IObjectBase> o2 = func(); + TObj<IObjectBase> o1 = typeInfo[nTypeID](); + TObj<IObjectBase> o2 = func(); // stupid clang warning auto& o1v = *o1; diff --git a/library/cpp/binsaver/ut/binsaver_ut.cpp b/library/cpp/binsaver/ut/binsaver_ut.cpp index f8275d63d0..37eba5406f 100644 --- a/library/cpp/binsaver/ut/binsaver_ut.cpp +++ b/library/cpp/binsaver/ut/binsaver_ut.cpp @@ -67,8 +67,8 @@ static bool operator==(const TBlob& l, const TBlob& r) { return TStringBuf(l.AsCharPtr(), l.Size()) == TStringBuf(r.AsCharPtr(), r.Size()); } -Y_UNIT_TEST_SUITE(BinSaver){ - Y_UNIT_TEST(HasTrivialSerializer){ +Y_UNIT_TEST_SUITE(BinSaver){ + Y_UNIT_TEST(HasTrivialSerializer){ UNIT_ASSERT(!IBinSaver::HasNonTrivialSerializer<TBinarySerializable>(0u)); UNIT_ASSERT(!IBinSaver::HasNonTrivialSerializer<TNonBinarySerializable>(0u)); UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomSerializer>(0u)); @@ -79,33 +79,33 @@ UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TVector<TCustomSerializer>>(0u)); } -Y_UNIT_TEST(TestStroka) { +Y_UNIT_TEST(TestStroka) { TestBinSaverSerialization(TString("QWERTY")); } -Y_UNIT_TEST(TestMoveOnlyType) { +Y_UNIT_TEST(TestMoveOnlyType) { TestBinSaverSerializationToBuffer(TMoveOnlyType()); } -Y_UNIT_TEST(TestVectorStrok) { +Y_UNIT_TEST(TestVectorStrok) { TestBinSaverSerialization(TVector<TString>{"A", "B", "C"}); } -Y_UNIT_TEST(TestCArray) { +Y_UNIT_TEST(TestCArray) { TestBinSaverSerialization(TTypeWithArray()); } -Y_UNIT_TEST(TestSets) { +Y_UNIT_TEST(TestSets) { TestBinSaverSerialization(THashSet<TString>{"A", "B", "C"}); TestBinSaverSerialization(TSet<TString>{"A", "B", "C"}); } -Y_UNIT_TEST(TestMaps) { +Y_UNIT_TEST(TestMaps) { TestBinSaverSerialization(THashMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}}); TestBinSaverSerialization(TMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}}); } -Y_UNIT_TEST(TestBlob) { +Y_UNIT_TEST(TestBlob) { TestBinSaverSerialization(TBlob::FromStringSingleThreaded("qwerty")); } @@ -125,7 +125,7 @@ Y_UNIT_TEST(TestVariant) { } } -Y_UNIT_TEST(TestPod) { +Y_UNIT_TEST(TestPod) { struct TPod { ui32 A = 5; ui64 B = 7; @@ -141,7 +141,7 @@ Y_UNIT_TEST(TestPod) { TestBinSaverSerialization(TVector<TPod>{custom}); } -Y_UNIT_TEST(TestSubPod) { +Y_UNIT_TEST(TestSubPod) { struct TPod { struct TSub { ui32 X = 10; @@ -166,7 +166,7 @@ Y_UNIT_TEST(TestSubPod) { TestBinSaverSerialization(TVector<TPod>{custom}); } -Y_UNIT_TEST(TestMemberAndOpIsMain) { +Y_UNIT_TEST(TestMemberAndOpIsMain) { struct TBase { TString S; virtual int operator&(IBinSaver& f) { diff --git a/library/cpp/binsaver/util_stream_io.h b/library/cpp/binsaver/util_stream_io.h index a00670e033..d65d630b93 100644 --- a/library/cpp/binsaver/util_stream_io.h +++ b/library/cpp/binsaver/util_stream_io.h @@ -10,7 +10,7 @@ class TYaStreamInput: public IBinaryStream { IInputStream& Stream; int WriteImpl(const void*, int) override { - Y_ASSERT(0); + Y_ASSERT(0); return 0; } int ReadImpl(void* userBuffer, int size) override { @@ -53,7 +53,7 @@ class TYaStreamOutput: public IBinaryStream { return size; } int ReadImpl(void*, int) override { - Y_ASSERT(0); + Y_ASSERT(0); return 0; } bool IsValid() const override { diff --git a/library/cpp/bit_io/bitinput_impl.h b/library/cpp/bit_io/bitinput_impl.h index 05a57ecd71..b13fbef101 100644 --- a/library/cpp/bit_io/bitinput_impl.h +++ b/library/cpp/bit_io/bitinput_impl.h @@ -1,8 +1,8 @@ #pragma once -#include <util/generic/bitops.h> +#include <util/generic/bitops.h> #include <util/system/unaligned_mem.h> - + namespace NBitIO { class TBitInputImpl { i64 RealStart; @@ -51,7 +51,7 @@ namespace NBitIO { BOffset += bits; if (BOffset < FakeStart) return true; - if (Y_UNLIKELY(BOffset > Length)) { + if (Y_UNLIKELY(BOffset > Length)) { result = 0; BOffset -= bits; return false; @@ -84,7 +84,7 @@ namespace NBitIO { template <typename T> Y_FORCE_INLINE static void CopyToResult(T& result, ui64 r64, ui64 bits, ui64 skipbits) { - result = (result & InverseMaskLowerBits(bits, skipbits)) | (r64 << skipbits); + result = (result & InverseMaskLowerBits(bits, skipbits)) | (r64 << skipbits); } public: diff --git a/library/cpp/bit_io/bitoutput.h b/library/cpp/bit_io/bitoutput.h index 0b4766520e..2b886c1f02 100644 --- a/library/cpp/bit_io/bitoutput.h +++ b/library/cpp/bit_io/bitoutput.h @@ -4,7 +4,7 @@ #include <util/stream/output.h> #include <util/system/yassert.h> -#include <util/generic/bitops.h> +#include <util/generic/bitops.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> @@ -148,7 +148,7 @@ namespace NBitIO { public: void WriteData(const char* begin, const char* end) { size_t sz = end - begin; - Y_VERIFY(sz <= Left, " "); + Y_VERIFY(sz <= Left, " "); memcpy(Data, begin, sz); Data += sz; Left -= sz; @@ -172,21 +172,21 @@ namespace NBitIO { using TBitOutputYVector = TBitOutputVector<TVector<char>>; class TBitOutputStreamImpl { - IOutputStream* Out; + IOutputStream* Out; public: void WriteData(const char* begin, const char* end) { Out->Write(begin, end - begin); } - TBitOutputStreamImpl(IOutputStream* out) + TBitOutputStreamImpl(IOutputStream* out) : Out(out) { } }; struct TBitOutputStream: public TBitOutputStreamImpl, public TBitOutputBase<TBitOutputStreamImpl> { - inline TBitOutputStream(IOutputStream* out) + inline TBitOutputStream(IOutputStream* out) : TBitOutputStreamImpl(out) , TBitOutputBase<TBitOutputStreamImpl>(this) { diff --git a/library/cpp/blockcodecs/codecs_ut.cpp b/library/cpp/blockcodecs/codecs_ut.cpp index d94a151075..bfe5a23690 100644 --- a/library/cpp/blockcodecs/codecs_ut.cpp +++ b/library/cpp/blockcodecs/codecs_ut.cpp @@ -7,7 +7,7 @@ #include <util/string/join.h> #include <util/digest/multi.h> -Y_UNIT_TEST_SUITE(TBlockCodecsTest) { +Y_UNIT_TEST_SUITE(TBlockCodecsTest) { using namespace NBlockCodecs; TBuffer Buffer(TStringBuf b) { @@ -67,79 +67,79 @@ Y_UNIT_TEST_SUITE(TBlockCodecsTest) { } } - Y_UNIT_TEST(TestAllAtOnce0) { + Y_UNIT_TEST(TestAllAtOnce0) { TestAllAtOnce(20, 0); } - Y_UNIT_TEST(TestAllAtOnce1) { + Y_UNIT_TEST(TestAllAtOnce1) { TestAllAtOnce(20, 1); } - Y_UNIT_TEST(TestAllAtOnce2) { + Y_UNIT_TEST(TestAllAtOnce2) { TestAllAtOnce(20, 2); } - Y_UNIT_TEST(TestAllAtOnce3) { + Y_UNIT_TEST(TestAllAtOnce3) { TestAllAtOnce(20, 3); } - Y_UNIT_TEST(TestAllAtOnce4) { + Y_UNIT_TEST(TestAllAtOnce4) { TestAllAtOnce(20, 4); } - Y_UNIT_TEST(TestAllAtOnce5) { + Y_UNIT_TEST(TestAllAtOnce5) { TestAllAtOnce(20, 5); } - Y_UNIT_TEST(TestAllAtOnce6) { + Y_UNIT_TEST(TestAllAtOnce6) { TestAllAtOnce(20, 6); } - Y_UNIT_TEST(TestAllAtOnce7) { + Y_UNIT_TEST(TestAllAtOnce7) { TestAllAtOnce(20, 7); } - Y_UNIT_TEST(TestAllAtOnce8) { + Y_UNIT_TEST(TestAllAtOnce8) { TestAllAtOnce(20, 8); } - Y_UNIT_TEST(TestAllAtOnce9) { + Y_UNIT_TEST(TestAllAtOnce9) { TestAllAtOnce(20, 9); } - Y_UNIT_TEST(TestAllAtOnce10) { + Y_UNIT_TEST(TestAllAtOnce10) { TestAllAtOnce(20, 10); } - Y_UNIT_TEST(TestAllAtOnce12) { + Y_UNIT_TEST(TestAllAtOnce12) { TestAllAtOnce(20, 12); } - Y_UNIT_TEST(TestAllAtOnce13) { + Y_UNIT_TEST(TestAllAtOnce13) { TestAllAtOnce(20, 13); } - Y_UNIT_TEST(TestAllAtOnce14) { + Y_UNIT_TEST(TestAllAtOnce14) { TestAllAtOnce(20, 14); } - Y_UNIT_TEST(TestAllAtOnce15) { + Y_UNIT_TEST(TestAllAtOnce15) { TestAllAtOnce(20, 15); } - Y_UNIT_TEST(TestAllAtOnce16) { + Y_UNIT_TEST(TestAllAtOnce16) { TestAllAtOnce(20, 16); } - Y_UNIT_TEST(TestAllAtOnce17) { + Y_UNIT_TEST(TestAllAtOnce17) { TestAllAtOnce(20, 17); } - Y_UNIT_TEST(TestAllAtOnce18) { + Y_UNIT_TEST(TestAllAtOnce18) { TestAllAtOnce(20, 18); } - Y_UNIT_TEST(TestAllAtOnce19) { + Y_UNIT_TEST(TestAllAtOnce19) { TestAllAtOnce(20, 19); } @@ -190,83 +190,83 @@ Y_UNIT_TEST_SUITE(TBlockCodecsTest) { } } - Y_UNIT_TEST(TestStreams0) { + Y_UNIT_TEST(TestStreams0) { TestStreams(20, 0); } - Y_UNIT_TEST(TestStreams1) { + Y_UNIT_TEST(TestStreams1) { TestStreams(20, 1); } - Y_UNIT_TEST(TestStreams2) { + Y_UNIT_TEST(TestStreams2) { TestStreams(20, 2); } - Y_UNIT_TEST(TestStreams3) { + Y_UNIT_TEST(TestStreams3) { TestStreams(20, 3); } - Y_UNIT_TEST(TestStreams4) { + Y_UNIT_TEST(TestStreams4) { TestStreams(20, 4); } - Y_UNIT_TEST(TestStreams5) { + Y_UNIT_TEST(TestStreams5) { TestStreams(20, 5); } - Y_UNIT_TEST(TestStreams6) { + Y_UNIT_TEST(TestStreams6) { TestStreams(20, 6); } - Y_UNIT_TEST(TestStreams7) { + Y_UNIT_TEST(TestStreams7) { TestStreams(20, 7); } - Y_UNIT_TEST(TestStreams8) { + Y_UNIT_TEST(TestStreams8) { TestStreams(20, 8); } - Y_UNIT_TEST(TestStreams9) { + Y_UNIT_TEST(TestStreams9) { TestStreams(20, 9); } - Y_UNIT_TEST(TestStreams10) { + Y_UNIT_TEST(TestStreams10) { TestStreams(20, 10); } - Y_UNIT_TEST(TestStreams11) { + Y_UNIT_TEST(TestStreams11) { TestStreams(20, 11); } - Y_UNIT_TEST(TestStreams12) { + Y_UNIT_TEST(TestStreams12) { TestStreams(20, 12); } - Y_UNIT_TEST(TestStreams13) { + Y_UNIT_TEST(TestStreams13) { TestStreams(20, 13); } - Y_UNIT_TEST(TestStreams14) { + Y_UNIT_TEST(TestStreams14) { TestStreams(20, 14); } - Y_UNIT_TEST(TestStreams15) { + Y_UNIT_TEST(TestStreams15) { TestStreams(20, 15); } - Y_UNIT_TEST(TestStreams16) { + Y_UNIT_TEST(TestStreams16) { TestStreams(20, 16); } - Y_UNIT_TEST(TestStreams17) { + Y_UNIT_TEST(TestStreams17) { TestStreams(20, 17); } - Y_UNIT_TEST(TestStreams18) { + Y_UNIT_TEST(TestStreams18) { TestStreams(20, 18); } - Y_UNIT_TEST(TestStreams19) { + Y_UNIT_TEST(TestStreams19) { TestStreams(20, 19); } diff --git a/library/cpp/blockcodecs/core/codecs.cpp b/library/cpp/blockcodecs/core/codecs.cpp index 94e2d324ed..21506e812b 100644 --- a/library/cpp/blockcodecs/core/codecs.cpp +++ b/library/cpp/blockcodecs/core/codecs.cpp @@ -38,8 +38,8 @@ namespace { } inline void ListCodecs(TCodecList& lst) const { - for (const auto& it : Registry) { - lst.push_back(it.first); + for (const auto& it : Registry) { + lst.push_back(it.first); } Sort(lst.begin(), lst.end()); diff --git a/library/cpp/blockcodecs/core/stream.cpp b/library/cpp/blockcodecs/core/stream.cpp index fe0347a261..4f7db3c32b 100644 --- a/library/cpp/blockcodecs/core/stream.cpp +++ b/library/cpp/blockcodecs/core/stream.cpp @@ -64,7 +64,7 @@ namespace { } } -TCodedOutput::TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen) +TCodedOutput::TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen) : C_(c) , D_(bufLen) , S_(out) @@ -95,7 +95,7 @@ void TCodedOutput::DoWrite(const void* buf, size_t len) { D_.Append(in, avail); - Y_ASSERT(!D_.Avail()); + Y_ASSERT(!D_.Avail()); in += avail; len -= avail; @@ -146,7 +146,7 @@ void TCodedOutput::DoFinish() { } } -TDecodedInput::TDecodedInput(IInputStream* in) +TDecodedInput::TDecodedInput(IInputStream* in) : S_(in) , C_(nullptr) { diff --git a/library/cpp/blockcodecs/core/stream.h b/library/cpp/blockcodecs/core/stream.h index a66c2e0c31..fd44ef88f2 100644 --- a/library/cpp/blockcodecs/core/stream.h +++ b/library/cpp/blockcodecs/core/stream.h @@ -9,9 +9,9 @@ namespace NBlockCodecs { struct ICodec; - class TCodedOutput: public IOutputStream { + class TCodedOutput: public IOutputStream { public: - TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen); + TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen); ~TCodedOutput() override; private: @@ -25,12 +25,12 @@ namespace NBlockCodecs { const ICodec* C_; TBuffer D_; TBuffer O_; - IOutputStream* S_; + IOutputStream* S_; }; - class TDecodedInput: public IWalkInput { + class TDecodedInput: public IWalkInput { public: - TDecodedInput(IInputStream* in); + TDecodedInput(IInputStream* in); TDecodedInput(IInputStream* in, const ICodec* codec); ~TDecodedInput() override; @@ -40,7 +40,7 @@ namespace NBlockCodecs { private: TBuffer D_; - IInputStream* S_; + IInputStream* S_; const ICodec* C_; }; } diff --git a/library/cpp/blockcodecs/fuzz/main.cpp b/library/cpp/blockcodecs/fuzz/main.cpp index cddf79f7f6..763c6c5a10 100644 --- a/library/cpp/blockcodecs/fuzz/main.cpp +++ b/library/cpp/blockcodecs/fuzz/main.cpp @@ -1,84 +1,84 @@ -#include <contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.h> +#include <contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.h> #include <google/protobuf/stubs/logging.h> - + #include <library/cpp/blockcodecs/codecs.h> #include <library/cpp/blockcodecs/fuzz/proto/case.pb.h> #include <library/cpp/blockcodecs/stream.h> -#include <util/stream/input.h> -#include <util/stream/length.h> +#include <util/stream/input.h> +#include <util/stream/length.h> #include <util/stream/mem.h> -#include <util/stream/null.h> -#include <util/stream/str.h> +#include <util/stream/null.h> +#include <util/stream/str.h> + +using NBlockCodecs::NFuzz::TPackUnpackCase; +using NBlockCodecs::TCodedOutput; +using NBlockCodecs::TDecodedInput; -using NBlockCodecs::NFuzz::TPackUnpackCase; -using NBlockCodecs::TCodedOutput; -using NBlockCodecs::TDecodedInput; +static void ValidateBufferSize(const ui32 size) { + Y_ENSURE(size > 0 && size <= 16ULL * 1024); +} -static void ValidateBufferSize(const ui32 size) { - Y_ENSURE(size > 0 && size <= 16ULL * 1024); -} - -static void DoOnlyDecode(const TPackUnpackCase& case_) { - if (!case_.GetPacked()) { - return; +static void DoOnlyDecode(const TPackUnpackCase& case_) { + if (!case_.GetPacked()) { + return; } - TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); - TDecodedInput di(&mi); - TNullOutput no; - TCountingOutput cno(&no); - TransferData(&di, &cno); + TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); + TDecodedInput di(&mi); + TNullOutput no; + TCountingOutput cno(&no); + TransferData(&di, &cno); +} + +static void DoDecodeEncode(const TPackUnpackCase& case_) { + auto* const codec = NBlockCodecs::Codec(case_.GetCodecName()); + Y_ENSURE(codec); + + TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); + TDecodedInput di(&mi, codec); + TStringStream decoded; + TransferData(&di, &decoded); + TNullOutput no; + TCountingOutput cno(&no); + TCodedOutput co(&cno, codec, case_.GetBufferLength()); + TransferData(&decoded, &co); + co.Flush(); + + Y_VERIFY((case_.GetData().size() > 0) == (cno.Counter() > 0)); + Y_VERIFY((case_.GetData().size() > 0) == (decoded.Str().size() > 0)); +} + +static void DoEncodeDecode(const TPackUnpackCase& case_) { + auto* const codec = NBlockCodecs::Codec(case_.GetCodecName()); + Y_ENSURE(codec); + + TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); + TStringStream encoded; + TCodedOutput co(&encoded, codec, case_.GetBufferLength()); + TransferData(&mi, &co); + co.Flush(); + TStringStream decoded; + TDecodedInput di(&encoded, codec); + TransferData(&di, &decoded); + + Y_VERIFY((case_.GetData().size() > 0) == (encoded.Str().size() > 0)); + Y_VERIFY(case_.GetData() == decoded.Str()); +} + +DEFINE_BINARY_PROTO_FUZZER(const TPackUnpackCase& case_) { + try { + if (!case_.GetCodecName()) { + DoOnlyDecode(case_); + return; + } + + ValidateBufferSize(case_.GetBufferLength()); + if (case_.GetPacked()) { + DoDecodeEncode(case_); + } else { + DoEncodeDecode(case_); + } + } catch (const std::exception&) { + } } - -static void DoDecodeEncode(const TPackUnpackCase& case_) { - auto* const codec = NBlockCodecs::Codec(case_.GetCodecName()); - Y_ENSURE(codec); - - TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); - TDecodedInput di(&mi, codec); - TStringStream decoded; - TransferData(&di, &decoded); - TNullOutput no; - TCountingOutput cno(&no); - TCodedOutput co(&cno, codec, case_.GetBufferLength()); - TransferData(&decoded, &co); - co.Flush(); - - Y_VERIFY((case_.GetData().size() > 0) == (cno.Counter() > 0)); - Y_VERIFY((case_.GetData().size() > 0) == (decoded.Str().size() > 0)); -} - -static void DoEncodeDecode(const TPackUnpackCase& case_) { - auto* const codec = NBlockCodecs::Codec(case_.GetCodecName()); - Y_ENSURE(codec); - - TMemoryInput mi(case_.GetData().data(), case_.GetData().size()); - TStringStream encoded; - TCodedOutput co(&encoded, codec, case_.GetBufferLength()); - TransferData(&mi, &co); - co.Flush(); - TStringStream decoded; - TDecodedInput di(&encoded, codec); - TransferData(&di, &decoded); - - Y_VERIFY((case_.GetData().size() > 0) == (encoded.Str().size() > 0)); - Y_VERIFY(case_.GetData() == decoded.Str()); -} - -DEFINE_BINARY_PROTO_FUZZER(const TPackUnpackCase& case_) { - try { - if (!case_.GetCodecName()) { - DoOnlyDecode(case_); - return; - } - - ValidateBufferSize(case_.GetBufferLength()); - if (case_.GetPacked()) { - DoDecodeEncode(case_); - } else { - DoEncodeDecode(case_); - } - } catch (const std::exception&) { - } -} diff --git a/library/cpp/blockcodecs/fuzz/proto/case.proto b/library/cpp/blockcodecs/fuzz/proto/case.proto index 622ed0ce47..85518b0da9 100644 --- a/library/cpp/blockcodecs/fuzz/proto/case.proto +++ b/library/cpp/blockcodecs/fuzz/proto/case.proto @@ -1,10 +1,10 @@ -syntax="proto3"; - -package NBlockCodecs.NFuzz; - -message TPackUnpackCase { - bool Packed = 1; - uint32 BufferLength = 2; - string CodecName = 3; - bytes Data = 4; -} +syntax="proto3"; + +package NBlockCodecs.NFuzz; + +message TPackUnpackCase { + bool Packed = 1; + uint32 BufferLength = 2; + string CodecName = 3; + bytes Data = 4; +} diff --git a/library/cpp/blockcodecs/fuzz/proto/ya.make b/library/cpp/blockcodecs/fuzz/proto/ya.make index dbd32e0f1c..da840bc8c9 100644 --- a/library/cpp/blockcodecs/fuzz/proto/ya.make +++ b/library/cpp/blockcodecs/fuzz/proto/ya.make @@ -1,14 +1,14 @@ -OWNER( - yazevnul - g:util -) - -PROTO_LIBRARY() - -SRCS( - case.proto -) - +OWNER( + yazevnul + g:util +) + +PROTO_LIBRARY() + +SRCS( + case.proto +) + EXCLUDE_TAGS(GO_PROTO) -END() +END() diff --git a/library/cpp/blockcodecs/fuzz/ya.make b/library/cpp/blockcodecs/fuzz/ya.make index dee86d56a2..bc8becc9e1 100644 --- a/library/cpp/blockcodecs/fuzz/ya.make +++ b/library/cpp/blockcodecs/fuzz/ya.make @@ -3,21 +3,21 @@ OWNER( g:util ) -IF (NOT MSVC) - FUZZ() +IF (NOT MSVC) + FUZZ() - SIZE(MEDIUM) + SIZE(MEDIUM) - SRCS( - main.cpp - ) - - PEERDIR( - contrib/libs/protobuf - contrib/libs/protobuf-mutator + SRCS( + main.cpp + ) + + PEERDIR( + contrib/libs/protobuf + contrib/libs/protobuf-mutator library/cpp/blockcodecs library/cpp/blockcodecs/fuzz/proto - ) - - END() -ENDIF() + ) + + END() +ENDIF() diff --git a/library/cpp/cache/cache.h b/library/cpp/cache/cache.h index 93bd6614db..6dc997076d 100644 --- a/library/cpp/cache/cache.h +++ b/library/cpp/cache/cache.h @@ -82,7 +82,7 @@ public: TItem* GetOldest() { typename TListType::TIterator it = List.Begin(); - Y_ASSERT(it != List.End()); + Y_ASSERT(it != List.End()); return &*it; } @@ -190,7 +190,7 @@ public: TItem* GetLeastFrequentlyUsed() { typename TListType::TIterator it = List.Begin(); - Y_ASSERT(it != List.End()); + Y_ASSERT(it != List.End()); return &*it; } @@ -310,7 +310,7 @@ public: TItem* GetLightest() { FixHeap(); - Y_ASSERT(!Heap.empty()); + Y_ASSERT(!Heap.empty()); return Heap.front(); } @@ -319,7 +319,7 @@ public: // Erased items are stored in Removed set // and will be deleted on-access (using FixHeap method) void Erase(TItem* item) { - Y_ASSERT(Size > 0); + Y_ASSERT(Size > 0); --Size; Removed.insert(item); @@ -460,14 +460,14 @@ public: // note: it shouldn't touch 'value' if it returns false. bool PickOut(const TKey& key, TValue* value) { - Y_ASSERT(value); + Y_ASSERT(value); TIndexIterator it = Index.find(TItem(key)); if (it == Index.end()) return false; *value = it->Value; List.Erase(const_cast<TItem*>(&*it)); Index.erase(it); - Y_ASSERT(Index.size() == List.GetSize()); + Y_ASSERT(Index.size() == List.GetSize()); return true; } @@ -492,7 +492,7 @@ public: } } - Y_ASSERT(Index.size() == List.GetSize()); + Y_ASSERT(Index.size() == List.GetSize()); return !insertedWasRemoved; } @@ -505,7 +505,7 @@ public: } Insert(key, value); - Y_ASSERT(Index.size() == List.GetSize()); + Y_ASSERT(Index.size() == List.GetSize()); } void Erase(TIterator it) { @@ -514,7 +514,7 @@ public: TDeleter::Destroy(item->Value); Index.erase(it.Iter); - Y_ASSERT(Index.size() == List.GetSize()); + Y_ASSERT(Index.size() == List.GetSize()); } bool Empty() const { @@ -527,7 +527,7 @@ public: List.Erase(item); TDeleter::Destroy(item->Value); } - Y_ASSERT(List.GetSize() == 0); + Y_ASSERT(List.GetSize() == 0); Index.clear(); } @@ -563,7 +563,7 @@ protected: void EraseFromIndex(TItem* item) { TDeleter::Destroy(item->Value); TIterator it = FindByItem(item); - Y_ASSERT(it != End()); + Y_ASSERT(it != End()); Index.erase(it.Iter); } }; diff --git a/library/cpp/cache/ut/cache_ut.cpp b/library/cpp/cache/ut/cache_ut.cpp index e92e07b12e..329872cfde 100644 --- a/library/cpp/cache/ut/cache_ut.cpp +++ b/library/cpp/cache/ut/cache_ut.cpp @@ -8,8 +8,8 @@ struct TStrokaWeighter { } }; -Y_UNIT_TEST_SUITE(TCacheTest) { - Y_UNIT_TEST(LRUListTest) { +Y_UNIT_TEST_SUITE(TCacheTest) { + Y_UNIT_TEST(LRUListTest) { typedef TLRUList<int, TString> TListType; TListType list(2); @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT_EQUAL(list.GetOldest()->Key, 4); } - Y_UNIT_TEST(LFUListTest) { + Y_UNIT_TEST(LFUListTest) { typedef TLFUList<int, TString> TListType; TListType list(2); @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT_EQUAL(list.GetLeastFrequentlyUsed()->Key, 1); } - Y_UNIT_TEST(LWListTest) { + Y_UNIT_TEST(LWListTest) { typedef TLWList<int, TString, size_t, TStrokaWeighter> TListType; TListType list(2); @@ -114,7 +114,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT_EQUAL(list.GetSize(), 1); } - Y_UNIT_TEST(SimpleTest) { + Y_UNIT_TEST(SimpleTest) { typedef TLRUCache<int, TString> TCache; TCache s(2); // size 2 s.Insert(1, "abcd"); @@ -311,7 +311,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT(s.Find(6) != s.End()); } - Y_UNIT_TEST(MultiCacheTest) { + Y_UNIT_TEST(MultiCacheTest) { typedef TLRUCache<int, TString> TCache; TCache s(3, true); UNIT_ASSERT(s.Insert(1, "abcd")); @@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { }; int TMyDelete::count = 0; - Y_UNIT_TEST(DeleterTest) { + Y_UNIT_TEST(DeleterTest) { typedef TLRUCache<int, TString, TMyDelete> TCache; TCache s(2); s.Insert(1, "123"); @@ -346,7 +346,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { UNIT_ASSERT(TMyDelete::count == 2); } - Y_UNIT_TEST(PromoteOnFind) { + Y_UNIT_TEST(PromoteOnFind) { typedef TLRUCache<int, TString> TCache; TCache s(2); s.Insert(1, "123"); @@ -357,7 +357,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { } } -Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { +Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { typedef TThreadSafeCache<ui32, TString, ui32> TCache; const char* VALS[] = {"abcd", "defg", "hjkl"}; @@ -375,7 +375,7 @@ Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { mutable i32 Creations = 0; }; - Y_UNIT_TEST(SimpleTest) { + Y_UNIT_TEST(SimpleTest) { for (ui32 i = 0; i < Y_ARRAY_SIZE(VALS); ++i) { const TString data = *TCache::Get<TCallbacks>(i); UNIT_ASSERT(data == VALS[i]); diff --git a/library/cpp/cgiparam/cgiparam.cpp b/library/cpp/cgiparam/cgiparam.cpp index c9bf98a357..f3277b8e4b 100644 --- a/library/cpp/cgiparam/cgiparam.cpp +++ b/library/cpp/cgiparam/cgiparam.cpp @@ -17,7 +17,7 @@ const TString& TCgiParameters::Get(const TStringBuf name, size_t numOfValue) con return end() == it ? Default<TString>() : it->second; } -bool TCgiParameters::Erase(const TStringBuf name, size_t pos) { +bool TCgiParameters::Erase(const TStringBuf name, size_t pos) { const auto pair = equal_range(name); for (auto it = pair.first; it != pair.second; ++it, --pos) { @@ -46,7 +46,7 @@ bool TCgiParameters::Erase(const TStringBuf name, const TStringBuf val) { return found; } -size_t TCgiParameters::EraseAll(const TStringBuf name) { +size_t TCgiParameters::EraseAll(const TStringBuf name) { size_t num = 0; const auto pair = equal_range(name); @@ -89,36 +89,36 @@ static inline TString DoUnescape(const TStringBuf s) { return res; } -void TCgiParameters::InsertEscaped(const TStringBuf name, const TStringBuf value) { +void TCgiParameters::InsertEscaped(const TStringBuf name, const TStringBuf value) { InsertUnescaped(DoUnescape(name), DoUnescape(value)); } template <bool addAll, class F> -static inline void DoScan(const TStringBuf s, F& f) { +static inline void DoScan(const TStringBuf s, F& f) { ScanKeyValue<addAll, '&', '='>(s, f); } struct TAddEscaped { TCgiParameters* C; - inline void operator()(const TStringBuf key, const TStringBuf val) { + inline void operator()(const TStringBuf key, const TStringBuf val) { C->InsertEscaped(key, val); } }; -void TCgiParameters::Scan(const TStringBuf query, bool form) { +void TCgiParameters::Scan(const TStringBuf query, bool form) { Flush(); form ? ScanAdd(query) : ScanAddAll(query); } -void TCgiParameters::ScanAdd(const TStringBuf query) { +void TCgiParameters::ScanAdd(const TStringBuf query) { TAddEscaped f = {this}; DoScan<false>(query, f); } -void TCgiParameters::ScanAddUnescaped(const TStringBuf query) { - auto f = [this](const TStringBuf key, const TStringBuf val) { +void TCgiParameters::ScanAddUnescaped(const TStringBuf query) { + auto f = [this](const TStringBuf key, const TStringBuf val) { this->InsertUnescaped(key, val); }; @@ -133,7 +133,7 @@ void TCgiParameters::ScanAddAllUnescaped(const TStringBuf query) { DoScan<true>(query, f); } -void TCgiParameters::ScanAddAll(const TStringBuf query) { +void TCgiParameters::ScanAddAll(const TStringBuf query) { TAddEscaped f = {this}; DoScan<true>(query, f); @@ -172,7 +172,7 @@ char* TCgiParameters::Print(char* res) const { size_t TCgiParameters::PrintSize() const noexcept { size_t res = size(); // for '&' - for (const auto& i : *this) { + for (const auto& i : *this) { res += CgiEscapeBufLen(i.first.size() + i.second.size()); // extra zero will be used for '=' } diff --git a/library/cpp/cgiparam/cgiparam.h b/library/cpp/cgiparam/cgiparam.h index c14ddbf6f2..87d1ab0ad4 100644 --- a/library/cpp/cgiparam/cgiparam.h +++ b/library/cpp/cgiparam/cgiparam.h @@ -20,7 +20,7 @@ class TCgiParameters: public TMultiMap<TString, TString> { public: TCgiParameters() = default; - explicit TCgiParameters(const TStringBuf cgiParamStr) { + explicit TCgiParameters(const TStringBuf cgiParamStr) { Scan(cgiParamStr); } @@ -30,7 +30,7 @@ public: erase(begin(), end()); } - size_t EraseAll(const TStringBuf name); + size_t EraseAll(const TStringBuf name); size_t NumOfValues(const TStringBuf name) const noexcept { return count(name); @@ -40,11 +40,11 @@ public: return Print(); } - void Scan(const TStringBuf cgiParStr, bool form = true); - void ScanAdd(const TStringBuf cgiParStr); - void ScanAddUnescaped(const TStringBuf cgiParStr); + void Scan(const TStringBuf cgiParStr, bool form = true); + void ScanAdd(const TStringBuf cgiParStr); + void ScanAddUnescaped(const TStringBuf cgiParStr); void ScanAddAllUnescaped(const TStringBuf cgiParStr); - void ScanAddAll(const TStringBuf cgiParStr); + void ScanAddAll(const TStringBuf cgiParStr); /// Returns the string representation of all the stored parameters /** @@ -85,7 +85,7 @@ public: Y_PURE_FUNCTION const TString& Get(const TStringBuf name, size_t numOfValue = 0) const noexcept; - void InsertEscaped(const TStringBuf name, const TStringBuf value); + void InsertEscaped(const TStringBuf name, const TStringBuf value); #if !defined(__GLIBCXX__) template <typename TName, typename TValue> @@ -119,14 +119,14 @@ public: // if val is a [possibly empty] non-NULL string, append it as well void JoinUnescaped(const TStringBuf key, char sep, TStringBuf val = TStringBuf()); - bool Erase(const TStringBuf name, size_t numOfValue = 0); + bool Erase(const TStringBuf name, size_t numOfValue = 0); bool Erase(const TStringBuf name, const TStringBuf val); - inline const char* FormField(const TStringBuf name, size_t numOfValue = 0) const { + inline const char* FormField(const TStringBuf name, size_t numOfValue = 0) const { const_iterator it = Find(name, numOfValue); if (it == end()) { - return nullptr; + return nullptr; } return it->second.data(); diff --git a/library/cpp/cgiparam/cgiparam_ut.cpp b/library/cpp/cgiparam/cgiparam_ut.cpp index c9946462f9..a562342084 100644 --- a/library/cpp/cgiparam/cgiparam_ut.cpp +++ b/library/cpp/cgiparam/cgiparam_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TCgiParametersTest) { - Y_UNIT_TEST(TestScan1) { +Y_UNIT_TEST_SUITE(TCgiParametersTest) { + Y_UNIT_TEST(TestScan1) { TCgiParameters C; C.Scan("aaa=b%62b&ccc=ddd&ag0="); UNIT_ASSERT_EQUAL(C.Get("aaa") == "bbb", true); @@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(!C.Has("aaa")); } - Y_UNIT_TEST(TestScan2) { + Y_UNIT_TEST(TestScan2) { const TString parsee("=000&aaa=bbb&ag0=&ccc=ddd"); TCgiParameters c; c.Scan(parsee); @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), parsee); } - Y_UNIT_TEST(TestScan3) { + Y_UNIT_TEST(TestScan3) { const TString parsee("aaa=bbb&ag0=&ccc=ddd"); TCgiParameters c; c.Scan(parsee); @@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), parsee + "&d=xxx"); } - Y_UNIT_TEST(TestScanAddAll1) { + Y_UNIT_TEST(TestScanAddAll1) { TCgiParameters c; c.ScanAddAll("qw"); @@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(c.Get("qw").empty()); } - Y_UNIT_TEST(TestScanAddAll2) { + Y_UNIT_TEST(TestScanAddAll2) { TCgiParameters c; c.ScanAddAll("qw&"); @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(c.Get("qw").empty()); } - Y_UNIT_TEST(TestScanAddAll3) { + Y_UNIT_TEST(TestScanAddAll3) { TCgiParameters c; c.ScanAddAll("qw=1&x"); @@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(c.Get("x").empty()); } - Y_UNIT_TEST(TestScanAddAll4) { + Y_UNIT_TEST(TestScanAddAll4) { TCgiParameters c; c.ScanAddAll("ccc=1&aaa=1&ccc=3&bbb&ccc=2"); @@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Get("text"), "%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82%2C"); } - Y_UNIT_TEST(TestEraseAll) { + Y_UNIT_TEST(TestEraseAll) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.EraseAll("par"); @@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb="); } - Y_UNIT_TEST(TestErase) { + Y_UNIT_TEST(TestErase) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3&par=1"); @@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=3"); } - Y_UNIT_TEST(TestReplaceUnescaped1) { + Y_UNIT_TEST(TestReplaceUnescaped1) { TCgiParameters c; c.ScanAddAll("many_keys=1&aaa=1&many_keys=2&bbb&many_keys=3"); c.ReplaceUnescaped("many_keys", "new_value"); @@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&many_keys=new_value"); } - Y_UNIT_TEST(TestReplaceUnescaped2) { + Y_UNIT_TEST(TestReplaceUnescaped2) { TCgiParameters c; c.ScanAddAll("par=1&only_one=1&par=2&bbb&par=3"); c.ReplaceUnescaped("only_one", "new_value"); @@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "bbb=&only_one=new_value&par=1&par=2&par=3"); } - Y_UNIT_TEST(TestReplaceUnescaped3) { + Y_UNIT_TEST(TestReplaceUnescaped3) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.ReplaceUnescaped("no_such_key", "new_value"); @@ -154,7 +154,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&no_such_key=new_value&par=1&par=2&par=3"); } - Y_UNIT_TEST(TestReplaceUnescapedRange1) { + Y_UNIT_TEST(TestReplaceUnescapedRange1) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.ReplaceUnescaped("par", {"x", "y", "z"}); // 3 old values, 3 new values @@ -162,7 +162,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y&par=z"); } - Y_UNIT_TEST(TestReplaceUnescapedRange2) { + Y_UNIT_TEST(TestReplaceUnescapedRange2) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb"); c.ReplaceUnescaped("par", {"x", "y", "z"}); // 2 old values, 3 new values @@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y&par=z"); } - Y_UNIT_TEST(TestReplaceUnescapedRange3) { + Y_UNIT_TEST(TestReplaceUnescapedRange3) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.ReplaceUnescaped("par", {"x", "y"}); // 3 old values, 2 new values @@ -178,23 +178,23 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y"); } - Y_UNIT_TEST(TestNumOfValues) { + Y_UNIT_TEST(TestNumOfValues) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("par"), 3u); } - Y_UNIT_TEST(TestUnscape) { + Y_UNIT_TEST(TestUnscape) { TCgiParameters c("f=1&t=%84R%84%7C%84%80%84%7E&reqenc=SHIFT_JIS&p=0"); UNIT_ASSERT_VALUES_EQUAL(c.Get("t"), "\x84R\x84\x7C\x84\x80\x84\x7E"); } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { UNIT_ASSERT(TCgiParameters().Print().empty()); } - Y_UNIT_TEST(TestJoinUnescaped) { + Y_UNIT_TEST(TestJoinUnescaped) { TCgiParameters c; c.Scan("foo=1&foo=2"); @@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "foo=1;2;0"); } - Y_UNIT_TEST(TestContInit) { + Y_UNIT_TEST(TestContInit) { TCgiParameters c = {std::make_pair("a", "a1"), std::make_pair("b", "b1"), std::make_pair("a", "a2")}; UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("a"), 2u); diff --git a/library/cpp/charset/ci_string.cpp b/library/cpp/charset/ci_string.cpp index 24b53c8efc..6097e40131 100644 --- a/library/cpp/charset/ci_string.cpp +++ b/library/cpp/charset/ci_string.cpp @@ -36,6 +36,6 @@ size_t TCiString::hashVal(const char* s, size_t len, const CodePage& cp) { } template <> -void Out<TCiString>(IOutputStream& o, const TCiString& p) { +void Out<TCiString>(IOutputStream& o, const TCiString& p) { o.Write(p.data(), p.size()); } diff --git a/library/cpp/charset/codepage.cpp b/library/cpp/charset/codepage.cpp index 3e5fe09f85..0431bef31b 100644 --- a/library/cpp/charset/codepage.cpp +++ b/library/cpp/charset/codepage.cpp @@ -4,7 +4,7 @@ #include "codepage.h" #include <util/string/cast.h> -#include <util/string/subst.h> +#include <util/string/subst.h> #include <util/string/util.h> #include <util/system/hi_lo.h> #include <util/system/yassert.h> @@ -90,7 +90,7 @@ static const CodePage UNSUPPORTED_CODEPAGE = { "unsupported", }, {}, - nullptr, + nullptr, }; static const CodePage UNKNOWN_CODEPAGE = { @@ -99,15 +99,15 @@ static const CodePage UNKNOWN_CODEPAGE = { "unknown", }, {}, - nullptr, + nullptr, }; void NCodepagePrivate::TCodepagesMap::SetData(const CodePage* cp) { - Y_ASSERT(cp); + Y_ASSERT(cp); int code = static_cast<int>(cp->CPEnum) + DataShift; - Y_ASSERT(code >= 0 && code < DataSize); - Y_ASSERT(Data[code] == nullptr); + Y_ASSERT(code >= 0 && code < DataSize); + Y_ASSERT(Data[code] == nullptr); Data[code] = cp; } @@ -138,7 +138,7 @@ private: if (Data.find(name.c_str()) == Data.end()) { Data.insert(TData::value_type(Pool.Append(name.data(), name.size() + 1), code)); } else { - Y_ASSERT(Data.find(name.c_str())->second == code); + Y_ASSERT(Data.find(name.c_str())->second == code); } } @@ -172,7 +172,7 @@ public: AddName(ToString(static_cast<int>(i)), e); - for (size_t j = 0; (name = page->Names[j]) != nullptr && name[0]; ++j) { + for (size_t j = 0; (name = page->Names[j]) != nullptr && name[0]; ++j) { AddName(name, e); AddName(xPrefix + name, e); @@ -199,7 +199,7 @@ ECharset CharsetByName(TStringBuf name) { ECharset CharsetByNameOrDie(TStringBuf name) { ECharset result = CharsetByName(name); if (result == CODES_UNKNOWN) - ythrow yexception() << "CharsetByNameOrDie: unknown charset '" << name << "'"; + ythrow yexception() << "CharsetByNameOrDie: unknown charset '" << name << "'"; return result; } @@ -280,7 +280,7 @@ void DoDecodeUnknownPlane(TxChar* str, TxChar*& ee, const ECharset enc) { *s = Lo8(Lo16(*s)); } } else { - Y_ASSERT(!SingleByteCodepage(enc)); + Y_ASSERT(!SingleByteCodepage(enc)); TxChar* s = str; TxChar* d = str; @@ -295,10 +295,10 @@ void DoDecodeUnknownPlane(TxChar* str, TxChar*& ee, const ECharset enc) { } else { if (!buf.empty()) { if (RecodeToUnicode(enc, buf.data(), d, buf.size(), e - d, read, written) == RECODE_OK) { - Y_ASSERT(read == buf.size()); + Y_ASSERT(read == buf.size()); d += written; } else { // just copying broken symbols - Y_ASSERT(buf.size() <= static_cast<size_t>(e - d)); + Y_ASSERT(buf.size() <= static_cast<size_t>(e - d)); Copy(buf.data(), buf.size(), d); d += buf.size(); } diff --git a/library/cpp/charset/codepage.h b/library/cpp/charset/codepage.h index 9e73fbd615..30a02a4610 100644 --- a/library/cpp/charset/codepage.h +++ b/library/cpp/charset/codepage.h @@ -85,7 +85,7 @@ struct CodePage { static void Initialize(); inline bool SingleByteCodepage() const { - return DefaultChar != nullptr; + return DefaultChar != nullptr; } inline bool NativeCodepage() const { return SingleByteCodepage() || CPEnum == CODES_UTF8; @@ -103,7 +103,7 @@ namespace NCodepagePrivate { private: inline const CodePage* GetPrivate(ECharset e) const { - Y_ASSERT(e + DataShift >= 0 && e + DataShift < DataSize); + Y_ASSERT(e + DataShift >= 0 && e + DataShift < DataSize); return Data[e + DataShift]; } @@ -115,7 +115,7 @@ namespace NCodepagePrivate { inline const CodePage* Get(ECharset e) const { const CodePage* res = GetPrivate(e); if (!res->SingleByteCodepage()) { - ythrow yexception() << "CodePage (" << (int)e << ") structure can only be used for single byte encodings"; + ythrow yexception() << "CodePage (" << (int)e << ") structure can only be used for single byte encodings"; } return res; @@ -170,7 +170,7 @@ inline const char* NameByCharsetSafe(ECharset e) { if (CODES_UNKNOWN < e && e < CODES_MAX) return ::NCodepagePrivate::TCodepagesMap::Instance().NameByCharset(e); else - ythrow yexception() << "unknown encoding: " << (int)e; + ythrow yexception() << "unknown encoding: " << (int)e; } inline const char* NameByCodePage(const CodePage* CP) { @@ -180,7 +180,7 @@ inline const char* NameByCodePage(const CodePage* CP) { inline const CodePage* CodePageByName(const char* name) { ECharset code = CharsetByName(name); if (code == CODES_UNKNOWN) - return nullptr; + return nullptr; return CodePageByCharset(code); } @@ -204,7 +204,7 @@ struct Encoder { char code = Code(ch); if (code == 0 && ch != 0) code = DefaultChar[NUnicode::CharType(ch)]; - Y_ASSERT(code != 0 || ch == 0); + Y_ASSERT(code != 0 || ch == 0); return code; } diff --git a/library/cpp/charset/codepage_ut.cpp b/library/cpp/charset/codepage_ut.cpp index 250e11bbf1..c3ac3ac478 100644 --- a/library/cpp/charset/codepage_ut.cpp +++ b/library/cpp/charset/codepage_ut.cpp @@ -151,7 +151,7 @@ void TCodepageTest::TestUTF() { //"\xed\xbe\x80", //"\xed\xbf\xbf", }; - for (size_t i = 0; i < Y_ARRAY_SIZE(badStrings); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(badStrings); ++i) { wchar32 rune; const ui8* p = (const ui8*)badStrings[i]; size_t len; @@ -169,15 +169,15 @@ void TCodepageTest::TestBrokenMultibyte() { size_t nwritten = 0; size_t nread = 0; - RECODE_RESULT res = RecodeToUnicode(cp, sampletext, recodeResult, Y_ARRAY_SIZE(sampletext), Y_ARRAY_SIZE(recodeResult), nread, nwritten); + RECODE_RESULT res = RecodeToUnicode(cp, sampletext, recodeResult, Y_ARRAY_SIZE(sampletext), Y_ARRAY_SIZE(recodeResult), nread, nwritten); UNIT_ASSERT(res == RECODE_OK); UNIT_ASSERT(nread == 1); UNIT_ASSERT(nwritten == 0); const char bigSample[] = {'\xC3', '\x87', '\xC3', '\x8E', '\xC2', '\xB0', '\xC3', '\x85', '\xC3', '\x85', '\xC3', '\xB8'}; - res = RecodeToUnicode(cp, bigSample, recodeResult, Y_ARRAY_SIZE(bigSample), Y_ARRAY_SIZE(recodeResult), nread, nwritten); + res = RecodeToUnicode(cp, bigSample, recodeResult, Y_ARRAY_SIZE(bigSample), Y_ARRAY_SIZE(recodeResult), nread, nwritten); UNIT_ASSERT(res == RECODE_OK); - UNIT_ASSERT(nread == Y_ARRAY_SIZE(bigSample)); + UNIT_ASSERT(nread == Y_ARRAY_SIZE(bigSample)); } void TCodepageTest::TestUTFFromUnknownPlane() { @@ -191,7 +191,7 @@ void TCodepageTest::TestUTFFromUnknownPlane() { size_t readchars = 0; size_t writtenbytes = 0; - size_t samplelen = Y_ARRAY_SIZE(sampletext); + size_t samplelen = Y_ARRAY_SIZE(sampletext); RECODE_RESULT res = RecodeFromUnicode(CODES_UTF8, sampletext, bytebuffer, samplelen, BUFFER_SIZE, readchars, writtenbytes); @@ -291,11 +291,11 @@ static void TestSurrogates(const char* str, const wchar16* wide, size_t wideSize void TCodepageTest::TestSurrogatePairs() { const char* utf8NonBMP = "\xf4\x80\x89\x84\xf4\x80\x89\x87\xf4\x80\x88\xba"; wchar16 wNonBMPDummy[] = {0xDBC0, 0xDE44, 0xDBC0, 0xDE47, 0xDBC0, 0xDE3A}; - TestSurrogates(utf8NonBMP, wNonBMPDummy, Y_ARRAY_SIZE(wNonBMPDummy)); + TestSurrogates(utf8NonBMP, wNonBMPDummy, Y_ARRAY_SIZE(wNonBMPDummy)); const char* utf8NonBMP2 = "ab\xf4\x80\x89\x87n"; wchar16 wNonBMPDummy2[] = {'a', 'b', 0xDBC0, 0xDE47, 'n'}; - TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2)); + TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2)); } void TCodepageTest::TestEncodingHints() { @@ -329,7 +329,7 @@ void TCodepageTest::TestEncodingHints() { void TCodepageTest::TestToLower() { TTempBuf buf; char* data = buf.Data(); - const size_t n = Y_ARRAY_SIZE(yandexUpperCase); // including NTS + const size_t n = Y_ARRAY_SIZE(yandexUpperCase); // including NTS memcpy(data, yandexUpperCase, n); ToLower(data, n - 1); UNIT_ASSERT(strcmp(data, yandexLowerCase) == 0); @@ -338,7 +338,7 @@ void TCodepageTest::TestToLower() { void TCodepageTest::TestToUpper() { TTempBuf buf; char* data = buf.Data(); - const size_t n = Y_ARRAY_SIZE(yandexLowerCase); // including NTS + const size_t n = Y_ARRAY_SIZE(yandexLowerCase); // including NTS memcpy(data, yandexLowerCase, n); ToUpper(data, n - 1); UNIT_ASSERT(strcmp(data, yandexUpperCase) == 0); diff --git a/library/cpp/charset/cp_encrec.cpp b/library/cpp/charset/cp_encrec.cpp index d3c7a9db66..e4570cd628 100644 --- a/library/cpp/charset/cp_encrec.cpp +++ b/library/cpp/charset/cp_encrec.cpp @@ -16,7 +16,7 @@ void Encoder::Tr(const wchar32* in, char* out) const { void Recoder::Create(const CodePage& source, const Encoder* wideTarget) { for (size_t i = 0; i != 256; ++i) { Table[i] = wideTarget->Tr(source.unicode[i]); - Y_ASSERT(Table[i] != 0 || i == 0); + Y_ASSERT(Table[i] != 0 || i == 0); } } diff --git a/library/cpp/charset/generated/cp_data.cpp b/library/cpp/charset/generated/cp_data.cpp index ebe37f1a15..202362c596 100644 --- a/library/cpp/charset/generated/cp_data.cpp +++ b/library/cpp/charset/generated/cp_data.cpp @@ -126,28 +126,28 @@ static const CodePage CODES_BIG5_CODE_PAGE = { CODES_BIG5, {"BIG5", "BIGFIVE", "CN-BIG5", "CSBIG5",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_BIG5_HKSCS_CODE_PAGE = { CODES_BIG5_HKSCS, {"BIG5-HKSCS", "BIG5-HKSCS:2004",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_BIG5_HKSCS_1999_CODE_PAGE = { CODES_BIG5_HKSCS_1999, {"BIG5-HKSCS:1999",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_BIG5_HKSCS_2001_CODE_PAGE = { CODES_BIG5_HKSCS_2001, {"BIG5-HKSCS:2001",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_CP1046_CODE_PAGE = { @@ -1274,70 +1274,70 @@ static const CodePage CODES_CP932_CODE_PAGE = { CODES_CP932, {"CP932",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_CP936_CODE_PAGE = { CODES_CP936, {"CP936",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_CP949_CODE_PAGE = { CODES_CP949, {"CP949", "UHC",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_CP950_CODE_PAGE = { CODES_CP950, {"CP950",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_EUC_CN_CODE_PAGE = { CODES_EUC_CN, {"EUC-CN", "CN-GB", "GB2312", "CSGB2312",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_EUC_JP_CODE_PAGE = { CODES_EUC_JP, {"EUC-JP", "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", "CSEUCPKDFMTJAPANESE",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_EUC_KR_CODE_PAGE = { CODES_EUC_KR, {"EUC-KR", "ISO-IR-149", "KOREAN", "KSC_5601", "KS_C_5601-1987", "KS_C_5601-1989", "CSEUCKR", "CSKSC56011987",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_EUC_TW_CODE_PAGE = { CODES_EUC_TW, {"EUC-TW", "CSEUCTW",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_GB18030_CODE_PAGE = { CODES_GB18030, {"GB18030",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_GBK_CODE_PAGE = { CODES_GBK, {"GBK",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_GEO_ITA_CODE_PAGE = { @@ -1464,7 +1464,7 @@ static const CodePage CODES_HZ_CODE_PAGE = { CODES_HZ, {"HZ", "HZ-GB-2312",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_IBM855_CODE_PAGE = { @@ -1711,42 +1711,42 @@ static const CodePage CODES_ISO_2022_CN_CODE_PAGE = { CODES_ISO_2022_CN, {"ISO-2022-CN", "CSISO2022CN",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_2022_CN_EXT_CODE_PAGE = { CODES_ISO_2022_CN_EXT, {"ISO-2022-CN-EXT",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_2022_JP_CODE_PAGE = { CODES_ISO_2022_JP, {"ISO-2022-JP", "CPISO2022JP",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_2022_JP_1_CODE_PAGE = { CODES_ISO_2022_JP_1, {"ISO-2022-JP-1",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_2022_JP_2_CODE_PAGE = { CODES_ISO_2022_JP_2, {"ISO-2022-JP-2", "CPISO2022JP2",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_2022_KR_CODE_PAGE = { CODES_ISO_2022_KR, {"ISO-2022-KR", "CSISO2022KR",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_ISO_8859_13_CODE_PAGE = { @@ -2193,7 +2193,7 @@ static const CodePage CODES_JOHAB_CODE_PAGE = { CODES_JOHAB, {"JOHAB", "CP1361",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_KAZWIN_CODE_PAGE = { @@ -3080,7 +3080,7 @@ static const CodePage CODES_SHIFT_JIS_CODE_PAGE = { CODES_SHIFT_JIS, {"SHIFT_JIS", "MS_KANJI", "SJIS", "CSSHIFTJIS",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_TATWIN_CODE_PAGE = { @@ -3287,21 +3287,21 @@ static const CodePage CODES_UTF8_CODE_PAGE = { CODES_UTF8, {"utf-8",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_UTF_16BE_CODE_PAGE = { CODES_UTF_16BE, {"UTF-16BE",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_UTF_16LE_CODE_PAGE = { CODES_UTF_16LE, {"UTF-16LE", "UTF-16",}, {}, - nullptr, + nullptr, }; // generated from multibyte.txt static const CodePage CODES_VISCII_CODE_PAGE = { diff --git a/library/cpp/charset/generated/encrec_data.cpp b/library/cpp/charset/generated/encrec_data.cpp index 3eb7fd3f2f..ca59f8ddef 100644 --- a/library/cpp/charset/generated/encrec_data.cpp +++ b/library/cpp/charset/generated/encrec_data.cpp @@ -8302,10 +8302,10 @@ const Encoder* const NCodepagePrivate::TCodePageData::EncodeTo[] = { &encoder_07, &encoder_08, &encoder_09, - nullptr, - nullptr, + nullptr, + nullptr, &encoder_12, - nullptr, + nullptr, &encoder_14, &encoder_15, &encoder_16, @@ -8382,29 +8382,29 @@ const Encoder* const NCodepagePrivate::TCodePageData::EncodeTo[] = { &encoder_87, &encoder_88, &encoder_89, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, }; const struct Encoder &WideCharToYandex = encoder_09; diff --git a/library/cpp/charset/iconv_ut.cpp b/library/cpp/charset/iconv_ut.cpp index c60c97307d..e8c56f6d49 100644 --- a/library/cpp/charset/iconv_ut.cpp +++ b/library/cpp/charset/iconv_ut.cpp @@ -76,11 +76,11 @@ public: void TestSurrogatePairs() { const char* utf8NonBMP = "\xf4\x80\x89\x84\xf4\x80\x89\x87\xf4\x80\x88\xba"; wchar16 wNonBMPDummy[] = {0xDBC0, 0xDE44, 0xDBC0, 0xDE47, 0xDBC0, 0xDE3A}; - TestSurrogates(utf8NonBMP, wNonBMPDummy, Y_ARRAY_SIZE(wNonBMPDummy)); + TestSurrogates(utf8NonBMP, wNonBMPDummy, Y_ARRAY_SIZE(wNonBMPDummy)); const char* utf8NonBMP2 = "ab\xf4\x80\x89\x87n"; wchar16 wNonBMPDummy2[] = {'a', 'b', 0xDBC0, 0xDE47, 'n'}; - TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2)); + TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2)); } }; diff --git a/library/cpp/charset/recyr.hh b/library/cpp/charset/recyr.hh index 5c560d770a..5ec8734bcf 100644 --- a/library/cpp/charset/recyr.hh +++ b/library/cpp/charset/recyr.hh @@ -47,7 +47,7 @@ inline RECODE_RESULT RecodeFromUnicode(ECharset to, const TCharType* in, char* o } inline RECODE_RESULT RecodeFromUnicode(ECharset theEncoding, const wchar16* chars, size_t length, - char* bytes, size_t size, size_t* read = nullptr, size_t* written = nullptr) { + char* bytes, size_t size, size_t* read = nullptr, size_t* written = nullptr) { size_t w = 0, r = 0; RECODE_RESULT rc = ::RecodeFromUnicode(theEncoding, chars, bytes, length, size, r, w); if (read) @@ -122,7 +122,7 @@ inline bool Recode(ECharset from, ECharset to, const TStringBuf& in, TString& ou size_t inRead = 0; size_t outWritten = 0; const RECODE_RESULT res = Recode(from, to, in.data(), out.begin(), inSize, outSize, inRead, outWritten); - Y_ENSURE(RECODE_OK == res, "Recode failed. "); + Y_ENSURE(RECODE_OK == res, "Recode failed. "); if (outWritten > outSize) ythrow yexception() << "Recode overrun the buffer: size=" << outSize << " need=" << outWritten; diff --git a/library/cpp/charset/recyr_int.hh b/library/cpp/charset/recyr_int.hh index 1ea917b70f..353af53305 100644 --- a/library/cpp/charset/recyr_int.hh +++ b/library/cpp/charset/recyr_int.hh @@ -49,7 +49,7 @@ namespace NCodepagePrivate { inline RECODE_RESULT _recodeFromUTF8(ECharset to, const char* in, char* out, size_t in_size, size_t out_size, size_t& in_readed, size_t& out_writed) { if (to == CODES_UTF8) return _recodeCopy(in, out, in_size, out_size, in_readed, out_writed); - Y_ASSERT(CODES_UNKNOWN < to && to < CODES_MAX); + Y_ASSERT(CODES_UNKNOWN < to && to < CODES_MAX); const Encoder* enc = &EncoderByCharset(to); const unsigned char* in_start = (const unsigned char*)in; diff --git a/library/cpp/charset/wide.h b/library/cpp/charset/wide.h index 6f17efabd9..32d30e849e 100644 --- a/library/cpp/charset/wide.h +++ b/library/cpp/charset/wide.h @@ -18,7 +18,7 @@ //! @note @c dest buffer must fit at least @c len number of characters template <typename TCharType> inline size_t WideToChar(const TCharType* text, size_t len, char* dest, ECharset enc) { - Y_ASSERT(SingleByteCodepage(enc)); + Y_ASSERT(SingleByteCodepage(enc)); const char* start = dest; @@ -57,21 +57,21 @@ namespace NDetail { template <typename TCharType> inline TBasicStringBuf<TCharType> RecodeSingleByteChar(const TStringBuf src, TCharType* dst, const CodePage& cp) { - Y_ASSERT(cp.SingleByteCodepage()); + Y_ASSERT(cp.SingleByteCodepage()); ::CharToWide(src.data(), src.size(), dst, cp); return TBasicStringBuf<TCharType>(dst, src.size()); } template <typename TCharType> inline TStringBuf RecodeSingleByteChar(const TBasicStringBuf<TCharType> src, char* dst, const CodePage& cp) { - Y_ASSERT(cp.SingleByteCodepage()); + Y_ASSERT(cp.SingleByteCodepage()); ::WideToChar(src.data(), src.size(), dst, cp.CPEnum); return TStringBuf(dst, src.size()); } template <typename TCharType> inline TBasicStringBuf<TCharType> RecodeMultiByteChar(const TStringBuf src, TCharType* dst, ECharset encoding) { - Y_ASSERT(!NCodepagePrivate::NativeCodepage(encoding)); + Y_ASSERT(!NCodepagePrivate::NativeCodepage(encoding)); size_t read = 0; size_t written = 0; ::NICONVPrivate::RecodeToUnicode(encoding, src.data(), dst, src.size(), src.size(), read, written); @@ -80,7 +80,7 @@ namespace NDetail { template <typename TCharType> inline TStringBuf RecodeMultiByteChar(const TBasicStringBuf<TCharType> src, char* dst, ECharset encoding) { - Y_ASSERT(!NCodepagePrivate::NativeCodepage(encoding)); + Y_ASSERT(!NCodepagePrivate::NativeCodepage(encoding)); size_t read = 0; size_t written = 0; ::NICONVPrivate::RecodeFromUnicode(encoding, src.data(), dst, src.size(), src.size() * 3, read, written); diff --git a/library/cpp/charset/wide_ut.cpp b/library/cpp/charset/wide_ut.cpp index 4acd822ea0..78947d51ba 100644 --- a/library/cpp/charset/wide_ut.cpp +++ b/library/cpp/charset/wide_ut.cpp @@ -211,17 +211,17 @@ void TConversionTest::TestYandexEncoding() { const char* utf8NonBMP2 = "ab\xf4\x80\x89\x87n"; wchar16 wNonBMPDummy2[] = {'a', 'b', 0xDBC0, 0xDE47, 'n'}; - TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2), CODES_UTF8); + TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2), CODES_UTF8); { const char* yandexNonBMP2 = "ab?n"; - UNIT_ASSERT(yandexNonBMP2 == WideToChar(wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2), CODES_YANDEX)); + UNIT_ASSERT(yandexNonBMP2 == WideToChar(wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2), CODES_YANDEX)); TString temp; - temp.resize(Y_ARRAY_SIZE(wNonBMPDummy2)); + temp.resize(Y_ARRAY_SIZE(wNonBMPDummy2)); size_t read = 0; size_t written = 0; - RecodeFromUnicode(CODES_YANDEX, wNonBMPDummy2, temp.begin(), Y_ARRAY_SIZE(wNonBMPDummy2), temp.size(), read, written); + RecodeFromUnicode(CODES_YANDEX, wNonBMPDummy2, temp.begin(), Y_ARRAY_SIZE(wNonBMPDummy2), temp.size(), read, written); temp.remove(written); UNIT_ASSERT(yandexNonBMP2 == temp); @@ -337,7 +337,7 @@ void TConversionTest::TestRecodeAppend() { } template <> -void Out<RECODE_RESULT>(IOutputStream& out, RECODE_RESULT val) { +void Out<RECODE_RESULT>(IOutputStream& out, RECODE_RESULT val) { out << int(val); } @@ -390,7 +390,7 @@ void TConversionTest::TestUnicodeLimit() { continue; const CodePage* page = CodePageByCharset(code); - Y_ASSERT(page); + Y_ASSERT(page); for (int c = 0; c < 256; ++c) { UNIT_ASSERT(page->unicode[c] < 1 << 16); diff --git a/library/cpp/codecs/comptable_codec.cpp b/library/cpp/codecs/comptable_codec.cpp index cd079dd52c..476b8ada80 100644 --- a/library/cpp/codecs/comptable_codec.cpp +++ b/library/cpp/codecs/comptable_codec.cpp @@ -54,11 +54,11 @@ namespace NCodecs { Init(); } - void Save(IOutputStream* out) const { + void Save(IOutputStream* out) const { ::Save(out, Table); } - void Load(IInputStream* in) { + void Load(IInputStream* in) { ::Load(in, Table); Init(); } @@ -97,11 +97,11 @@ namespace NCodecs { Impl->DoLearn(in); } - void TCompTableCodec::Save(IOutputStream* out) const { + void TCompTableCodec::Save(IOutputStream* out) const { Impl->Save(out); } - void TCompTableCodec::Load(IInputStream* in) { + void TCompTableCodec::Load(IInputStream* in) { Impl->Load(in); } diff --git a/library/cpp/codecs/greedy_dict/gd_builder.cpp b/library/cpp/codecs/greedy_dict/gd_builder.cpp index 1c25299b11..561bfbca01 100644 --- a/library/cpp/codecs/greedy_dict/gd_builder.cpp +++ b/library/cpp/codecs/greedy_dict/gd_builder.cpp @@ -4,7 +4,7 @@ #include <util/generic/algorithm.h> #include <util/random/shuffle.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/string/printf.h> #include <util/system/rusage.h> diff --git a/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp b/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp index 6f6fe0e4cb..679089a11b 100644 --- a/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp +++ b/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp @@ -122,7 +122,7 @@ class TGreedyDictTest: public TTestBase { void FillData(NGreedyDict::TStringBufs& data) { static const char* urls[] = {"http://53.ru/car/motors/foreign/opel/tigra/", "http://abakan.24au.ru/tender/85904/", "http://anm15.gulaig.com/", "http://avto-parts.com/mercedes-benz/mercedes-benz-w220-1998-2005/category-442/category-443/", "http://ballooncousin.co.uk/", "http://benzol.ru/equipment/?id=1211&parent=514", "http://blazingseorank.com/blazing-seo-rank-free-website-analysis-to-increase-rank-and-traffic-450.html", "http://blogblaugrana.contadorwebmasters.com/", "http://bristolhash.org.uk/bh3cntct.php", "http://broker.borovichi.ru/category/item/3/1/0/8/28/257", "http://canoncompactcamerax.blogspot.com/", "http://classifieds.smashits.com/p,107881,email-to-friend.htm", "http://conferences.ksde.org/Portals/132/FallAssessment/SAVETHEDAY-FA09.pdf", "http://eway.vn/raovat/325-dien-tu-gia-dung/337-dieu-hoa/98041-b1-sua-may-lanh-quan-binh-tan-sua-may-lanh-quan-binh-chanh-hh-979676119-toan-quoc.html", "http://gallery.e2bn.org/asset73204_8-.html", "http://goplay.nsw.gov.au/activities-for-kids/by/historic-houses-trust/?startdate=2012-07-10", "http://grichards19067.multiply.com/", "http://hotkovo.egent.ru/user/89262269084/", "http://howimetyourself.com/?redirect_to=http://gomiso.com/m/suits/seasons/2/episodes/2", "http://islamqa.com/hi/ref/9014/DEAD%20PEOPLE%20GOOD%20DEEDS", "http://lapras.rutube.ru/", "http://nceluiko.ya.ru/", "http://nyanyanyanyaa.beon.ru/", "http://ozbo.com/Leaf-River-DV-7SS-7-0-MP-Game-Camera-K1-32541.html", "http://sbantom.ru/catalog/chasy/632753.html", "http://shopingoff.com/index.php?option=com_virtuemart&Itemid=65&category_id=&page=shop.browse&manufacturer_id=122&limit=32&limitstart=96", "http://shopingoff.com/katalog-odezhdy/manufacturer/62-christian-audigier.html?limit=32&start=448", "https://webwinkel.ah.nl/process?fh_location=//ecommerce/nl_NL/categories%3C%7Becommerce_shoc1%7D/it_show_product_code_1384%3E%7B10%3B20%7D/pr_startdate%3C20120519/pr_enddate%3E20120519/pr_ltc_allowed%3E%7Bbowi%7D/categories%3C%7Becommerce_shoc1_1al%7D/categories%3C%7Becommerce_shoc1_1al_1ahal%7D&&action=albert_noscript.modules.build", "http://top100.rambler.ru/navi/?theme=208/210/371&rgn=17", "http://volgogradskaya-oblast.extra-m.ru/classifieds/rabota/vakansii/banki-investicii/901467/", "http://wikien4.appspot.com/wiki/Warburg_hypothesis", "http://wola_baranowska.kamerzysta24.com.pl/", "http://www.10dot0dot0dot1.com/", "http://www.anima-redux.ru/index.php?key=gifts+teenage+girls", "http://www.aquaticabyseaworld.com/Calendar.aspx/CP/CP/CP/sp-us/CP/CP/ParkMap/Tickets/Weather.aspx", "http://www.autousa.com/360spin/2012_cadillac_ctssportwagon_3.6awdpremiumcollection.htm", "http://www.booking.com/city/gb/paignton-aireborough.html?inac=0&lang=pl", "http://www.booking.com/city/it/vodo-cadore.en.html", "http://www.booking.com/district/us/new-york/rockefeller-center.html&lang=no", "http://www.booking.com/hotel/bg/crown-fort-club.lv.html", "http://www.booking.com/hotel/ca/gouverneur-rimouski.ar.html", "http://www.booking.com/hotel/ch/l-auberge-du-chalet-a-gobet.fi.html", "http://www.booking.com/hotel/de/mark-garni.ru.html?aid=337384;label=yandex-hotel-mark-garni-68157-%7Bparam1%7D", "http://www.booking.com/hotel/de/mercure-goldschmieding-castrop-rauxel.ro.html", "http://www.booking.com/hotel/de/zollenspieker-fahrhaus.fr.html", "http://www.booking.com/hotel/es/jardin-metropolitano.ca.html", "http://www.booking.com/hotel/fr/clim.fr.html", "http://www.booking.com/hotel/fr/radisson-sas-toulouse-airport.et.html", "http://www.booking.com/hotel/gb/stgileshotel.ro.html?srfid=68c7fe42a03653a8796c84435c5299e4X16?tab=4", "http://www.booking.com/hotel/gr/rodos-park-suites.ru.html", "http://www.booking.com/hotel/id/le-grande-suites-bali.ru.html", "http://www.booking.com/hotel/it/mozart.it.html?aid=321655", "http://www.booking.com/hotel/ni/bahia-del-sol-villas.ru.html?dcid=1;dva=0", "http://www.booking.com/hotel/nl/cpschiphol.ro.html.ro.html?tab=4", "http://www.booking.com/hotel/th/laem-din.en-gb.html", "http://www.booking.com/hotel/th/tinidee-ranong.en.html", "http://www.booking.com/hotel/us/best-western-plus-merrimack-valley.hu.html", "http://www.booking.com/hotel/vn/tan-hai-long.km.html", "http://www.booking.com/landmark/au/royal-brisbane-women-s-hospital.vi.html", "http://www.booking.com/landmark/hk/nam-cheong-station.html&lang=id", "http://www.booking.com/landmark/it/spanish-steps.ca.html", "http://www.booking.com/landmark/sg/asian-civilisations-museum.html&lang=fi", "http://www.booking.com/place/fi-1376029.pt.html", "http://www.booking.com/place/tn257337.pl.html", "http://www.booking.com/region/ca/niagarafalls.ar.html&selected_currency=PLN", "http://www.booking.com/region/mx/queretaro.pt-pt.html&selected_currency=AUD", "http://www.booking.com/searchresults.en.html?city=20063074", "http://www.booking.com/searchresults.et.html?checkin=;checkout=;city=-394632", "http://www.booking.com/searchresults.lv.html?region=3936", "http://www.cevredanismanlari.com/index.php/component/k2/index.php/mevzuat/genel-yazlar/item/dosyalar/index.php?option=com_k2&view=item&id=16:iso-14001-%C3%A7evre-y%C3%B6netim-sistemi&Itemid=132&limitstart=107120", "http://www.dh-wholesaler.com/MENS-POLO-RACING-TEE-RL-p-417.html", "http://www.employabilityonline.net/", "http://www.esso.inc.ru/board/tools.php?event=profile&pname=Invinerrq", "http://www.filesurgery.ru/searchfw/kids_clothes-3.html", "http://www.furnitureandcarpetsource.com/Item.aspx?ItemID=-2107311899&ItemNum=53-T3048", "http://www.gets.cn/product/Gold-Sand-Lampwork-Glass-Beads--Flat-round--28x28x13mm_p260717.html", "http://www.gets.cn/wholesale-Sterling-Silver-Pendant-Findings-3577_S--L-Star-P-1.html?view=1&by=1", "http://www.homeandgardenadvice.com/diy/Mortgages_Loans_and_Financing/9221.html", "http://www.hongkongairport.com/eng/index.html/passenger/passenger/transport/to-from-airport/business/about-the-airport/transport/shopping/entertainment/t2/passenger/interactive-map.html", "http://www.hongkongairport.com/eng/index.html/shopping/insideshopping/all/passenger/transfer-transit/all/airline-information/shopping/entertainment/t2/business/about-the-airport/welcome.html", "http://www.hongkongairport.com/eng/index.html/transport/business/about-the-airport/transport/business/airport-authority/passenger/shopping/dining/all/dining.html", "http://www.idedge.com/index.cfm/fuseaction/category.display/category_id/298/index.cfm", "http://www.istanbulburda.com/aramalar.php", "http://www.jewelryinthenet.com/ads/AdDetail.aspx?AdID=1-0311002490689&stid=22-0111001020877", "http://www.johnnydepp.ru/forum/index.php?showtopic=1629&mode=linearplus&view=findpost&p=186977", "http://www.johnnydepp.ru/forum/index.php?showtopic=476&st=60&p=87379&", "http://www.joseleano.com/joomla/index.php/audio", "http://www.kaplicarehberi.com/tag/sakar-ilicali-kaplicalari/feed", "http://www.khaber.com.tr/arama.html?key=%C3%A7avdar", "http://www.kiz-oyunlari1.com/1783/4437/4363/1056/4170/Bump-Copter2-.html", "http://www.kiz-oyunlari1.com/3752/2612/4175/1166/3649/1047/Angelina-Oyunu.html", "http://www.kiz-oyunlari1.com/4266/3630/3665/3286/4121/301/3274/Sinir-Sinekler-.html", "http://www.kuldiga.lv/index.php?f=8&cat=371", "http://www.kuldiga.lv/index.php/img/index.php?l=lv&art_id=1836&show_c=&cat=85", "http://www.patronessa.ru/remontiruemsya/kuzovnie30raboti.html", "http://www.rapdict.org/Nu_Money?title=Talk:Nu_Money&action=edit", "http://www.serafin-phu.tabor24.com/?page=8", "http://www.shoes-store.org/brand1/Kids/Minnetonka.html", "http://www.shoes-store.org/shoes-store.xml", "http://www.way2allah.com/khotab-download-34695.htm"}; data.clear(); - data.insert(data.begin(), urls, urls + Y_ARRAY_SIZE(urls)); + data.insert(data.begin(), urls, urls + Y_ARRAY_SIZE(urls)); } typedef THashMap<TStringBuf, NGreedyDict::TEntry> TDict; @@ -140,9 +140,9 @@ class TGreedyDictTest: public TTestBase { TEntrySet& set = b.EntrySet(); - for (const auto& it : set) { - if (it.Score) { - res[it.Str] = it; + for (const auto& it : set) { + if (it.Score) { + res[it.Str] = it; } } diff --git a/library/cpp/codecs/greedy_dict/ut/ya.make b/library/cpp/codecs/greedy_dict/ut/ya.make index ae57a20ccd..bd67d1a452 100644 --- a/library/cpp/codecs/greedy_dict/ut/ya.make +++ b/library/cpp/codecs/greedy_dict/ut/ya.make @@ -1,7 +1,7 @@ UNITTEST_FOR(library/cpp/codecs/greedy_dict) -OWNER(velavokr) - +OWNER(velavokr) + SRCS( greedy_dict_ut.cpp ) diff --git a/library/cpp/codecs/greedy_dict/ya.make b/library/cpp/codecs/greedy_dict/ya.make index 4deb99578e..2a57224f7e 100644 --- a/library/cpp/codecs/greedy_dict/ya.make +++ b/library/cpp/codecs/greedy_dict/ya.make @@ -1,5 +1,5 @@ -OWNER(velavokr) - +OWNER(velavokr) + LIBRARY() SRCS( diff --git a/library/cpp/codecs/huffman_codec.cpp b/library/cpp/codecs/huffman_codec.cpp index e45f92a9aa..650fe7cdfd 100644 --- a/library/cpp/codecs/huffman_codec.cpp +++ b/library/cpp/codecs/huffman_codec.cpp @@ -3,7 +3,7 @@ #include <library/cpp/bit_io/bitoutput.h> #include <util/generic/algorithm.h> -#include <util/generic/bitops.h> +#include <util/generic/bitops.h> #include <util/stream/buffer.h> #include <util/stream/length.h> #include <util/string/printf.h> diff --git a/library/cpp/codecs/static/static.cpp b/library/cpp/codecs/static/static.cpp index f7cc97142c..44a07dd73a 100644 --- a/library/cpp/codecs/static/static.cpp +++ b/library/cpp/codecs/static/static.cpp @@ -19,7 +19,7 @@ namespace NCodecs { return STATIC_CODEC_INFO_MAGIC; } - void SaveCodecInfoToStream(IOutputStream& out, const TStaticCodecInfo& info) { + void SaveCodecInfoToStream(IOutputStream& out, const TStaticCodecInfo& info) { TBufferOutput bout; info.SerializeToArcadiaStream(&bout); ui64 hash = DataSignature(bout.Buffer()); @@ -28,7 +28,7 @@ namespace NCodecs { ::Save(&out, bout.Buffer()); } - TStaticCodecInfo LoadCodecInfoFromStream(IInputStream& in) { + TStaticCodecInfo LoadCodecInfoFromStream(IInputStream& in) { { TBuffer magic; magic.Resize(GetStaticCodecInfoMagic().size()); diff --git a/library/cpp/codecs/static/static.h b/library/cpp/codecs/static/static.h index b5e1be3bb3..c1eaed2a74 100644 --- a/library/cpp/codecs/static/static.h +++ b/library/cpp/codecs/static/static.h @@ -4,7 +4,7 @@ #include <util/generic/strbuf.h> #include <util/generic/string.h> -#include <util/stream/output.h> +#include <util/stream/output.h> namespace NCodecs { class TStaticCodecInfo; @@ -23,11 +23,11 @@ namespace NCodecs { TString SaveCodecInfoToString(const TStaticCodecInfo&); - void SaveCodecInfoToStream(IOutputStream& out, const TStaticCodecInfo&); + void SaveCodecInfoToStream(IOutputStream& out, const TStaticCodecInfo&); // misc - TStaticCodecInfo LoadCodecInfoFromStream(IInputStream& in); + TStaticCodecInfo LoadCodecInfoFromStream(IInputStream& in); TString FormatCodecInfo(const TStaticCodecInfo&); diff --git a/library/cpp/codecs/static/tools/common/ct_common.cpp b/library/cpp/codecs/static/tools/common/ct_common.cpp index 99151a6d4d..fe77691280 100644 --- a/library/cpp/codecs/static/tools/common/ct_common.cpp +++ b/library/cpp/codecs/static/tools/common/ct_common.cpp @@ -4,7 +4,7 @@ #include <library/cpp/codecs/static/static_codec_info.pb.h> #include <library/cpp/string_utils/base64/base64.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/string/builder.h> #include <util/system/hp_timer.h> diff --git a/library/cpp/codecs/ut/codecs_ut.cpp b/library/cpp/codecs/ut/codecs_ut.cpp index 823a9bf748..caf6089aef 100644 --- a/library/cpp/codecs/ut/codecs_ut.cpp +++ b/library/cpp/codecs/ut/codecs_ut.cpp @@ -1111,7 +1111,7 @@ private: { TVector<TBuffer> learn; - for (auto& textValue : TextValues) { + for (auto& textValue : TextValues) { learn.emplace_back(textValue, strlen(textValue)); } @@ -1199,7 +1199,7 @@ private: TVector<TBuffer> data; - for (auto& textValue : TextValues) { + for (auto& textValue : TextValues) { data.emplace_back(textValue, strlen(textValue)); } @@ -1221,15 +1221,15 @@ private: THuffmanCodec codec; std::pair<char, ui64> freqs[256]; - for (size_t i = 0; i < Y_ARRAY_SIZE(freqs); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(freqs); ++i) { freqs[i].first = (char)i; freqs[i].second = 0; } - for (auto& textValue : TextValues) { - size_t len = strlen(textValue); + for (auto& textValue : TextValues) { + size_t len = strlen(textValue); for (size_t j = 0; j < len; ++j) { - ++freqs[(ui32)(0xFF & textValue[j])].second; + ++freqs[(ui32)(0xFF & textValue[j])].second; } } @@ -1253,7 +1253,7 @@ private: { TVector<TBuffer> learn; - for (auto& textValue : TextValues) { + for (auto& textValue : TextValues) { learn.emplace_back(textValue, strlen(textValue)); } @@ -1345,14 +1345,14 @@ private: void TestRegistry() { using namespace NCodecs; TVector<TString> vs = ICodec::GetCodecsList(); - for (const auto& v : vs) { - TCodecPtr p = ICodec::GetInstance(v); - if (v == "none") { + for (const auto& v : vs) { + TCodecPtr p = ICodec::GetInstance(v); + if (v == "none") { UNIT_ASSERT(!p); continue; } - UNIT_ASSERT_C(!!p, v); - UNIT_ASSERT_C(TStringBuf(v).Head(3) == TStringBuf(p->GetName()).Head(3), v + " " + p->GetName()); + UNIT_ASSERT_C(!!p, v); + UNIT_ASSERT_C(TStringBuf(v).Head(3) == TStringBuf(p->GetName()).Head(3), v + " " + p->GetName()); } } }; diff --git a/library/cpp/codecs/ut/float_huffman_ut.cpp b/library/cpp/codecs/ut/float_huffman_ut.cpp index 2215a9c6d7..3156fb1f46 100644 --- a/library/cpp/codecs/ut/float_huffman_ut.cpp +++ b/library/cpp/codecs/ut/float_huffman_ut.cpp @@ -8,7 +8,7 @@ namespace fh = NCodecs::NFloatHuff; -Y_UNIT_TEST_SUITE(FloatHuffmanTest) { +Y_UNIT_TEST_SUITE(FloatHuffmanTest) { static const float Factors[] = { 0.340582, 0.000974026, 0.487168, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0.411765, 0.921569, 0.00390625, 0.109371, 0, 1, 0, 0, 0, 0, 0.523322, 0, 1, 0, 0, 0, 0, 0.285714, 1, @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { 0.947855, 0, 0, 0, 0, 0, 0, 0, 0, 0.847059, 0.679841, 0, 0.156863, 0, 0, 1, 0, 0, 0, 0, 0.969697, 0, 0, 0.564706, 0, 0, 0, 0, 0, 1, 0.0367282, 0.0395228, 0, 0, 0, 0, 0, 0.0470588, 0.141176, 0.054902, 0, 0, 0, 0}; - static const size_t FactorCount = Y_ARRAY_SIZE(Factors); + static const size_t FactorCount = Y_ARRAY_SIZE(Factors); static const ui8 CodedFactors[] = { 0x24, 0x06, 0x73, 0xB5, 0xC7, 0x55, 0x7F, 0x3A, 0xB4, 0x70, 0xCB, 0xEF, 0xEE, 0xFE, 0xB3, 0x5B, @@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { 0xC8, 0xFE, 0x08, 0xC2, 0x07, 0xC7, 0x27, 0x21, 0xE1, 0xBB, 0x3E, 0xC1, 0x59, 0x68, 0xAA, 0x78, 0xC8, 0x57, 0x5D, 0x60, 0x20, 0xC6, 0x41, 0x42, 0xE8, 0x3A, 0x38, 0xD8, 0x9B, 0xFF, 0xFF, 0xFF, 0xC4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - static const size_t CodedSize = Y_ARRAY_SIZE(CodedFactors); + static const size_t CodedSize = Y_ARRAY_SIZE(CodedFactors); static const TStringBuf CodedFactorsBuf(reinterpret_cast<const char*>(CodedFactors), CodedSize); void FillWithGarbage(float* factors, size_t count) { @@ -166,7 +166,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { Cerr << result.Str() << Endl; } - Y_UNIT_TEST(TestCompress) { + Y_UNIT_TEST(TestCompress) { const auto codedFactors = fh::Encode(Factors); UNIT_ASSERT_VALUES_EQUAL(codedFactors.size(), CodedSize); for (size_t i = 0; i < Min(codedFactors.size(), CodedSize); ++i) @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { //PrintCompressed(codedFactors); } - Y_UNIT_TEST(TestSimpleDecompress) { + Y_UNIT_TEST(TestSimpleDecompress) { TVector<float> factors = fh::Decode(CodedFactorsBuf); UNIT_ASSERT_VALUES_EQUAL(factors.size(), FactorCount); for (size_t i = 0; i < Min(factors.size(), FactorCount); ++i) @@ -197,7 +197,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { //PrintDecompressed(factors); } - Y_UNIT_TEST(TestSkip) { + Y_UNIT_TEST(TestSkip) { float factors[FactorCount]; FillWithGarbage(factors, FactorCount); fh::TDecoder decoder(CodedFactorsBuf); @@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { //PrintDecompressed(factors); } - Y_UNIT_TEST(TestDecompressForgedData) { + Y_UNIT_TEST(TestDecompressForgedData) { // this coredumps without end-of-coded-stream check, see SEARCH-1156 for details TString brokenBase64Encoded = "NLjYltUWs5pqnd3d3f05Li4OAwCAEqrP6mv06jDt7PiAUVu7Y+PiMpuZmdzeM" diff --git a/library/cpp/codecs/ut/tls_cache_ut.cpp b/library/cpp/codecs/ut/tls_cache_ut.cpp index daa7249eaa..8101af761f 100644 --- a/library/cpp/codecs/ut/tls_cache_ut.cpp +++ b/library/cpp/codecs/ut/tls_cache_ut.cpp @@ -1,7 +1,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/codecs/tls_cache.h> -Y_UNIT_TEST_SUITE(CodecsBufferFactoryTest){ +Y_UNIT_TEST_SUITE(CodecsBufferFactoryTest){ void AssignToBuffer(TBuffer & buf, TStringBuf val){ buf.Assign(val.data(), val.size()); } @@ -10,7 +10,7 @@ TStringBuf AsStringBuf(const TBuffer& b) { return TStringBuf(b.Data(), b.Size()); } -Y_UNIT_TEST(TestAcquireReleaseReuse) { +Y_UNIT_TEST(TestAcquireReleaseReuse) { NCodecs::TBufferTlsCache factory; // acquiring the first buffer auto buf1 = factory.Item(); diff --git a/library/cpp/codecs/zstd_dict_codec.cpp b/library/cpp/codecs/zstd_dict_codec.cpp index 5ae8dcd324..c42a2879e6 100644 --- a/library/cpp/codecs/zstd_dict_codec.cpp +++ b/library/cpp/codecs/zstd_dict_codec.cpp @@ -183,11 +183,11 @@ namespace NCodecs { return true; } - void Save(IOutputStream* out) const { + void Save(IOutputStream* out) const { ::Save(out, Dict); } - void Load(IInputStream* in) { + void Load(IInputStream* in) { ::Load(in, Dict); InitContexts(); } @@ -255,11 +255,11 @@ namespace NCodecs { return Impl->Learn(in, false/*throwOnError*/); } - void TZStdDictCodec::Save(IOutputStream* out) const { + void TZStdDictCodec::Save(IOutputStream* out) const { Impl->Save(out); } - void TZStdDictCodec::Load(IInputStream* in) { + void TZStdDictCodec::Load(IInputStream* in) { Impl->Load(in); } diff --git a/library/cpp/colorizer/colors.cpp b/library/cpp/colorizer/colors.cpp index 004adeee6e..decc5c9847 100644 --- a/library/cpp/colorizer/colors.cpp +++ b/library/cpp/colorizer/colors.cpp @@ -452,7 +452,7 @@ TColors& NColorizer::StdOut() { return *Singleton<TStdOutColors>(); } -TColors& NColorizer::AutoColors(IOutputStream& os) { +TColors& NColorizer::AutoColors(IOutputStream& os) { if (&os == &Cerr) { return StdErr(); } diff --git a/library/cpp/colorizer/colors.h b/library/cpp/colorizer/colors.h index 690090b7d3..474a918994 100644 --- a/library/cpp/colorizer/colors.h +++ b/library/cpp/colorizer/colors.h @@ -218,7 +218,7 @@ namespace NColorizer { /// Choose `TColors` depending on output stream. If passed stream is stderr/stdout, return a corresponding /// singletone. Otherwise, return a disabled singletone (which you can, but should *not* enable). - TColors& AutoColors(IOutputStream& os); + TColors& AutoColors(IOutputStream& os); /// Calculate total length of all ANSI escape codes in the text. size_t TotalAnsiEscapeCodeLen(TStringBuf text); diff --git a/library/cpp/colorizer/fwd.h b/library/cpp/colorizer/fwd.h index f07ed5dda2..d71efdc053 100644 --- a/library/cpp/colorizer/fwd.h +++ b/library/cpp/colorizer/fwd.h @@ -1,11 +1,11 @@ #pragma once -class IOutputStream; +class IOutputStream; namespace NColorizer { class TColors; TColors& StdErr(); TColors& StdOut(); - TColors& AutoColors(IOutputStream&); + TColors& AutoColors(IOutputStream&); } diff --git a/library/cpp/colorizer/output.cpp b/library/cpp/colorizer/output.cpp index 70698d66f0..66a5626675 100644 --- a/library/cpp/colorizer/output.cpp +++ b/library/cpp/colorizer/output.cpp @@ -5,6 +5,6 @@ using namespace NColorizer; template <> -void Out<TColorHandle>(IOutputStream& o, const TColorHandle& h) { +void Out<TColorHandle>(IOutputStream& o, const TColorHandle& h) { o << (*(h.C).*h.F)(); } diff --git a/library/cpp/colorizer/ut/colorizer_ut.cpp b/library/cpp/colorizer/ut/colorizer_ut.cpp index ec270d605e..20341440af 100644 --- a/library/cpp/colorizer/ut/colorizer_ut.cpp +++ b/library/cpp/colorizer/ut/colorizer_ut.cpp @@ -5,8 +5,8 @@ #include <util/string/escape.h> -Y_UNIT_TEST_SUITE(ColorizerTest) { - Y_UNIT_TEST(BasicTest) { +Y_UNIT_TEST_SUITE(ColorizerTest) { + Y_UNIT_TEST(BasicTest) { NColorizer::TColors colors; colors.Enable(); UNIT_ASSERT_STRINGS_EQUAL(EscapeC(colors.BlueColor()), "\\x1B[22;34m"); @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(ColorizerTest) { UNIT_ASSERT(colors.BlueColor().Empty()); } - Y_UNIT_TEST(ResettingTest) { + Y_UNIT_TEST(ResettingTest) { NColorizer::TColors colors; colors.Enable(); // 22;39, not 0, should be used so that only foreground changes diff --git a/library/cpp/compproto/compproto_ut.cpp b/library/cpp/compproto/compproto_ut.cpp index 9dfb947e1c..9393be967a 100644 --- a/library/cpp/compproto/compproto_ut.cpp +++ b/library/cpp/compproto/compproto_ut.cpp @@ -108,7 +108,7 @@ void Test(const TString& metainfo, const ECompMode mode) { } } -Y_UNIT_TEST_SUITE(CompProtoTestBasic) { +Y_UNIT_TEST_SUITE(CompProtoTestBasic) { using namespace NCompProto; const TString metainfo = @@ -254,7 +254,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { TMap<ui32, TRegInfo>::iterator RegIter; TMetaIterator<TVerifyingDecompressor>& GetDecompressor(size_t index) { - Y_UNUSED(index); + Y_UNUSED(index); return *Parent; } @@ -354,24 +354,24 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { } }; - Y_UNIT_TEST(VerifyDecompression) { + Y_UNIT_TEST(VerifyDecompression) { Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_SINGLEPASS); } - Y_UNIT_TEST(VerifyHistDecompression) { + Y_UNIT_TEST(VerifyHistDecompression) { Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_TWOPASS); } - Y_UNIT_TEST(VerifyDecompressionMulti) { + Y_UNIT_TEST(VerifyDecompressionMulti) { Test<TMultiDecompressor, TSerialize>(metainfo, CM_SINGLEPASS); } - Y_UNIT_TEST(VerifyHistDecompressionMulti) { + Y_UNIT_TEST(VerifyHistDecompressionMulti) { Test<TMultiDecompressor, TSerialize>(metainfo, CM_TWOPASS); } } -Y_UNIT_TEST_SUITE(CompProtoTestExtended) { +Y_UNIT_TEST_SUITE(CompProtoTestExtended) { using namespace NCompProto; const TString metainfo = "\n\ @@ -447,7 +447,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestExtended) { } TMetaIterator<TVerifyingDecompressor>& GetDecompressor(size_t index) { - Y_UNUSED(index); + Y_UNUSED(index); return *Parent; } @@ -533,11 +533,11 @@ Y_UNIT_TEST_SUITE(CompProtoTestExtended) { } } }; - Y_UNIT_TEST(VerifyDecompression) { + Y_UNIT_TEST(VerifyDecompression) { Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_SINGLEPASS); } - Y_UNIT_TEST(VerifyHistDecompression) { + Y_UNIT_TEST(VerifyHistDecompression) { Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_TWOPASS); } } diff --git a/library/cpp/comptable/comptable.h b/library/cpp/comptable/comptable.h index 18f0b6ec81..d225fed7a0 100644 --- a/library/cpp/comptable/comptable.h +++ b/library/cpp/comptable/comptable.h @@ -66,10 +66,10 @@ namespace NCompTable { template <> class TSerializer<NCompTable::TCompressorTable> { public: - static inline void Save(IOutputStream* out, const NCompTable::TCompressorTable& entry) { + static inline void Save(IOutputStream* out, const NCompTable::TCompressorTable& entry) { SavePodType(out, entry); } - static inline void Load(IInputStream* in, NCompTable::TCompressorTable& entry) { + static inline void Load(IInputStream* in, NCompTable::TCompressorTable& entry) { LoadPodType(in, entry); } }; diff --git a/library/cpp/comptable/usage/usage.cpp b/library/cpp/comptable/usage/usage.cpp index 9fb9cd6e3b..9997c83686 100644 --- a/library/cpp/comptable/usage/usage.cpp +++ b/library/cpp/comptable/usage/usage.cpp @@ -69,7 +69,7 @@ int main(int argc, const char* argv[]) { DoTest<true>(table, lines); DoTest<false>(table, lines); - Y_UNUSED(argc); - Y_UNUSED(argv); + Y_UNUSED(argc); + Y_UNUSED(argv); return 0; } diff --git a/library/cpp/comptable/ut/comptable_ut.cpp b/library/cpp/comptable/ut/comptable_ut.cpp index ff17b80aae..5901d0246f 100644 --- a/library/cpp/comptable/ut/comptable_ut.cpp +++ b/library/cpp/comptable/ut/comptable_ut.cpp @@ -39,8 +39,8 @@ void DoTest(const TCompressorTable& table, const TVector<TString>& lines) { UNIT_ASSERT(compSize < origSize); } -Y_UNIT_TEST_SUITE(TestComptable) { - Y_UNIT_TEST(TestComptableCompressDecompress) { +Y_UNIT_TEST_SUITE(TestComptable) { + Y_UNIT_TEST(TestComptableCompressDecompress) { TReallyFastRng32 rr(17); TVector<TString> lines; for (size_t i = 0; i < 1000000; ++i) { diff --git a/library/cpp/containers/2d_array/2d_array.h b/library/cpp/containers/2d_array/2d_array.h index aa47f39933..9e24650637 100644 --- a/library/cpp/containers/2d_array/2d_array.h +++ b/library/cpp/containers/2d_array/2d_array.h @@ -13,7 +13,7 @@ struct TBoundCheck { Size = s; } T& operator[](size_t i) const { - Y_ASSERT(i >= 0 && i < Size); + Y_ASSERT(i >= 0 && i < Size); return Data[i]; } }; diff --git a/library/cpp/containers/bitseq/bititerator.h b/library/cpp/containers/bitseq/bititerator.h index bbeadb7295..52dadd3798 100644 --- a/library/cpp/containers/bitseq/bititerator.h +++ b/library/cpp/containers/bitseq/bititerator.h @@ -44,7 +44,7 @@ public: TWord Peek(ui8 count) const { if (!count) return 0; - Y_VERIFY_DEBUG(count <= TTraits::NumBits); + Y_VERIFY_DEBUG(count <= TTraits::NumBits); if (!Mask) return *Data & TTraits::ElemMask(count); @@ -64,7 +64,7 @@ public: TWord Read(ui8 count) { if (!count) return 0; - Y_VERIFY_DEBUG(count <= TTraits::NumBits); + Y_VERIFY_DEBUG(count <= TTraits::NumBits); if (!Mask) { Current = *Data++; diff --git a/library/cpp/containers/bitseq/bititerator_ut.cpp b/library/cpp/containers/bitseq/bititerator_ut.cpp index a7bbec119f..ed0925866f 100644 --- a/library/cpp/containers/bitseq/bititerator_ut.cpp +++ b/library/cpp/containers/bitseq/bititerator_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/generic/vector.h> -Y_UNIT_TEST_SUITE(TBitIteratorTest) { +Y_UNIT_TEST_SUITE(TBitIteratorTest) { TVector<ui16> GenWords() { TVector<ui16> words(1, 0); for (ui16 word = 1; word; ++word) @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TBitIteratorTest) { UNIT_ASSERT_EQUAL(peek, expected); } - Y_UNIT_TEST(TestNextAndPeek) { + Y_UNIT_TEST(TestNextAndPeek) { const auto& words = GenWords(); TBitIterator<ui16> iter(words.data()); @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(TBitIteratorTest) { UNIT_ASSERT_EQUAL(iter.NextWord(), words.data() + words.size()); } - Y_UNIT_TEST(TestAlignedReadAndPeek) { + Y_UNIT_TEST(TestAlignedReadAndPeek) { const auto& words = GenWords(); TBitIterator<ui16> iter(words.data()); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TBitIteratorTest) { UNIT_ASSERT_EQUAL(iter.NextWord(), words.data() + words.size()); } - Y_UNIT_TEST(TestForward) { + Y_UNIT_TEST(TestForward) { TVector<ui32> words; words.push_back((1 << 10) | (1 << 20) | (1 << 25)); words.push_back(1 | (1 << 5) | (1 << 6) | (1 << 30)); @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(TBitIteratorTest) { UNIT_ASSERT_EQUAL(iter.NextWord(), words.data() + 6); } - Y_UNIT_TEST(TestUnalignedReadAndPeek) { + Y_UNIT_TEST(TestUnalignedReadAndPeek) { TVector<ui32> words; words.push_back((1 << 10) | (1 << 20) | (1 << 25)); words.push_back(1 | (1 << 5) | (1 << 6) | (1 << 30)); diff --git a/library/cpp/containers/bitseq/bitvector.h b/library/cpp/containers/bitseq/bitvector.h index 9d6471ea9a..3f8fd81ee5 100644 --- a/library/cpp/containers/bitseq/bitvector.h +++ b/library/cpp/containers/bitseq/bitvector.h @@ -52,7 +52,7 @@ public: } bool Set(ui64 pos) { - Y_ASSERT(pos < Size_); + Y_ASSERT(pos < Size_); TWord& val = Data_[pos >> TTraits::DivShift]; if (val & TTraits::BitMask(pos & TTraits::ModMask)) return false; @@ -65,7 +65,7 @@ public: } void Reset(ui64 pos) { - Y_ASSERT(pos < Size_); + Y_ASSERT(pos < Size_); Data_[pos >> TTraits::DivShift] &= ~TTraits::BitMask(pos & TTraits::ModMask); } @@ -80,7 +80,7 @@ public: void Set(ui64 pos, TWord value, ui8 width, TWord mask) { if (!width) return; - Y_ASSERT((pos + width) <= Size_); + Y_ASSERT((pos + width) <= Size_); size_t word = pos >> TTraits::DivShift; TWord shift1 = pos & TTraits::ModMask; TWord shift2 = TTraits::NumBits - shift1; @@ -130,12 +130,12 @@ public: return Data_.data(); } - void Save(IOutputStream* out) const { + void Save(IOutputStream* out) const { ::Save(out, Size_); ::Save(out, Data_); } - void Load(IInputStream* inp) { + void Load(IInputStream* inp) { ::Load(inp, Size_); ::Load(inp, Data_); } @@ -145,7 +145,7 @@ public: Data_.size() * sizeof(TWord)); } - void Print(IOutputStream& out, size_t truncate = 128) { + void Print(IOutputStream& out, size_t truncate = 128) { for (size_t i = 0; i < Data_.size() && i < truncate; ++i) { for (int j = TTraits::NumBits - 1; j >= 0; --j) { size_t pos = TTraits::NumBits * i + j; diff --git a/library/cpp/containers/bitseq/bitvector_ut.cpp b/library/cpp/containers/bitseq/bitvector_ut.cpp index 3fd4df1de6..6137adab1e 100644 --- a/library/cpp/containers/bitseq/bitvector_ut.cpp +++ b/library/cpp/containers/bitseq/bitvector_ut.cpp @@ -6,8 +6,8 @@ #include <util/memory/blob.h> #include <util/stream/buffer.h> -Y_UNIT_TEST_SUITE(TBitVectorTest) { - Y_UNIT_TEST(TestEmpty) { +Y_UNIT_TEST_SUITE(TBitVectorTest) { + Y_UNIT_TEST(TestEmpty) { TBitVector<ui64> v64; UNIT_ASSERT_EQUAL(v64.Size(), 0); UNIT_ASSERT_EQUAL(v64.Words(), 0); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TBitVectorTest) { UNIT_ASSERT_EQUAL(v32.Words(), 0); } - Y_UNIT_TEST(TestOneWord) { + Y_UNIT_TEST(TestOneWord) { TBitVector<ui32> v; v.Append(1, 1); v.Append(0, 1); @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TBitVectorTest) { UNIT_ASSERT_EQUAL(v.Words(), 1); } - Y_UNIT_TEST(TestManyWords) { + Y_UNIT_TEST(TestManyWords) { static const int BITS = 10; TBitVector<ui64> v; @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(TBitVectorTest) { UNIT_ASSERT_EQUAL(v.Get(i * BITS, BITS), (ui64)i); } - Y_UNIT_TEST(TestMaxWordSize) { + Y_UNIT_TEST(TestMaxWordSize) { TBitVector<ui32> v; for (int i = 0; i < 100; ++i) v.Append(i, 32); @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TBitVectorTest) { UNIT_ASSERT_EQUAL(v.Get(10 * 32, 32), 100500); } - Y_UNIT_TEST(TestReadonlyVector) { + Y_UNIT_TEST(TestReadonlyVector) { TBitVector<ui64> v(100); for (ui64 i = 0; i < v.Size(); ++i) { if (i % 3 == 0) { diff --git a/library/cpp/containers/bitseq/traits.h b/library/cpp/containers/bitseq/traits.h index a57f15d7b3..2330b1b4f2 100644 --- a/library/cpp/containers/bitseq/traits.h +++ b/library/cpp/containers/bitseq/traits.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/bitops.h> +#include <util/generic/bitops.h> #include <util/generic/typetraits.h> #include <util/system/yassert.h> @@ -12,7 +12,7 @@ struct TBitSeqTraits { static inline TWord ElemMask(ui8 count) { // NOTE: Shifting by the type's length is UB, so we need this workaround. - if (Y_LIKELY(count)) + if (Y_LIKELY(count)) return TWord(-1) >> (NumBits - count); return 0; } diff --git a/library/cpp/containers/compact_vector/compact_vector.h b/library/cpp/containers/compact_vector/compact_vector.h index 434eda0f1a..dbe7473f0c 100644 --- a/library/cpp/containers/compact_vector/compact_vector.h +++ b/library/cpp/containers/compact_vector/compact_vector.h @@ -162,14 +162,14 @@ public: } TIterator Insert(TIterator pos, const T& elem) { - Y_ASSERT(pos >= Begin()); - Y_ASSERT(pos <= End()); + Y_ASSERT(pos >= Begin()); + Y_ASSERT(pos <= End()); size_t posn = pos - Begin(); if (pos == End()) { PushBack(elem); } else { - Y_ASSERT(Size() > 0); + Y_ASSERT(Size() > 0); Reserve(Size() + 1); @@ -198,12 +198,12 @@ public: } T& operator[](size_t index) { - Y_ASSERT(index < Size()); + Y_ASSERT(index < Size()); return Ptr[index]; } const T& operator[](size_t index) const { - Y_ASSERT(index < Size()); + Y_ASSERT(index < Size()); return Ptr[index]; } }; diff --git a/library/cpp/containers/compact_vector/compact_vector_ut.cpp b/library/cpp/containers/compact_vector/compact_vector_ut.cpp index 4f5ec0ad10..7d413d6575 100644 --- a/library/cpp/containers/compact_vector/compact_vector_ut.cpp +++ b/library/cpp/containers/compact_vector/compact_vector_ut.cpp @@ -2,11 +2,11 @@ #include "compact_vector.h" -Y_UNIT_TEST_SUITE(TCompactVectorTest) { - Y_UNIT_TEST(TestSimple1) { +Y_UNIT_TEST_SUITE(TCompactVectorTest) { + Y_UNIT_TEST(TestSimple1) { } - Y_UNIT_TEST(TestSimple) { + Y_UNIT_TEST(TestSimple) { TCompactVector<ui32> vector; for (ui32 i = 0; i < 10000; ++i) { vector.PushBack(i + 20); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TCompactVectorTest) { } } - Y_UNIT_TEST(TestInsert) { + Y_UNIT_TEST(TestInsert) { TCompactVector<ui32> vector; for (ui32 i = 0; i < 10; ++i) { diff --git a/library/cpp/containers/comptrie/chunked_helpers_trie.h b/library/cpp/containers/comptrie/chunked_helpers_trie.h index 993a9f800f..cfa35f5ba2 100644 --- a/library/cpp/containers/comptrie/chunked_helpers_trie.h +++ b/library/cpp/containers/comptrie/chunked_helpers_trie.h @@ -48,7 +48,7 @@ public: return Builder.Find(key, strlen(key), &dummy); } - void Save(IOutputStream& out) const { + void Save(IOutputStream& out) const { Builder.Save(out); } @@ -164,7 +164,7 @@ public: } } - void Save(IOutputStream& out, bool minimize = false) const { + void Save(IOutputStream& out, bool minimize = false) const { if (minimize) { CompactTrieMinimize<TBuilder>(out, Builder, false); } else { @@ -191,7 +191,7 @@ public: Values.push_back(TValue(key, value)); } - void Save(IOutputStream& out) { + void Save(IOutputStream& out) { Sort(Values.begin(), Values.end()); TTrieMapWriter<T, true> writer; for (typename TValues::const_iterator toValue = Values.begin(); toValue != Values.end(); ++toValue) diff --git a/library/cpp/containers/comptrie/comptrie_builder.h b/library/cpp/containers/comptrie/comptrie_builder.h index 8b5adf060c..cf7d2e39a3 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.h +++ b/library/cpp/containers/comptrie/comptrie_builder.h @@ -81,8 +81,8 @@ public: return FindLongestPrefix(key.data(), key.size(), prefixLen, value); } - size_t Save(IOutputStream& os) const; - size_t SaveAndDestroy(IOutputStream& os); + size_t Save(IOutputStream& os) const; + size_t SaveAndDestroy(IOutputStream& os); size_t SaveToFile(const TString& fileName) const { TFixedBufferFileOutput out(fileName); return Save(out); @@ -118,10 +118,10 @@ protected: // If you want both minimization and fast layout, do the minimization first. template <class TPacker> -size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker(), NCompactTrie::EMinimizeMode mode = NCompactTrie::MM_DEFAULT); +size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker(), NCompactTrie::EMinimizeMode mode = NCompactTrie::MM_DEFAULT); template <class TTrieBuilder> -size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); +size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); //---------------------------------------------------------------------------------------------------------------- // Lay the trie in memory in such a way that there are less cache misses when jumping from root to leaf. @@ -143,17 +143,17 @@ size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool // (there is not much difference between these papers, actually). // template <class TPacker> -size_t CompactTrieMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker()); +size_t CompactTrieMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker()); template <class TTrieBuilder> -size_t CompactTrieMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); +size_t CompactTrieMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); // Composition of minimization and fast layout template <class TPacker> -size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker()); +size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker()); template <class TTrieBuilder> -size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); +size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); // Implementation details moved here. #include "comptrie_builder.inl" diff --git a/library/cpp/containers/comptrie/comptrie_builder.inl b/library/cpp/containers/comptrie/comptrie_builder.inl index 612a1bbe95..f273fa6571 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.inl +++ b/library/cpp/containers/comptrie/comptrie_builder.inl @@ -53,18 +53,18 @@ protected: bool FindLongestPrefixImpl(const char* keyptr, size_t keylen, size_t* prefixLen, TData* value) const; size_t NodeMeasureSubtree(TNode* thiz) const; - ui64 NodeSaveSubtree(TNode* thiz, IOutputStream& os) const; - ui64 NodeSaveSubtreeAndDestroy(TNode* thiz, IOutputStream& osy); + ui64 NodeSaveSubtree(TNode* thiz, IOutputStream& os) const; + ui64 NodeSaveSubtreeAndDestroy(TNode* thiz, IOutputStream& osy); void NodeBufferSubtree(TNode* thiz); size_t NodeMeasureLeafValue(TNode* thiz) const; - ui64 NodeSaveLeafValue(TNode* thiz, IOutputStream& os) const; + ui64 NodeSaveLeafValue(TNode* thiz, IOutputStream& os) const; virtual ui64 ArcMeasure(const TArc* thiz, size_t leftsize, size_t rightsize) const; virtual ui64 ArcSaveSelf(const TArc* thiz, IOutputStream& os) const; - ui64 ArcSave(const TArc* thiz, IOutputStream& os) const; - ui64 ArcSaveAndDestroy(const TArc* thiz, IOutputStream& os); + ui64 ArcSave(const TArc* thiz, IOutputStream& os) const; + ui64 ArcSaveAndDestroy(const TArc* thiz, IOutputStream& os); public: TCompactTrieBuilderImpl(TCompactTrieBuilderFlags flags, TPacker packer, IAllocator* alloc); @@ -83,8 +83,8 @@ public: bool FindEntry(const TSymbol* key, size_t keylen, TData* value) const; bool FindLongestPrefix(const TSymbol* key, size_t keylen, size_t* prefixlen, TData* value) const; - size_t Save(IOutputStream& os) const; - size_t SaveAndDestroy(IOutputStream& os); + size_t Save(IOutputStream& os) const; + size_t SaveAndDestroy(IOutputStream& os); void Clear(); @@ -118,8 +118,8 @@ public: virtual ~ISubtree() = default; virtual bool IsLast() const = 0; virtual ui64 Measure(const TBuilderImpl* builder) const = 0; - virtual ui64 Save(const TBuilderImpl* builder, IOutputStream& os) const = 0; - virtual ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) = 0; + virtual ui64 Save(const TBuilderImpl* builder, IOutputStream& os) const = 0; + virtual ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) = 0; virtual void Destroy(TBuilderImpl*) { } // Tries to find key in subtree. @@ -135,7 +135,7 @@ public: typedef typename TCompactVector<TArc>::const_iterator const_iterator; TArcSet() { - Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() + Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() } iterator Find(char ch); @@ -166,17 +166,17 @@ public: return builder->ArcMeasure(&(*this)[median], leftsize, rightsize); } - ui64 Save(const TBuilderImpl* builder, IOutputStream& os) const override { + ui64 Save(const TBuilderImpl* builder, IOutputStream& os) const override { return SaveRange(builder, 0, this->size(), os); } - ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { + ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { ui64 result = SaveRangeAndDestroy(builder, 0, this->size(), os); Destroy(builder); return result; } - ui64 SaveRange(const TBuilderImpl* builder, size_t from, size_t to, IOutputStream& os) const { + ui64 SaveRange(const TBuilderImpl* builder, size_t from, size_t to, IOutputStream& os) const { if (from >= to) return 0; @@ -188,7 +188,7 @@ public: return written; } - ui64 SaveRangeAndDestroy(TBuilderImpl* builder, size_t from, size_t to, IOutputStream& os) { + ui64 SaveRangeAndDestroy(TBuilderImpl* builder, size_t from, size_t to, IOutputStream& os) { if (from >= to) return 0; @@ -209,7 +209,7 @@ public: } ~TArcSet() override { - Y_ASSERT(this->empty()); + Y_ASSERT(this->empty()); } }; @@ -218,7 +218,7 @@ public: TArrayWithSizeHolder<char> Buffer; TBufferedSubtree() { - Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() + Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() } bool IsLast() const override { @@ -255,12 +255,12 @@ public: return Buffer.Size(); } - ui64 Save(const TBuilderImpl*, IOutputStream& os) const override { + ui64 Save(const TBuilderImpl*, IOutputStream& os) const override { os.Write(Buffer.Get(), Buffer.Size()); return Buffer.Size(); } - ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { + ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { ui64 result = Save(builder, os); TArrayWithSizeHolder<char>().Swap(Buffer); return result; @@ -284,7 +284,7 @@ public: Data->FileName = fileName; Data->Size = size; - Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() + Y_ASSERT(reinterpret_cast<ISubtree*>(this) == static_cast<void*>(this)); // This assumption is used in TNode::Subtree() } bool IsLast() const override { @@ -320,7 +320,7 @@ public: return Data->Size; } - ui64 Save(const TBuilderImpl*, IOutputStream& os) const override { + ui64 Save(const TBuilderImpl*, IOutputStream& os) const override { TUnbufferedFileInput is(Data->FileName); ui64 written = TransferData(&is, &os); if (written != Data->Size) @@ -328,7 +328,7 @@ public: return written; } - ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { + ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { return Save(builder, os); } }; @@ -412,7 +412,7 @@ public: ~TNode() { Subtree()->~ISubtree(); - Y_ASSERT(PayloadType == DATA_ABSENT); + Y_ASSERT(PayloadType == DATA_ABSENT); } }; @@ -457,12 +457,12 @@ bool TCompactTrieBuilder<T, D, S>::FindLongestPrefix( } template <class T, class D, class S> -size_t TCompactTrieBuilder<T, D, S>::Save(IOutputStream& os) const { +size_t TCompactTrieBuilder<T, D, S>::Save(IOutputStream& os) const { return Impl->Save(os); } template <class T, class D, class S> -size_t TCompactTrieBuilder<T, D, S>::SaveAndDestroy(IOutputStream& os) { +size_t TCompactTrieBuilder<T, D, S>::SaveAndDestroy(IOutputStream& os) { return Impl->SaveAndDestroy(os); } @@ -509,13 +509,13 @@ void TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ConvertSymbolArrayTo for (size_t i = 0; i < keylen; ++i) { TSymbol label = key[i]; for (int j = (int)NCompactTrie::ExtraBits<TSymbol>(); j >= 0; j -= 8) { - Y_ASSERT(ckeyptr < buf.Data() + buflen); + Y_ASSERT(ckeyptr < buf.Data() + buflen); *(ckeyptr++) = (char)(label >> j); } } buf.Proceed(buflen); - Y_ASSERT(ckeyptr == buf.Data() + buf.Filled()); + Y_ASSERT(ckeyptr == buf.Data() + buf.Filled()); } template <class T, class D, class S> @@ -750,7 +750,7 @@ void TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::Clear() { } template <class T, class D, class S> -size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::Save(IOutputStream& os) const { +size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::Save(IOutputStream& os) const { const size_t len = NodeMeasureSubtree(Root); if (len != NodeSaveSubtree(Root, os)) ythrow yexception() << "something wrong"; @@ -759,7 +759,7 @@ size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::Save(IOutputStream } template <class T, class D, class S> -size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::SaveAndDestroy(IOutputStream& os) { +size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::SaveAndDestroy(IOutputStream& os) { const size_t len = NodeMeasureSubtree(Root); if (len != NodeSaveSubtreeAndDestroy(Root, os)) ythrow yexception() << "something wrong"; @@ -829,12 +829,12 @@ size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeMeasureSubtree } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveSubtree(TNode* thiz, IOutputStream& os) const { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveSubtree(TNode* thiz, IOutputStream& os) const { return thiz->Subtree()->Save(this, os); } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveSubtreeAndDestroy(TNode* thiz, IOutputStream& os) { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveSubtreeAndDestroy(TNode* thiz, IOutputStream& os) { return thiz->Subtree()->SaveAndDestroy(this, os); } @@ -853,7 +853,7 @@ void TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeBufferSubtree(TN TMemoryOutput bufout(buffer.Get(), buffer.Size()); ui64 written = arcSet->Save(this, bufout); - Y_ASSERT(written == bufferLength); + Y_ASSERT(written == bufferLength); arcSet->Destroy(this); arcSet->~TArcSet(); @@ -872,7 +872,7 @@ size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeMeasureLeafVal } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveLeafValue(TNode* thiz, IOutputStream& os) const { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveLeafValue(TNode* thiz, IOutputStream& os) const { if (!thiz->IsFinal()) return 0; @@ -919,7 +919,7 @@ ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcMeasure( } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveSelf(const TArc* thiz, IOutputStream& os) const { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveSelf(const TArc* thiz, IOutputStream& os) const { using namespace NCompactTrie; ui64 written = 0; @@ -962,14 +962,14 @@ ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveSelf(const TA } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSave(const TArc* thiz, IOutputStream& os) const { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSave(const TArc* thiz, IOutputStream& os) const { ui64 written = ArcSaveSelf(thiz, os); written += NodeSaveSubtree(thiz->Node, os); return written; } template <class T, class D, class S> -ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveAndDestroy(const TArc* thiz, IOutputStream& os) { +ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveAndDestroy(const TArc* thiz, IOutputStream& os) { ui64 written = ArcSaveSelf(thiz, os); written += NodeSaveSubtreeAndDestroy(thiz->Node, os); return written; @@ -1061,13 +1061,13 @@ const typename TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::TNode* // as you expect it to, and can destroy the trie in the making. template <class TPacker> -size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalength, bool verbose /*= false*/, const TPacker& packer /*= TPacker()*/, NCompactTrie::EMinimizeMode mode) { +size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalength, bool verbose /*= false*/, const TPacker& packer /*= TPacker()*/, NCompactTrie::EMinimizeMode mode) { using namespace NCompactTrie; return CompactTrieMinimizeImpl(os, data, datalength, verbose, &packer, mode); } template <class TTrieBuilder> -size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { +size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { TBufferStream buftmp; size_t len = builder.Save(buftmp); return CompactTrieMinimize<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose); @@ -1093,27 +1093,27 @@ size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool // (there is not much difference between these papers, actually). // template <class TPacker> -size_t CompactTrieMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose /*= false*/, const TPacker& packer /*= TPacker()*/) { +size_t CompactTrieMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose /*= false*/, const TPacker& packer /*= TPacker()*/) { using namespace NCompactTrie; return CompactTrieMakeFastLayoutImpl(os, data, datalength, verbose, &packer); } template <class TTrieBuilder> -size_t CompactTrieMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { +size_t CompactTrieMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { TBufferStream buftmp; size_t len = builder.Save(buftmp); return CompactTrieMakeFastLayout<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose); } template <class TPacker> -size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose/*=false*/, const TPacker& packer/*= TPacker()*/) { +size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose/*=false*/, const TPacker& packer/*= TPacker()*/) { TBufferStream buftmp; size_t len = CompactTrieMinimize(buftmp, data, datalength, verbose, packer); return CompactTrieMakeFastLayout(os, buftmp.Buffer().Data(), len, verbose, packer); } template <class TTrieBuilder> -size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { +size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { TBufferStream buftmp; size_t len = CompactTrieMinimize(buftmp, builder, verbose); return CompactTrieMakeFastLayout<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose); diff --git a/library/cpp/containers/comptrie/comptrie_impl.h b/library/cpp/containers/comptrie/comptrie_impl.h index 607b8e5d32..f41c38311a 100644 --- a/library/cpp/containers/comptrie/comptrie_impl.h +++ b/library/cpp/containers/comptrie/comptrie_impl.h @@ -18,7 +18,7 @@ namespace NCompactTrie { Y_FORCE_INLINE size_t UnpackOffset(const char* p, size_t len); size_t MeasureOffset(size_t offset); size_t PackOffset(char* buffer, size_t offset); - static inline ui64 ArcSaveOffset(size_t offset, IOutputStream& os); + static inline ui64 ArcSaveOffset(size_t offset, IOutputStream& os); Y_FORCE_INLINE char LeapByte(const char*& datapos, const char* dataend, char label); template <class T> @@ -37,7 +37,7 @@ namespace NCompactTrie { } const size_t offsetlength = flags & MT_SIZEMASK; const size_t offset = UnpackOffset(datapos + 1, offsetlength); - Y_ASSERT(offset); + Y_ASSERT(offset); datapos += offset; } @@ -89,7 +89,7 @@ namespace NCompTriePrivate { } namespace NCompactTrie { - static inline ui64 ArcSaveOffset(size_t offset, IOutputStream& os) { + static inline ui64 ArcSaveOffset(size_t offset, IOutputStream& os) { using namespace NCompactTrie; if (!offset) @@ -127,7 +127,7 @@ namespace NCompactTrie { // These links are created during minimization: original uncompressed // tree does not need them. (If we find a way to package 3 offset lengths // into 1 byte, we could get rid of them; but it looks like they do no harm. - Y_ASSERT(datapos < dataend); + Y_ASSERT(datapos < dataend); offsetlength = flags & MT_SIZEMASK; offset = UnpackOffset(datapos, offsetlength); if (!offset) @@ -185,7 +185,7 @@ namespace NCompactTrie { template <typename TSymbol, class TPacker> Y_FORCE_INLINE bool Advance(const char*& datapos, const char* const dataend, const char*& value, TSymbol label, TPacker packer) { - Y_ASSERT(datapos < dataend); + Y_ASSERT(datapos < dataend); char flags = MT_NEXT; for (int i = (int)ExtraBits<TSymbol>(); i >= 0; i -= 8) { flags = LeapByte(datapos, dataend, (char)(label >> i)); @@ -195,7 +195,7 @@ namespace NCompactTrie { value = nullptr; - Y_ASSERT(datapos <= dataend); + Y_ASSERT(datapos <= dataend); if ((flags & MT_FINAL)) { value = datapos; datapos += packer.SkipLeaf(datapos); diff --git a/library/cpp/containers/comptrie/comptrie_trie.h b/library/cpp/containers/comptrie/comptrie_trie.h index 25a288f23d..40ec1e52b3 100644 --- a/library/cpp/containers/comptrie/comptrie_trie.h +++ b/library/cpp/containers/comptrie/comptrie_trie.h @@ -11,7 +11,7 @@ #include <util/generic/vector.h> #include <util/generic/yexception.h> #include <util/memory/blob.h> -#include <util/stream/input.h> +#include <util/stream/input.h> #include <utility> template <class T, class D, class S> @@ -54,16 +54,16 @@ protected: public: TCompactTrie() = default; - TCompactTrie(const char* d, size_t len, TPacker packer); - TCompactTrie(const char* d, size_t len) + TCompactTrie(const char* d, size_t len, TPacker packer); + TCompactTrie(const char* d, size_t len) : TCompactTrie{d, len, TPacker{}} { - } - - TCompactTrie(const TBlob& data, TPacker packer); - explicit TCompactTrie(const TBlob& data) + } + + TCompactTrie(const TBlob& data, TPacker packer); + explicit TCompactTrie(const TBlob& data) : TCompactTrie{data, TPacker{}} { - } - + } + // Skipper should be initialized with &Packer, not with &other.Packer, so you have to redefine these. TCompactTrie(const TCompactTrie& other); TCompactTrie(TCompactTrie&& other) noexcept; @@ -185,7 +185,7 @@ public: // LowerBound of X cannot be greater than X. TConstIterator UpperBound(const TKeyBuf& key) const; - void Print(IOutputStream& os); + void Print(IOutputStream& os); size_t Size() const; @@ -212,7 +212,7 @@ private: TArrayHolder<char> Storage; public: - TCompactTrieHolder(IInputStream& is, size_t len); + TCompactTrieHolder(IInputStream& is, size_t len); }; //------------------------// @@ -308,7 +308,7 @@ void TCompactTrie<T, D, S>::Init(const TBlob& data, TPacker packer) { const char* emptypos = datapos; char flags = LeapByte(emptypos, dataend, 0); if (emptypos && (flags & MT_FINAL)) { - Y_ASSERT(emptypos <= dataend); + Y_ASSERT(emptypos <= dataend); EmptyValue = emptypos; } } @@ -375,7 +375,7 @@ bool TCompactTrie<T, D, S>::FindTails(const TSymbol* key, size_t keylen, TCompac if (key == keyend) { if (datapos) { - Y_ASSERT(datapos >= datastart); + Y_ASSERT(datapos >= datastart); res = TCompactTrie<T, D, S>(TBlob::NoCopy(datapos, dataend - datapos), value); } else { res = TCompactTrie<T, D, S>(value); @@ -406,7 +406,7 @@ inline bool TCompactTrie<T, D, S>::FindTails(TSymbol label, TCompactTrie<T, D, S return false; if (datapos) { - Y_ASSERT(datapos >= datastart); + Y_ASSERT(datapos >= datastart); res = TCompactTrie<T, D, S>(TBlob::NoCopy(datapos, dataend - datapos), value); } else { res = TCompactTrie<T, D, S>(value); @@ -452,7 +452,7 @@ typename TCompactTrie<T, D, S>::TConstIterator TCompactTrie<T, D, S>::UpperBound } template <class T, class D, class S> -void TCompactTrie<T, D, S>::Print(IOutputStream& os) { +void TCompactTrie<T, D, S>::Print(IOutputStream& os) { typedef typename ::TCompactTrieKeySelector<T>::TKeyBuf TSBuffer; for (TConstIterator it = Begin(); it != End(); ++it) { os << TSBuffer((*it).first.data(), (*it).first.size()) << "\t" << (*it).second << Endl; @@ -504,7 +504,7 @@ bool TCompactTrie<T, D, S>::LookupLongestPrefix(const TSymbol* key, size_t keyle return found; // no such arc } - Y_ASSERT(datapos <= dataend); + Y_ASSERT(datapos <= dataend); if ((flags & MT_FINAL)) { prefixLen = keylen - (keyend - key) - (i ? 1 : 0); valuepos = datapos; @@ -558,7 +558,7 @@ void TCompactTrie<T, D, S>::LookupPhrases( // TCompactTrieHolder template <class T, class D, class S> -TCompactTrieHolder<T, D, S>::TCompactTrieHolder(IInputStream& is, size_t len) +TCompactTrieHolder<T, D, S>::TCompactTrieHolder(IInputStream& is, size_t len) : Storage(new char[len]) { if (is.Load(Storage.Get(), len) != len) { diff --git a/library/cpp/containers/comptrie/comptrie_ut.cpp b/library/cpp/containers/comptrie/comptrie_ut.cpp index 6095f78cf8..74bee09b5d 100644 --- a/library/cpp/containers/comptrie/comptrie_ut.cpp +++ b/library/cpp/containers/comptrie/comptrie_ut.cpp @@ -1,7 +1,7 @@ #include <util/random/shuffle.h> #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <utility> #include <util/charset/wide.h> @@ -105,7 +105,7 @@ private: UNIT_TEST(TestFirstSymbolIteratorChar32); UNIT_TEST(TestArrayPacker); - + UNIT_TEST(TestBuilderFindLongestPrefix); UNIT_TEST(TestBuilderFindLongestPrefixWithEmptyValue); @@ -118,7 +118,7 @@ private: static const char* SampleData[]; template <class T> - void CreateTrie(IOutputStream& out, bool minimize, bool useFastLayout); + void CreateTrie(IOutputStream& out, bool minimize, bool useFastLayout); template <class T> void CheckData(const char* src, size_t len); @@ -241,7 +241,7 @@ public: void TestFirstSymbolIterator32(); void TestFirstSymbolIteratorChar32(); - void TestArrayPacker(); + void TestArrayPacker(); void TestBuilderFindLongestPrefix(); void TestBuilderFindLongestPrefix(size_t keysCount, double branchProbability, bool isPrefixGrouped, bool hasEmptyKey); @@ -297,17 +297,17 @@ typename TCompactTrie<T>::TKey MakeWideKey(const TStringBuf& buf) { } template <class T> -void TCompactTrieTest::CreateTrie(IOutputStream& out, bool minimize, bool useFastLayout) { +void TCompactTrieTest::CreateTrie(IOutputStream& out, bool minimize, bool useFastLayout) { TCompactTrieBuilder<T> builder; - for (auto& i : SampleData) { - size_t len = strlen(i); + for (auto& i : SampleData) { + size_t len = strlen(i); - builder.Add(MakeWideKey<T>(i, len), len * 2); + builder.Add(MakeWideKey<T>(i, len), len * 2); } TBufferOutput tmp2; - IOutputStream& currentOutput = useFastLayout ? tmp2 : out; + IOutputStream& currentOutput = useFastLayout ? tmp2 : out; if (minimize) { TBufferOutput buftmp; builder.Save(buftmp); @@ -361,14 +361,14 @@ template <class T> void TCompactTrieTest::CheckData(const char* data, size_t datalen) { TCompactTrie<T> trie(data, datalen); - UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(SampleData), trie.Size()); + UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(SampleData), trie.Size()); - for (auto& i : SampleData) { - size_t len = strlen(i); + for (auto& i : SampleData) { + size_t len = strlen(i); ui64 value = 0; size_t prefixLen = 0; - typename TCompactTrie<T>::TKey key = MakeWideKey<T>(i, len); + typename TCompactTrie<T>::TKey key = MakeWideKey<T>(i, len); UNIT_ASSERT(trie.Find(key, &value)); UNIT_ASSERT_EQUAL(len * 2, value); UNIT_ASSERT(trie.FindLongestPrefix(key, &prefixLen, &value)); @@ -376,7 +376,7 @@ void TCompactTrieTest::CheckData(const char* data, size_t datalen) { UNIT_ASSERT_EQUAL(len * 2, value); TString badkey("bb"); - badkey += i; + badkey += i; key = MakeWideKey<T>(badkey); UNIT_ASSERT(!trie.Find(key)); value = 123; @@ -386,7 +386,7 @@ void TCompactTrieTest::CheckData(const char* data, size_t datalen) { UNIT_ASSERT_EQUAL(1, prefixLen); UNIT_ASSERT_EQUAL(2, value); - badkey = i; + badkey = i; badkey += "x"; key = MakeWideKey<T>(badkey); UNIT_ASSERT(!trie.Find(key)); @@ -425,10 +425,10 @@ void TCompactTrieTest::CheckIterator(const char* data, size_t datalen) { typedef typename TCompactTrie<T>::TValueType TValue; TMap<TKey, ui64> stored; - for (auto& i : SampleData) { - size_t len = strlen(i); + for (auto& i : SampleData) { + size_t len = strlen(i); - stored[MakeWideKey<T>(i, len)] = len * 2; + stored[MakeWideKey<T>(i, len)] = len * 2; } TCompactTrie<T> trie(data, datalen); @@ -567,7 +567,7 @@ void TCompactTrieTest::TestPhraseSearch() { TBufferOutput bufout; TCompactTrieBuilder<char> builder; - for (size_t i = 0; i < Y_ARRAY_SIZE(phrases); i++) { + for (size_t i = 0; i < Y_ARRAY_SIZE(phrases); i++) { builder.Add(phrases[i], strlen(phrases[i]), i); } builder.Save(bufout); @@ -576,8 +576,8 @@ void TCompactTrieTest::TestPhraseSearch() { TVector<TCompactTrie<char>::TPhraseMatch> matches; trie.FindPhrases(goodphrase, strlen(goodphrase), matches); - UNIT_ASSERT(matches.size() == Y_ARRAY_SIZE(phrases)); - for (size_t i = 0; i < Y_ARRAY_SIZE(phrases); i++) { + UNIT_ASSERT(matches.size() == Y_ARRAY_SIZE(phrases)); + for (size_t i = 0; i < Y_ARRAY_SIZE(phrases); i++) { UNIT_ASSERT(matches[i].first == strlen(phrases[i])); UNIT_ASSERT(matches[i].second == i); } @@ -734,11 +734,11 @@ void TCompactTrieTest::TestFindTailsImpl(const TString& prefix) { TMap<TString, ui64> input; - for (auto& i : SampleData) { + for (auto& i : SampleData) { TString temp = i; ui64 val = temp.size() * 2; builder.Add(temp.data(), temp.size(), val); - if (temp.StartsWith(prefix)) { + if (temp.StartsWith(prefix)) { input[temp.substr(prefix.size())] = val; } } @@ -789,10 +789,10 @@ void TCompactTrieTest::TestPrefixGrouped() { "Tumen", }; - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { ui32 val = strlen(data[i]) + 1; b1.Add(data[i], strlen(data[i]), val); - for (size_t j = 0; j < Y_ARRAY_SIZE(data); ++j) { + for (size_t j = 0; j < Y_ARRAY_SIZE(data); ++j) { ui32 mustHave = strlen(data[j]) + 1; ui32 found = 0; if (j <= i) { @@ -813,10 +813,10 @@ void TCompactTrieTest::TestPrefixGrouped() { //t1.Print(Cerr); - for (auto& i : data) { + for (auto& i : data) { ui32 v; - UNIT_ASSERT(t1.Find(i, strlen(i), &v)); - UNIT_ASSERT_VALUES_EQUAL(strlen(i) + 1, v); + UNIT_ASSERT(t1.Find(i, strlen(i), &v)); + UNIT_ASSERT_VALUES_EQUAL(strlen(i) + 1, v); } } @@ -831,7 +831,7 @@ void TCompactTrieTest::CrashTestPrefixGrouped() { }; bool wasException = false; try { - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { builder.Add(data[i], strlen(data[i]), i + 1); } } catch (const yexception& e) { @@ -947,7 +947,7 @@ void TCompactTrieTest::TestUniqueImpl(bool isPrefixGrouped) { "Fry", "Tumen", }; - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { UNIT_ASSERT_C(builder.Add(data[i], strlen(data[i]), i + 1), i); } bool wasException = false; @@ -973,7 +973,7 @@ void TCompactTrieTest::TestAddRetValue() { "Fry", "Tumen", }; - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { UNIT_ASSERT(builder.Add(data[i], strlen(data[i]), i + 1)); UNIT_ASSERT(!builder.Add(data[i], strlen(data[i]), i + 2)); ui32 value; @@ -995,10 +995,10 @@ void TCompactTrieTest::TestClear() { "Fry", "Tumen", }; - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { builder.Add(data[i], strlen(data[i]), i + 1); } - UNIT_ASSERT(builder.GetEntryCount() == Y_ARRAY_SIZE(data)); + UNIT_ASSERT(builder.GetEntryCount() == Y_ARRAY_SIZE(data)); builder.Clear(); UNIT_ASSERT(builder.GetEntryCount() == 0); UNIT_ASSERT(builder.GetNodeCount() == 1); @@ -1105,7 +1105,7 @@ void TCompactTrieTest::TestTrieSet() { // Tests for trie with vector (list, set) values TVector<TUtf16String> TCompactTrieTest::GetSampleKeys(size_t nKeys) const { - Y_ASSERT(nKeys <= 10); + Y_ASSERT(nKeys <= 10); TString sampleKeys[] = {"a", "b", "ac", "bd", "abe", "bcf", "deg", "ah", "xy", "abc"}; TVector<TUtf16String> result; for (size_t i = 0; i < nKeys; i++) @@ -1332,7 +1332,7 @@ void TCompactTrieTest::TestSearchIterImpl() { TStringBuf("abbbc"), TStringBuf("bdfaa"), }; - for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { + for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) { builder.Add(TConvertKey<TChar>::Convert(data[i]), i + 1); } builder.Save(buffer); @@ -1434,37 +1434,37 @@ void TCompactTrieTest::TestFirstSymbolIteratorChar32() { } -void TCompactTrieTest::TestArrayPacker() { +void TCompactTrieTest::TestArrayPacker() { using TDataInt = std::array<int, 2>; const std::pair<TString, TDataInt> dataXxx{"xxx", {{15, 16}}}; const std::pair<TString, TDataInt> dataYyy{"yyy", {{20, 30}}}; - - TCompactTrieBuilder<char, TDataInt> trieBuilderOne; - trieBuilderOne.Add(dataXxx.first, dataXxx.second); - trieBuilderOne.Add(dataYyy.first, dataYyy.second); - - TBufferOutput bufferOne; - trieBuilderOne.Save(bufferOne); - - const TCompactTrie<char, TDataInt> trieOne(bufferOne.Buffer().Data(), bufferOne.Buffer().Size()); - UNIT_ASSERT_VALUES_EQUAL(dataXxx.second, trieOne.Get(dataXxx.first)); - UNIT_ASSERT_VALUES_EQUAL(dataYyy.second, trieOne.Get(dataYyy.first)); - + + TCompactTrieBuilder<char, TDataInt> trieBuilderOne; + trieBuilderOne.Add(dataXxx.first, dataXxx.second); + trieBuilderOne.Add(dataYyy.first, dataYyy.second); + + TBufferOutput bufferOne; + trieBuilderOne.Save(bufferOne); + + const TCompactTrie<char, TDataInt> trieOne(bufferOne.Buffer().Data(), bufferOne.Buffer().Size()); + UNIT_ASSERT_VALUES_EQUAL(dataXxx.second, trieOne.Get(dataXxx.first)); + UNIT_ASSERT_VALUES_EQUAL(dataYyy.second, trieOne.Get(dataYyy.first)); + using TDataStroka = std::array<TString, 2>; const std::pair<TString, TDataStroka> dataZzz{"zzz", {{"hello", "there"}}}; const std::pair<TString, TDataStroka> dataWww{"www", {{"half", "life"}}}; - - TCompactTrieBuilder<char, TDataStroka> trieBuilderTwo; - trieBuilderTwo.Add(dataZzz.first, dataZzz.second); - trieBuilderTwo.Add(dataWww.first, dataWww.second); - - TBufferOutput bufferTwo; - trieBuilderTwo.Save(bufferTwo); - - const TCompactTrie<char, TDataStroka> trieTwo(bufferTwo.Buffer().Data(), bufferTwo.Buffer().Size()); - UNIT_ASSERT_VALUES_EQUAL(dataZzz.second, trieTwo.Get(dataZzz.first)); - UNIT_ASSERT_VALUES_EQUAL(dataWww.second, trieTwo.Get(dataWww.first)); -} + + TCompactTrieBuilder<char, TDataStroka> trieBuilderTwo; + trieBuilderTwo.Add(dataZzz.first, dataZzz.second); + trieBuilderTwo.Add(dataWww.first, dataWww.second); + + TBufferOutput bufferTwo; + trieBuilderTwo.Save(bufferTwo); + + const TCompactTrie<char, TDataStroka> trieTwo(bufferTwo.Buffer().Data(), bufferTwo.Buffer().Size()); + UNIT_ASSERT_VALUES_EQUAL(dataZzz.second, trieTwo.Get(dataZzz.first)); + UNIT_ASSERT_VALUES_EQUAL(dataWww.second, trieTwo.Get(dataWww.first)); +} void TCompactTrieTest::TestBuilderFindLongestPrefix() { const size_t sizes[] = {10, 100}; @@ -1517,7 +1517,7 @@ void TCompactTrieTest::TestBuilderFindLongestPrefix(size_t keysCount, double bra } else { size_t max = 0; for (size_t k = 0; k < i; ++k) - if (keys[k].Size() < otherKey.Size() && keys[k].Size() > max && otherKey.StartsWith(keys[k])) + if (keys[k].Size() < otherKey.Size() && keys[k].Size() > max && otherKey.StartsWith(keys[k])) max = keys[k].Size(); expectedSize = max; } diff --git a/library/cpp/containers/comptrie/loader/loader.h b/library/cpp/containers/comptrie/loader/loader.h index 478c820abc..ee10e9b451 100644 --- a/library/cpp/containers/comptrie/loader/loader.h +++ b/library/cpp/containers/comptrie/loader/loader.h @@ -12,7 +12,7 @@ TrieType LoadTrieFromArchive(const TString& key, bool ignoreErrors = false) { TArchiveReader archive(TBlob::NoCopy(data, sizeof(data))); if (archive.Has(key)) { - TAutoPtr<IInputStream> trie = archive.ObjectByKey(key); + TAutoPtr<IInputStream> trie = archive.ObjectByKey(key); return TrieType(TBlob::FromStream(*trie)); } if (!ignoreErrors) { diff --git a/library/cpp/containers/comptrie/loader/loader_ut.cpp b/library/cpp/containers/comptrie/loader/loader_ut.cpp index f146bfaff5..345063a31e 100644 --- a/library/cpp/containers/comptrie/loader/loader_ut.cpp +++ b/library/cpp/containers/comptrie/loader/loader_ut.cpp @@ -10,8 +10,8 @@ namespace { }; } -Y_UNIT_TEST_SUITE(ArchiveLoaderTests) { - Y_UNIT_TEST(BaseTest) { +Y_UNIT_TEST_SUITE(ArchiveLoaderTests) { + Y_UNIT_TEST(BaseTest) { TDummyTrie trie = LoadTrieFromArchive<TDummyTrie>("/dummy.trie", DATA, true); UNIT_ASSERT_EQUAL(trie.Size(), 3); diff --git a/library/cpp/containers/comptrie/make_fast_layout.h b/library/cpp/containers/comptrie/make_fast_layout.h index 6bb4ff0d55..b8fab5d65b 100644 --- a/library/cpp/containers/comptrie/make_fast_layout.h +++ b/library/cpp/containers/comptrie/make_fast_layout.h @@ -3,7 +3,7 @@ #include "leaf_skipper.h" #include <cstddef> -class IOutputStream; +class IOutputStream; namespace NCompactTrie { // Return value: size of the resulting trie. diff --git a/library/cpp/containers/comptrie/minimize.h b/library/cpp/containers/comptrie/minimize.h index 5973564844..baaa431d04 100644 --- a/library/cpp/containers/comptrie/minimize.h +++ b/library/cpp/containers/comptrie/minimize.h @@ -3,7 +3,7 @@ #include "leaf_skipper.h" #include <cstddef> -class IOutputStream; +class IOutputStream; namespace NCompactTrie { size_t MeasureOffset(size_t offset); diff --git a/library/cpp/containers/comptrie/write_trie_backwards.h b/library/cpp/containers/comptrie/write_trie_backwards.h index 78e1e6ade4..634e6b811a 100644 --- a/library/cpp/containers/comptrie/write_trie_backwards.h +++ b/library/cpp/containers/comptrie/write_trie_backwards.h @@ -17,7 +17,7 @@ namespace NCompactTrie { struct TOpaqueTrie; - size_t WriteTrieBackwards(IOutputStream& os, TReverseNodeEnumerator& enumerator, bool verbose); - size_t WriteTrieBackwardsNoAlloc(IOutputStream& os, TReverseNodeEnumerator& enumerator, TOpaqueTrie& trie, EMinimizeMode mode); + size_t WriteTrieBackwards(IOutputStream& os, TReverseNodeEnumerator& enumerator, bool verbose); + size_t WriteTrieBackwardsNoAlloc(IOutputStream& os, TReverseNodeEnumerator& enumerator, TOpaqueTrie& trie, EMinimizeMode mode); } diff --git a/library/cpp/containers/intrusive_avl_tree/avltree.h b/library/cpp/containers/intrusive_avl_tree/avltree.h index 717c18cb14..a58c63b07c 100644 --- a/library/cpp/containers/intrusive_avl_tree/avltree.h +++ b/library/cpp/containers/intrusive_avl_tree/avltree.h @@ -28,11 +28,11 @@ class TAvlTree: public TNonCopyable { } inline bool IsEnd() const noexcept { - return Ptr_ == nullptr; + return Ptr_ == nullptr; } inline bool IsBegin() const noexcept { - return Ptr_ == nullptr; + return Ptr_ == nullptr; } inline bool IsFirst() const noexcept { @@ -107,10 +107,10 @@ class TAvlTree: public TNonCopyable { } inline static TIteratorBase FindPrev(TTreeItem* el) noexcept { - if (el->Left_ != nullptr) { + if (el->Left_ != nullptr) { el = el->Left_; - while (el->Right_ != nullptr) { + while (el->Right_ != nullptr) { el = el->Right_; } } else { @@ -118,7 +118,7 @@ class TAvlTree: public TNonCopyable { TTreeItem* last = el; el = el->Parent_; - if (el == nullptr || el->Right_ == last) { + if (el == nullptr || el->Right_ == last) { break; } } @@ -128,7 +128,7 @@ class TAvlTree: public TNonCopyable { } static TTreeItem* FindNext(TTreeItem* el) { - if (el->Right_ != nullptr) { + if (el->Right_ != nullptr) { el = el->Right_; while (el->Left_) { @@ -139,7 +139,7 @@ class TAvlTree: public TNonCopyable { TTreeItem* last = el; el = el->Parent_; - if (el == nullptr || el->Left_ == last) { + if (el == nullptr || el->Left_ == last) { break; } } @@ -202,14 +202,14 @@ public: el->Tree_ = this; TTreeItem* curEl = Root_; - TTreeItem* parentEl = nullptr; - TTreeItem* lastLess = nullptr; + TTreeItem* parentEl = nullptr; + TTreeItem* lastLess = nullptr; while (true) { - if (curEl == nullptr) { + if (curEl == nullptr) { AttachRebal(el, parentEl, lastLess); - if (lastFound != nullptr) { + if (lastFound != nullptr) { *lastFound = el; } @@ -223,11 +223,11 @@ public: parentEl = curEl; curEl = curEl->Right_; } else { - if (lastFound != nullptr) { + if (lastFound != nullptr) { *lastFound = curEl; } - return nullptr; + return nullptr; } } } @@ -245,12 +245,12 @@ public: } } - return nullptr; + return nullptr; } inline T* LowerBound(const TTreeItem* el) const noexcept { TTreeItem* curEl = Root_; - TTreeItem* lowerBound = nullptr; + TTreeItem* lowerBound = nullptr; while (curEl) { if (Compare(*el, *curEl)) { @@ -271,11 +271,11 @@ public: return this->EraseImpl(el); } - return nullptr; + return nullptr; } inline T* EraseImpl(TTreeItem* el) noexcept { - el->Tree_ = nullptr; + el->Tree_ = nullptr; TTreeItem* replacement; TTreeItem* fixfrom; @@ -330,10 +330,10 @@ public: Tail_ = el->Parent_; } - RemoveEl(el, nullptr); + RemoveEl(el, nullptr); } - if (fixfrom == nullptr) { + if (fixfrom == nullptr) { return AsT(el); } @@ -422,7 +422,7 @@ public: } inline iterator End() noexcept { - return iterator(nullptr, this); + return iterator(nullptr, this); } inline iterator begin() noexcept { @@ -507,7 +507,7 @@ private: } } - if (ggp == nullptr) { + if (ggp == nullptr) { Root_ = b; } else if (ggp->Left_ == gp) { ggp->Left_ = b; @@ -522,25 +522,25 @@ private: c->Parent_ = b; a->Left_ = t1; - if (t1 != nullptr) { + if (t1 != nullptr) { t1->Parent_ = a; } a->Right_ = t2; - if (t2 != nullptr) { + if (t2 != nullptr) { t2->Parent_ = a; } c->Left_ = t3; - if (t3 != nullptr) { + if (t3 != nullptr) { t3->Parent_ = c; } c->Right_ = t4; - if (t4 != nullptr) { + if (t4 != nullptr) { t4->Parent_ = c; } @@ -584,13 +584,13 @@ private: long lheight, rheight, balanceProp; TTreeItem* gp; - if (el == nullptr || el->Parent_ == nullptr || el->Parent_->Parent_ == nullptr) { - return nullptr; + if (el == nullptr || el->Parent_ == nullptr || el->Parent_->Parent_ == nullptr) { + return nullptr; } gp = el->Parent_->Parent_; - while (gp != nullptr) { + while (gp != nullptr) { lheight = gp->Left_ ? gp->Left_->Height_ : 0; rheight = gp->Right_ ? gp->Right_->Height_ : 0; balanceProp = lheight - rheight; @@ -603,12 +603,12 @@ private: gp = gp->Parent_; } - return nullptr; + return nullptr; } inline TTreeItem* FindFirstUnbalEl(TTreeItem* el) noexcept { - if (el == nullptr) { - return nullptr; + if (el == nullptr) { + return nullptr; } while (el) { @@ -623,7 +623,7 @@ private: el = el->Parent_; } - return nullptr; + return nullptr; } inline void ReplaceEl(TTreeItem* el, TTreeItem* replacement) noexcept { @@ -680,11 +680,11 @@ private: inline void AttachRebal(TTreeItem* el, TTreeItem* parentEl, TTreeItem* lastLess) { el->Parent_ = parentEl; - el->Left_ = nullptr; - el->Right_ = nullptr; + el->Left_ = nullptr; + el->Right_ = nullptr; el->Height_ = 1; - if (parentEl != nullptr) { + if (parentEl != nullptr) { if (lastLess == parentEl) { parentEl->Left_ = el; } else { @@ -707,7 +707,7 @@ private: TTreeItem* ub = FindFirstUnbalGP(el); - if (ub != nullptr) { + if (ub != nullptr) { Rebalance(ub); } } diff --git a/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp b/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp index 737da8e1e2..cab2365cce 100644 --- a/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp +++ b/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp @@ -59,7 +59,7 @@ void TAvlTreeTest::TestLowerBound() { TIt it_large(1000); UNIT_ASSERT_EQUAL(its.LowerBound(&it3), &it3); UNIT_ASSERT_EQUAL(its.LowerBound(&it_zero), &it5); - UNIT_ASSERT_EQUAL(its.LowerBound(&it_large), nullptr); + UNIT_ASSERT_EQUAL(its.LowerBound(&it_large), nullptr); } void TAvlTreeTest::TestIterator() { @@ -81,7 +81,7 @@ void TAvlTreeTest::TestIterator() { its.Insert(&it2); TVector<int> res; - for (const TIt& i : its) { + for (const TIt& i : its) { res.push_back(i.Val); } @@ -89,7 +89,7 @@ void TAvlTreeTest::TestIterator() { UNIT_ASSERT_EQUAL(res, expected); res.clear(); - for (TIt& i : its) { + for (TIt& i : its) { res.push_back(i.Val); } UNIT_ASSERT_EQUAL(res, expected); diff --git a/library/cpp/containers/intrusive_rb_tree/rb_tree.h b/library/cpp/containers/intrusive_rb_tree/rb_tree.h index 579b1d6fc3..0259452a14 100644 --- a/library/cpp/containers/intrusive_rb_tree/rb_tree.h +++ b/library/cpp/containers/intrusive_rb_tree/rb_tree.h @@ -24,28 +24,28 @@ struct TRbTreeNodeBase { inline void ReInitNode() noexcept { Color_ = RBTreeBlack; - Parent_ = nullptr; - Left_ = nullptr; - Right_ = nullptr; + Parent_ = nullptr; + Left_ = nullptr; + Right_ = nullptr; Children_ = 1; } static TBasePtr MinimumNode(TBasePtr x) { - while (x->Left_ != nullptr) + while (x->Left_ != nullptr) x = x->Left_; return x; } static TBasePtr MaximumNode(TBasePtr x) { - while (x->Right_ != nullptr) + while (x->Right_ != nullptr) x = x->Right_; return x; } static TBasePtr ByIndex(TBasePtr x, size_t index) { - if (x->Left_ != nullptr) { + if (x->Left_ != nullptr) { if (index < x->Left_->Children_) return ByIndex(x->Left_, index); index -= x->Left_->Children_; @@ -178,7 +178,7 @@ public: class TRealNode: public TNodeBase { public: inline TRealNode() - : Tree_(nullptr) + : Tree_(nullptr) { } @@ -190,7 +190,7 @@ public: if (Tree_) { Tree_->EraseImpl(this); ReInitNode(); - Tree_ = nullptr; + Tree_ = nullptr; } } @@ -221,7 +221,7 @@ public: inline void Init() noexcept { Data_.Color_ = RBTreeRed; - Data_.Parent_ = nullptr; + Data_.Parent_ = nullptr; Data_.Left_ = &Data_; Data_.Right_ = &Data_; Data_.Children_ = 0; @@ -229,7 +229,7 @@ public: struct TDestroy { inline void operator()(TValue& v) const noexcept { - v.SetRbTreeParent(nullptr); + v.SetRbTreeParent(nullptr); v.ReInitNode(); } }; @@ -291,7 +291,7 @@ public: TBasePtr y = &this->Data_; TBasePtr x = Root(); - while (x != nullptr) { + while (x != nullptr) { ++(x->Children_); y = x; @@ -332,10 +332,10 @@ public: template <class T1> inline TValue* Find(const T1& k) const { - TBasePtr y = nullptr; + TBasePtr y = nullptr; TBasePtr x = Root(); // Current node. - while (x != nullptr) + while (x != nullptr) if (!KeyCompare_(ValueNode(x), k)) y = x, x = LeftNode(x); else @@ -343,7 +343,7 @@ public: if (y) { if (KeyCompare_(k, ValueNode(y))) { - y = nullptr; + y = nullptr; } } @@ -375,7 +375,7 @@ public: TBasePtr y = const_cast<TBasePtr>(&this->Data_); /* Last node which is not less than k. */ TBasePtr x = Root(); /* Current node. */ - while (x != nullptr) + while (x != nullptr) if (!KeyCompare_(ValueNode(x), k)) y = x, x = LeftNode(x); else @@ -389,7 +389,7 @@ public: TBasePtr y = const_cast<TBasePtr>(&this->Data_); /* Last node which is greater than k. */ TBasePtr x = Root(); /* Current node. */ - while (x != nullptr) + while (x != nullptr) if (KeyCompare_(k, ValueNode(x))) y = x, x = LeftNode(x); else @@ -402,11 +402,11 @@ public: inline size_t LessCount(const T1& k) const { auto x = LowerBound(k); if (x == const_cast<TBasePtr>(&this->Data_)) { - if (const auto root = Root()) { - return root->Children_; - } else { - return 0; - } + if (const auto root = Root()) { + return root->Children_; + } else { + return 0; + } } else { return GetIndex(x); } @@ -439,9 +439,9 @@ public: private: // CRP 7/10/00 inserted argument on_right, which is another hint (meant to // act like on_left and ignore a portion of the if conditions -- specify - // on_right != nullptr to bypass comparison as false or on_left != nullptr to bypass + // on_right != nullptr to bypass comparison as false or on_left != nullptr to bypass // comparison as true) - TIterator InsertImpl(TRbTreeNodeBase* parent, TRbTreeNodeBase* val, TRbTreeNodeBase* on_left = nullptr, TRbTreeNodeBase* on_right = nullptr) { + TIterator InsertImpl(TRbTreeNodeBase* parent, TRbTreeNodeBase* val, TRbTreeNodeBase* on_left = nullptr, TRbTreeNodeBase* on_right = nullptr) { ValueNode(val).SetRbTreeParent(this); TBasePtr new_node = val; @@ -450,10 +450,10 @@ private: // also makes LeftMost() = new_node Root() = new_node; RightMost() = new_node; - } else if (on_right == nullptr && - // If on_right != nullptr, the remainder fails to false - (on_left != nullptr || - // If on_left != nullptr, the remainder succeeds to true + } else if (on_right == nullptr && + // If on_right != nullptr, the remainder fails to false + (on_left != nullptr || + // If on_left != nullptr, the remainder succeeds to true KeyCompare_(ValueNode(val), ValueNode(parent)))) { LeftNode(parent) = new_node; @@ -532,7 +532,7 @@ template <class TDummy> void TRbGlobal<TDummy>::RotateLeft(TRbTreeNodeBase* x, TRbTreeNodeBase*& root) { TRbTreeNodeBase* y = x->Right_; x->Right_ = y->Left_; - if (y->Left_ != nullptr) + if (y->Left_ != nullptr) y->Left_->Parent_ = x; y->Parent_ = x->Parent_; @@ -552,7 +552,7 @@ template <class TDummy> void TRbGlobal<TDummy>::RotateRight(TRbTreeNodeBase* x, TRbTreeNodeBase*& root) { TRbTreeNodeBase* y = x->Left_; x->Left_ = y->Right_; - if (y->Right_ != nullptr) + if (y->Right_ != nullptr) y->Right_->Parent_ = x; y->Parent_ = x->Parent_; @@ -633,7 +633,7 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z, TRbTreeNodeBase* x; TRbTreeNodeBase* x_parent; - if (y->Left_ == nullptr) // z has at most one non-null child. y == z. + if (y->Left_ == nullptr) // z has at most one non-null child. y == z. x = y->Right_; // x might be null. else { if (y->Right_ == nullptr) // z has exactly one non-null child. y == z. @@ -691,14 +691,14 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z, } if (leftmost == z) { - if (z->Right_ == nullptr) // z->mLeft must be null also + if (z->Right_ == nullptr) // z->mLeft must be null also leftmost = z->Parent_; // makes leftmost == _M_header if z == root else leftmost = TRbTreeNodeBase::MinimumNode(x); } if (rightmost == z) { - if (z->Left_ == nullptr) // z->mRight must be null also + if (z->Left_ == nullptr) // z->mRight must be null also rightmost = z->Parent_; // makes rightmost == _M_header if z == root else // x == z->mLeft @@ -707,7 +707,7 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z, } if (y->Color_ != RBTreeRed) { - while (x != root && (x == nullptr || x->Color_ == RBTreeBlack)) + while (x != root && (x == nullptr || x->Color_ == RBTreeBlack)) if (x == x_parent->Left_) { TRbTreeNodeBase* w = x_parent->Right_; if (w->Color_ == RBTreeRed) { @@ -716,9 +716,9 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z, RotateLeft(x_parent, root); w = x_parent->Right_; } - if ((w->Left_ == nullptr || + if ((w->Left_ == nullptr || w->Left_->Color_ == RBTreeBlack) && - (w->Right_ == nullptr || + (w->Right_ == nullptr || w->Right_->Color_ == RBTreeBlack)) { w->Color_ = RBTreeRed; @@ -748,9 +748,9 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z, RotateRight(x_parent, root); w = x_parent->Left_; } - if ((w->Right_ == nullptr || + if ((w->Right_ == nullptr || w->Right_->Color_ == RBTreeBlack) && - (w->Left_ == nullptr || + (w->Left_ == nullptr || w->Left_->Color_ == RBTreeBlack)) { w->Color_ = RBTreeRed; @@ -782,7 +782,7 @@ template <class TDummy> TRbTreeNodeBase* TRbGlobal<TDummy>::DecrementNode(TRbTreeNodeBase* Node_) { if (Node_->Color_ == RBTreeRed && Node_->Parent_->Parent_ == Node_) Node_ = Node_->Right_; - else if (Node_->Left_ != nullptr) { + else if (Node_->Left_ != nullptr) { Node_ = TRbTreeNodeBase::MaximumNode(Node_->Left_); } else { TBasePtr y = Node_->Parent_; @@ -797,7 +797,7 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::DecrementNode(TRbTreeNodeBase* Node_) { template <class TDummy> TRbTreeNodeBase* TRbGlobal<TDummy>::IncrementNode(TRbTreeNodeBase* Node_) { - if (Node_->Right_ != nullptr) { + if (Node_->Right_ != nullptr) { Node_ = TRbTreeNodeBase::MinimumNode(Node_->Right_); } else { TBasePtr y = Node_->Parent_; diff --git a/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp b/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp index 6ee9acbf48..c34ed1fd9b 100644 --- a/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp +++ b/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp @@ -46,7 +46,7 @@ class TRedBlackTreeTest: public TTestBase { UNIT_TEST(TestCheckChildrenAfterErase) UNIT_TEST(TestGettingIndexWithDifferentValuesAfterErase) UNIT_TEST(TestGettingIndexWithEqualValues) - UNIT_TEST(TestLessCountOnEmptyTree) + UNIT_TEST(TestLessCountOnEmptyTree) UNIT_TEST_SUITE_END(); private: @@ -288,11 +288,11 @@ private: UNIT_ASSERT(tree.Empty()); } - - inline void TestLessCountOnEmptyTree() { - TTree tree; - UNIT_ASSERT_VALUES_EQUAL(0, tree.LessCount(TNode(1))); - } + + inline void TestLessCountOnEmptyTree() { + TTree tree; + UNIT_ASSERT_VALUES_EQUAL(0, tree.LessCount(TNode(1))); + } }; UNIT_TEST_SUITE_REGISTRATION(TRedBlackTreeTest); diff --git a/library/cpp/containers/ring_buffer/ring_buffer.cpp b/library/cpp/containers/ring_buffer/ring_buffer.cpp index f603db7283..799dad631b 100644 --- a/library/cpp/containers/ring_buffer/ring_buffer.cpp +++ b/library/cpp/containers/ring_buffer/ring_buffer.cpp @@ -1 +1 @@ -#include "ring_buffer.h" +#include "ring_buffer.h" diff --git a/library/cpp/containers/ring_buffer/ring_buffer.h b/library/cpp/containers/ring_buffer/ring_buffer.h index d4eca72b34..41220dcf6b 100644 --- a/library/cpp/containers/ring_buffer/ring_buffer.h +++ b/library/cpp/containers/ring_buffer/ring_buffer.h @@ -37,12 +37,12 @@ public: } const T& operator[](size_t index) const { - Y_ASSERT(IsAvail(index)); + Y_ASSERT(IsAvail(index)); return Items[RealIndex(index)]; } T& operator[](size_t index) { - Y_ASSERT(IsAvail(index)); + Y_ASSERT(IsAvail(index)); return Items[RealIndex(index)]; } diff --git a/library/cpp/containers/ring_buffer/ya.make b/library/cpp/containers/ring_buffer/ya.make index 6d9967ba43..51333978f7 100644 --- a/library/cpp/containers/ring_buffer/ya.make +++ b/library/cpp/containers/ring_buffer/ya.make @@ -1,9 +1,9 @@ OWNER(mowgli) - -LIBRARY() - -SRCS( - ring_buffer.cpp -) - -END() + +LIBRARY() + +SRCS( + ring_buffer.cpp +) + +END() diff --git a/library/cpp/containers/stack_array/stack_array.h b/library/cpp/containers/stack_array/stack_array.h index 4be0a5171b..28e49bfc3c 100644 --- a/library/cpp/containers/stack_array/stack_array.h +++ b/library/cpp/containers/stack_array/stack_array.h @@ -23,10 +23,10 @@ namespace NStackArray { * as those might be called from a loop, and then stack overflow is in the cards. */ template <class T> - class TStackArray: public TArrayRef<T> { + class TStackArray: public TArrayRef<T> { public: inline TStackArray(void* data, size_t len) - : TArrayRef<T>((T*)data, len) + : TArrayRef<T>((T*)data, len) { NRangeOps::InitializeRange(this->begin(), this->end()); } diff --git a/library/cpp/containers/stack_array/ut/tests_ut.cpp b/library/cpp/containers/stack_array/ut/tests_ut.cpp index 29476858e6..3e96384f0e 100644 --- a/library/cpp/containers/stack_array/ut/tests_ut.cpp +++ b/library/cpp/containers/stack_array/ut/tests_ut.cpp @@ -1,7 +1,7 @@ #include <library/cpp/containers/stack_array/stack_array.h> #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestStackArray) { +Y_UNIT_TEST_SUITE(TestStackArray) { using namespace NStackArray; static inline void* FillWithTrash(void* d, size_t l) { @@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(TestStackArray) { #define ALLOC(type, len) FillWithTrash(alloca(sizeof(type) * len), sizeof(type) * len), len - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { TStackArray<ui32> s(ALLOC(ui32, 10)); UNIT_ASSERT_VALUES_EQUAL(s.size(), 10); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TestStackArray) { } }; - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { { TStackArray<TX1> s(ALLOC(TX1, 10)); @@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(TestStackArray) { } }; - Y_UNIT_TEST(Test3) { + Y_UNIT_TEST(Test3) { bool haveException = false; try { diff --git a/library/cpp/containers/stack_vector/stack_vec_ut.cpp b/library/cpp/containers/stack_vector/stack_vec_ut.cpp index bcdec46ad4..19f9677781 100644 --- a/library/cpp/containers/stack_vector/stack_vec_ut.cpp +++ b/library/cpp/containers/stack_vector/stack_vec_ut.cpp @@ -43,13 +43,13 @@ namespace { }; } -Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { - Y_UNIT_TEST(TestCreateEmpty) { +Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { + Y_UNIT_TEST(TestCreateEmpty) { TStackVec<int> ints; UNIT_ASSERT_EQUAL(ints.size(), 0); } - Y_UNIT_TEST(TestCreateNonEmpty) { + Y_UNIT_TEST(TestCreateNonEmpty) { TStackVec<int> ints(5); UNIT_ASSERT_EQUAL(ints.size(), 5); @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { } } - Y_UNIT_TEST(TestReallyOnStack) { + Y_UNIT_TEST(TestReallyOnStack) { const TStackVec<int> vec(5); UNIT_ASSERT( @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { ); } - Y_UNIT_TEST(TestFallback) { + Y_UNIT_TEST(TestFallback) { TSmallVec<int> ints; for (int i = 0; i < 14; ++i) { ints.push_back(i); diff --git a/library/cpp/containers/top_keeper/top_keeper.h b/library/cpp/containers/top_keeper/top_keeper.h index 362e430711..2f282b5a9e 100644 --- a/library/cpp/containers/top_keeper/top_keeper.h +++ b/library/cpp/containers/top_keeper/top_keeper.h @@ -179,13 +179,13 @@ public: } const T& GetNext() { - Y_ENSURE(!IsEmpty(), "Trying GetNext from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying GetNext from empty heap!"); Finalize(); return Internal.Back(); } void Pop() { - Y_ENSURE(!IsEmpty(), "Trying Pop from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying Pop from empty heap!"); Finalize(); Internal.Pop(); if (IsEmpty()) { @@ -194,7 +194,7 @@ public: } T ExtractOne() { - Y_ENSURE(!IsEmpty(), "Trying ExtractOne from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying ExtractOne from empty heap!"); Finalize(); auto value = std::move(Internal.Back()); Internal.Pop(); @@ -243,7 +243,7 @@ public: } void SetMaxSize(size_t newMaxSize) { - Y_ENSURE(!Finalized, "Cannot resize after finalizing (Pop() / GetNext() / Finalize())! " + Y_ENSURE(!Finalized, "Cannot resize after finalizing (Pop() / GetNext() / Finalize())! " "Use TLimitedHeap for this scenario"); MaxSize = newMaxSize; Internal.SetMaxSize(newMaxSize); diff --git a/library/cpp/containers/top_keeper/top_keeper/top_keeper.h b/library/cpp/containers/top_keeper/top_keeper/top_keeper.h index 362e430711..2f282b5a9e 100644 --- a/library/cpp/containers/top_keeper/top_keeper/top_keeper.h +++ b/library/cpp/containers/top_keeper/top_keeper/top_keeper.h @@ -179,13 +179,13 @@ public: } const T& GetNext() { - Y_ENSURE(!IsEmpty(), "Trying GetNext from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying GetNext from empty heap!"); Finalize(); return Internal.Back(); } void Pop() { - Y_ENSURE(!IsEmpty(), "Trying Pop from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying Pop from empty heap!"); Finalize(); Internal.Pop(); if (IsEmpty()) { @@ -194,7 +194,7 @@ public: } T ExtractOne() { - Y_ENSURE(!IsEmpty(), "Trying ExtractOne from empty heap!"); + Y_ENSURE(!IsEmpty(), "Trying ExtractOne from empty heap!"); Finalize(); auto value = std::move(Internal.Back()); Internal.Pop(); @@ -243,7 +243,7 @@ public: } void SetMaxSize(size_t newMaxSize) { - Y_ENSURE(!Finalized, "Cannot resize after finalizing (Pop() / GetNext() / Finalize())! " + Y_ENSURE(!Finalized, "Cannot resize after finalizing (Pop() / GetNext() / Finalize())! " "Use TLimitedHeap for this scenario"); MaxSize = newMaxSize; Internal.SetMaxSize(newMaxSize); diff --git a/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp b/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp index 5684a00377..a938279025 100644 --- a/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp +++ b/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp @@ -12,9 +12,9 @@ ui32 Rnd() { /* * Tests for TTopKeeper */ -Y_UNIT_TEST_SUITE(TTopKeeperTest) { +Y_UNIT_TEST_SUITE(TTopKeeperTest) { // Tests correctness on usual examples - Y_UNIT_TEST(CorrectnessTest) { + Y_UNIT_TEST(CorrectnessTest) { int m = 20000; TLimitedHeap<std::pair<int, int>> h1(m); @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests on zero-size correctness - Y_UNIT_TEST(ZeroSizeCorrectnes) { + Y_UNIT_TEST(ZeroSizeCorrectnes) { TTopKeeper<int> h(0); for (int i = 0; i < 100; ++i) { h.Insert(i % 10 + i / 10); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests SetMaxSize behaviour - Y_UNIT_TEST(SetMaxSizeTest) { + Y_UNIT_TEST(SetMaxSizeTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests reuse behavior - Y_UNIT_TEST(ReuseTest) { + Y_UNIT_TEST(ReuseTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests reset behavior - Y_UNIT_TEST(ResetTest) { + Y_UNIT_TEST(ResetTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } } - Y_UNIT_TEST(PreRegressionTest) { + Y_UNIT_TEST(PreRegressionTest) { typedef std::pair<float, unsigned int> TElementType; const size_t randomTriesCount = 128; @@ -193,7 +193,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } } - Y_UNIT_TEST(CopyKeeperRegressionCase) { + Y_UNIT_TEST(CopyKeeperRegressionCase) { using TKeeper = TTopKeeper<float>; TVector<TKeeper> v(2, TKeeper(200)); auto& k = v[1]; diff --git a/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp b/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp index 5684a00377..a938279025 100644 --- a/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp +++ b/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp @@ -12,9 +12,9 @@ ui32 Rnd() { /* * Tests for TTopKeeper */ -Y_UNIT_TEST_SUITE(TTopKeeperTest) { +Y_UNIT_TEST_SUITE(TTopKeeperTest) { // Tests correctness on usual examples - Y_UNIT_TEST(CorrectnessTest) { + Y_UNIT_TEST(CorrectnessTest) { int m = 20000; TLimitedHeap<std::pair<int, int>> h1(m); @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests on zero-size correctness - Y_UNIT_TEST(ZeroSizeCorrectnes) { + Y_UNIT_TEST(ZeroSizeCorrectnes) { TTopKeeper<int> h(0); for (int i = 0; i < 100; ++i) { h.Insert(i % 10 + i / 10); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests SetMaxSize behaviour - Y_UNIT_TEST(SetMaxSizeTest) { + Y_UNIT_TEST(SetMaxSizeTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests reuse behavior - Y_UNIT_TEST(ReuseTest) { + Y_UNIT_TEST(ReuseTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } // Tests reset behavior - Y_UNIT_TEST(ResetTest) { + Y_UNIT_TEST(ResetTest) { int m = 20000; TLimitedHeap<int> h1(m); TTopKeeper<int> h2(m); @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } } - Y_UNIT_TEST(PreRegressionTest) { + Y_UNIT_TEST(PreRegressionTest) { typedef std::pair<float, unsigned int> TElementType; const size_t randomTriesCount = 128; @@ -193,7 +193,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { } } - Y_UNIT_TEST(CopyKeeperRegressionCase) { + Y_UNIT_TEST(CopyKeeperRegressionCase) { using TKeeper = TTopKeeper<float>; TVector<TKeeper> v(2, TKeeper(200)); auto& k = v[1]; diff --git a/library/cpp/coroutine/engine/coroutine_ut.cpp b/library/cpp/coroutine/engine/coroutine_ut.cpp index 6749f2e076..8b372496a2 100644 --- a/library/cpp/coroutine/engine/coroutine_ut.cpp +++ b/library/cpp/coroutine/engine/coroutine_ut.cpp @@ -5,7 +5,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/string/cast.h> -#include <util/system/pipe.h> +#include <util/system/pipe.h> #include <util/system/env.h> #include <util/system/info.h> #include <util/system/thread.h> diff --git a/library/cpp/coroutine/engine/events.h b/library/cpp/coroutine/engine/events.h index b5a7726343..07cc4d25e8 100644 --- a/library/cpp/coroutine/engine/events.h +++ b/library/cpp/coroutine/engine/events.h @@ -69,7 +69,7 @@ public: } ~TContWaitQueue() { - Y_ASSERT(Waiters_.Empty()); + Y_ASSERT(Waiters_.Empty()); } int WaitD(TCont* current, TInstant deadline) { diff --git a/library/cpp/coroutine/engine/impl.cpp b/library/cpp/coroutine/engine/impl.cpp index 5e2d7f6610..7ae6f74051 100644 --- a/library/cpp/coroutine/engine/impl.cpp +++ b/library/cpp/coroutine/engine/impl.cpp @@ -34,7 +34,7 @@ TCont::TCont(NCoro::NStack::IAllocator& allocator, {} -void TCont::PrintMe(IOutputStream& out) const noexcept { +void TCont::PrintMe(IOutputStream& out) const noexcept { out << "cont(" << "name = " << Name_ << ", " << "addr = " << Hex((size_t)this) diff --git a/library/cpp/coroutine/engine/impl.h b/library/cpp/coroutine/engine/impl.h index d0041bf789..283a96ecf1 100644 --- a/library/cpp/coroutine/engine/impl.h +++ b/library/cpp/coroutine/engine/impl.h @@ -66,7 +66,7 @@ public: return Name_; } - void PrintMe(IOutputStream& out) const noexcept; + void PrintMe(IOutputStream& out) const noexcept; void Yield() noexcept; diff --git a/library/cpp/coroutine/engine/mutex.h b/library/cpp/coroutine/engine/mutex.h index 252d281c98..93e9119503 100644 --- a/library/cpp/coroutine/engine/mutex.h +++ b/library/cpp/coroutine/engine/mutex.h @@ -11,7 +11,7 @@ public: } ~TContMutex() { - Y_ASSERT(Token_); + Y_ASSERT(Token_); } int LockD(TCont* current, TInstant deadline) { @@ -37,7 +37,7 @@ public: } void UnLock() noexcept { - Y_ASSERT(!Token_); + Y_ASSERT(!Token_); Token_ = true; WaitQueue_.Signal(); diff --git a/library/cpp/coroutine/engine/poller.cpp b/library/cpp/coroutine/engine/poller.cpp index cba6ae0c79..61164fa56b 100644 --- a/library/cpp/coroutine/engine/poller.cpp +++ b/library/cpp/coroutine/engine/poller.cpp @@ -162,7 +162,7 @@ namespace { T* Get(size_t i) { TValRef& v = V_.Get(i); - if (Y_UNLIKELY(!v)) { + if (Y_UNLIKELY(!v)) { v.Reset(new (&P_) TVal()); I_.PushFront(v.Get()); } diff --git a/library/cpp/coroutine/engine/sockpool.cpp b/library/cpp/coroutine/engine/sockpool.cpp index 8a61b19bcd..b9482e780f 100644 --- a/library/cpp/coroutine/engine/sockpool.cpp +++ b/library/cpp/coroutine/engine/sockpool.cpp @@ -21,7 +21,7 @@ void SetCommonSockOpts(SOCKET sock, const struct sockaddr* sa) { warn("bind6"); } } else { - Y_ASSERT(0); + Y_ASSERT(0); } SetNoDelay(sock, true); diff --git a/library/cpp/coroutine/engine/sockpool.h b/library/cpp/coroutine/engine/sockpool.h index c58455d6f5..1ebb7e7b38 100644 --- a/library/cpp/coroutine/engine/sockpool.h +++ b/library/cpp/coroutine/engine/sockpool.h @@ -227,7 +227,7 @@ inline void TPooledSocket::TImpl::ReturnToPool() noexcept { } -class TContIO: public IInputStream, public IOutputStream { +class TContIO: public IInputStream, public IOutputStream { public: TContIO(SOCKET fd, TCont* cont) : Fd_(fd) diff --git a/library/cpp/coroutine/listener/listen.cpp b/library/cpp/coroutine/listener/listen.cpp index 11e91b5f6e..3d4e711d1d 100644 --- a/library/cpp/coroutine/listener/listen.cpp +++ b/library/cpp/coroutine/listener/listen.cpp @@ -181,7 +181,7 @@ private: class TListeners: public TIntrusiveListWithAutoDelete<TOneSocketListener, TDelete> { private: template <class T> - using TIt = std::conditional_t<std::is_const<T>::value, typename T::TConstIterator, typename T::TIterator>; + using TIt = std::conditional_t<std::is_const<T>::value, typename T::TConstIterator, typename T::TIterator>; template <class T> static inline TIt<T> FindImpl(T* t, const IRemoteAddr& addr) { diff --git a/library/cpp/dbg_output/auto.h b/library/cpp/dbg_output/auto.h index 1fdfcae0e2..8d96167f6a 100644 --- a/library/cpp/dbg_output/auto.h +++ b/library/cpp/dbg_output/auto.h @@ -4,7 +4,7 @@ // int a = 1, b = 2; Cout << LabeledDump(a, b, 1 + 2); yields {"a": 1, "b": 2, "1 + 2": 3} #define LabeledDump(...) \ - '{' Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_DUMP_NONLAST__, __LABELED_DUMP_IMPL__, __VA_ARGS__)) << '}' + '{' Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_DUMP_NONLAST__, __LABELED_DUMP_IMPL__, __VA_ARGS__)) << '}' #define __LABELED_DUMP_IMPL__(x) << "\"" #x "\": " << DbgDump(x) #define __LABELED_DUMP_NONLAST__(x) __LABELED_DUMP_IMPL__(x) << ", " @@ -15,7 +15,7 @@ struct TDumper<C> { \ template <class S> \ static inline void Dump(S& s, const C& v) { \ - s << DumpRaw("{") Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__DEFINE_DUMPER_NONLAST__, __DEFINE_DUMPER_IMPL__, __VA_ARGS__)) << DumpRaw("}"); \ + s << DumpRaw("{") Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__DEFINE_DUMPER_NONLAST__, __DEFINE_DUMPER_IMPL__, __VA_ARGS__)) << DumpRaw("}"); \ } \ }; #define __DEFINE_DUMPER_IMPL__(x) << DumpRaw("\"" #x "\": ") << v.x diff --git a/library/cpp/dbg_output/colorscheme.h b/library/cpp/dbg_output/colorscheme.h index 1d6862d76a..a5b9cf749a 100644 --- a/library/cpp/dbg_output/colorscheme.h +++ b/library/cpp/dbg_output/colorscheme.h @@ -17,27 +17,27 @@ namespace NDbgDump { struct TPlain { // Foreground color modifiers DBG_OUTPUT_COLOR_HANDLER(Markup) { - Y_UNUSED(stream); + Y_UNUSED(stream); } DBG_OUTPUT_COLOR_HANDLER(String) { - Y_UNUSED(stream); + Y_UNUSED(stream); } DBG_OUTPUT_COLOR_HANDLER(Literal) { - Y_UNUSED(stream); + Y_UNUSED(stream); } DBG_OUTPUT_COLOR_HANDLER(ResetType) { - Y_UNUSED(stream); + Y_UNUSED(stream); } // Background color modifiers DBG_OUTPUT_COLOR_HANDLER(Key) { - Y_UNUSED(stream); + Y_UNUSED(stream); } DBG_OUTPUT_COLOR_HANDLER(Value) { - Y_UNUSED(stream); + Y_UNUSED(stream); } DBG_OUTPUT_COLOR_HANDLER(ResetRole) { - Y_UNUSED(stream); + Y_UNUSED(stream); } }; diff --git a/library/cpp/dbg_output/dump.h b/library/cpp/dbg_output/dump.h index 448f1a8f5a..c7efa105ee 100644 --- a/library/cpp/dbg_output/dump.h +++ b/library/cpp/dbg_output/dump.h @@ -71,7 +71,7 @@ namespace NPrivate { { } - inline void DumpTo(IOutputStream& out) const { + inline void DumpTo(IOutputStream& out) const { typename TTraits::TDump d(out, Indent); d << *T_; @@ -88,7 +88,7 @@ namespace NPrivate { }; template <class T, class TTraits> - static inline IOutputStream& operator<<(IOutputStream& out, const TDbgDump<T, TTraits>& d) { + static inline IOutputStream& operator<<(IOutputStream& out, const TDbgDump<T, TTraits>& d) { d.DumpTo(out); return out; diff --git a/library/cpp/dbg_output/dumpers.h b/library/cpp/dbg_output/dumpers.h index fca6c58920..4868e97da0 100644 --- a/library/cpp/dbg_output/dumpers.h +++ b/library/cpp/dbg_output/dumpers.h @@ -48,7 +48,7 @@ struct TDumper<TCopyPtr<T, C, D>> { }; //small ints -// Default dumper prints them via IOutputStream << (value), which results in raw +// Default dumper prints them via IOutputStream << (value), which results in raw // chars, not integer values. Cast to a bigger int type to force printing as // integers. // NB: i8 = signed char != char != unsigned char = ui8 @@ -102,10 +102,10 @@ template <class T> struct TDumper<TArrayRef<T>>: public TSeqDumper { }; -template <class T, size_t N> +template <class T, size_t N> struct TDumper<std::array<T, N>>: public TSeqDumper { -}; - +}; + template <class T, class A> struct TDumper<TDeque<T, A>>: public TSeqDumper { }; diff --git a/library/cpp/dbg_output/engine.h b/library/cpp/dbg_output/engine.h index 111a00a019..f13c728c39 100644 --- a/library/cpp/dbg_output/engine.h +++ b/library/cpp/dbg_output/engine.h @@ -31,14 +31,14 @@ namespace NDumpPrivate { } struct TDumpBase: public ::NDumpPrivate::TADLBase { - inline TDumpBase(IOutputStream& out, bool indent) noexcept + inline TDumpBase(IOutputStream& out, bool indent) noexcept : Out(&out) , IndentLevel(0) , Indent(indent) { } - inline IOutputStream& Stream() const noexcept { + inline IOutputStream& Stream() const noexcept { return *Out; } @@ -50,7 +50,7 @@ struct TDumpBase: public ::NDumpPrivate::TADLBase { void Raw(const TStringBuf& s); - IOutputStream* Out; + IOutputStream* Out; size_t IndentLevel; bool Indent; }; diff --git a/library/cpp/dbg_output/ut/dbg_output_ut.cpp b/library/cpp/dbg_output/ut/dbg_output_ut.cpp index 7406a76bef..7b285c84cb 100644 --- a/library/cpp/dbg_output/ut/dbg_output_ut.cpp +++ b/library/cpp/dbg_output/ut/dbg_output_ut.cpp @@ -31,14 +31,14 @@ namespace TMyNS { } DEFINE_DUMPER(TMyNS::TMyStruct, A, B) -Y_UNIT_TEST_SUITE(TContainerPrintersTest) { - Y_UNIT_TEST(TestVectorInt) { +Y_UNIT_TEST_SUITE(TContainerPrintersTest) { + Y_UNIT_TEST(TestVectorInt) { TStringStream out; out << DbgDump(TVector<int>({1, 2, 3, 4, 5})); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "[1, 2, 3, 4, 5]"); } - Y_UNIT_TEST(TestMapCharToCharArray) { + Y_UNIT_TEST(TestMapCharToCharArray) { TStringStream out; TMap<char, const char*> m; @@ -51,7 +51,7 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) { UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "{'a' -> \"SMALL LETTER A\", 'b' -> (empty)}"); } - Y_UNIT_TEST(TestVectorOfVectors) { + Y_UNIT_TEST(TestVectorOfVectors) { TStringStream out; TVector<TVector<wchar16>> vec(2); vec[0].push_back(0); @@ -60,24 +60,24 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) { UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "[[w'\\0'], [w'a']]"); } - Y_UNIT_TEST(TestInfinite) { + Y_UNIT_TEST(TestInfinite) { UNIT_ASSERT(!!(TStringBuilder() << DbgDumpDeep(TX()))); } - Y_UNIT_TEST(TestLabeledDump) { + Y_UNIT_TEST(TestLabeledDump) { TStringStream out; int a = 1, b = 2; out << LabeledDump(a, b, 1 + 2); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "{\"a\": 1, \"b\": 2, \"1 + 2\": 3}"); } - Y_UNIT_TEST(TestStructDumper) { + Y_UNIT_TEST(TestStructDumper) { TStringStream out; out << DbgDump(TMyNS::TMyStruct{3, 4}); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "{\"A\": 3, \"B\": 4}"); } - Y_UNIT_TEST(TestColors) { + Y_UNIT_TEST(TestColors) { using TComplex = TMap<TString, TMap<int, char>>; TComplex test; test["a"][1] = '7'; @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) { "\\x1B[1;31m'6'\\x1B[22;39m\\x1B[1;32m}\\x1B[22;39m\\x1B[22;39m\\x1B[49m\\x1B[1;32m}\\x1B[22;39m"); } - Y_UNIT_TEST(SmallIntOrChar) { + Y_UNIT_TEST(SmallIntOrChar) { char c = 'e'; i8 i = -100; ui8 u = 10; diff --git a/library/cpp/deprecated/accessors/accessors_impl.h b/library/cpp/deprecated/accessors/accessors_impl.h index 66ba8d2d71..6b2b987351 100644 --- a/library/cpp/deprecated/accessors/accessors_impl.h +++ b/library/cpp/deprecated/accessors/accessors_impl.h @@ -27,8 +27,8 @@ namespace NAccessors { template <typename Tb> struct TIndirectMemoryRegionBegin { - Y_HAS_MEMBER(Begin); - Y_HAS_MEMBER(begin); + Y_HAS_MEMBER(Begin); + Y_HAS_MEMBER(begin); template <typename Tc> struct TByBegin { @@ -51,10 +51,10 @@ namespace NAccessors { } }; - using TGet = std::conditional_t< + using TGet = std::conditional_t< TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionBegin<Ta>, - std::conditional_t< + std::conditional_t< TMemoryAccessorBase<Ta>::ContinuousMemory, TIndirectMemoryRegionBegin<Ta>, typename TMemoryAccessorBase<Ta>::TBadAccessor>>; @@ -77,8 +77,8 @@ namespace NAccessors { template <typename Tb> struct TIndirectMemoryRegionEnd { - Y_HAS_MEMBER(End); - Y_HAS_MEMBER(end); + Y_HAS_MEMBER(End); + Y_HAS_MEMBER(end); template <typename Tc> struct TByEnd { @@ -101,10 +101,10 @@ namespace NAccessors { } }; - using TGet = std::conditional_t< + using TGet = std::conditional_t< TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionEnd<Ta>, - std::conditional_t< + std::conditional_t< TMemoryAccessorBase<Ta>::ContinuousMemory, TIndirectMemoryRegionEnd<Ta>, typename TMemoryAccessorBase<Ta>::TBadAccessor>>; @@ -125,8 +125,8 @@ namespace NAccessors { template <typename Tb> struct TIndirectMemoryRegionClear { - Y_HAS_MEMBER(Clear); - Y_HAS_MEMBER(clear); + Y_HAS_MEMBER(Clear); + Y_HAS_MEMBER(clear); template <typename Tc> struct TByClear { @@ -150,10 +150,10 @@ namespace NAccessors { } }; - using TDo = std::conditional_t< + using TDo = std::conditional_t< THasClear<Tb>::value, TByClear<Tb>, - std::conditional_t< + std::conditional_t< THasclear<Tb>::value, TByclear<Tb>, TByNone<Tb>>>; @@ -163,7 +163,7 @@ namespace NAccessors { } }; - using TDo = std::conditional_t<TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionClear<Ta>, TIndirectMemoryRegionClear<Ta>>; + using TDo = std::conditional_t<TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionClear<Ta>, TIndirectMemoryRegionClear<Ta>>; static void Do(Ta& b) { TDo::Do(b); @@ -172,8 +172,8 @@ namespace NAccessors { template <typename Tb> struct TReserve { - Y_HAS_MEMBER(Reserve); - Y_HAS_MEMBER(reserve); + Y_HAS_MEMBER(Reserve); + Y_HAS_MEMBER(reserve); template <typename Tc> struct TByReserve { @@ -195,10 +195,10 @@ namespace NAccessors { } }; - using TDo = std::conditional_t< + using TDo = std::conditional_t< THasReserve<Tb>::value, TByReserve<Tb>, - std::conditional_t< + std::conditional_t< THasreserve<Tb>::value, TByreserve<Tb>, TByNone<Tb>>>; @@ -210,8 +210,8 @@ namespace NAccessors { template <typename Tb> struct TResize { - Y_HAS_MEMBER(Resize); - Y_HAS_MEMBER(resize); + Y_HAS_MEMBER(Resize); + Y_HAS_MEMBER(resize); template <typename Tc> struct TByResize { @@ -236,9 +236,9 @@ namespace NAccessors { template <typename Tb> struct TAppend { - Y_HAS_MEMBER(Append); - Y_HAS_MEMBER(append); - Y_HAS_MEMBER(push_back); + Y_HAS_MEMBER(Append); + Y_HAS_MEMBER(append); + Y_HAS_MEMBER(push_back); template <typename Tc> struct TByAppend { @@ -267,10 +267,10 @@ namespace NAccessors { } }; - using TDo = std::conditional_t< + using TDo = std::conditional_t< THasAppend<Tb>::value, TByAppend<Tb>, - std::conditional_t< + std::conditional_t< THasappend<Tb>::value, TByappend<Tb>, TBypush_back<Tb>>>; @@ -284,9 +284,9 @@ namespace NAccessors { template <typename Tb> struct TAppendRegion { - Y_HAS_MEMBER(Append); - Y_HAS_MEMBER(append); - Y_HAS_MEMBER(insert); + Y_HAS_MEMBER(Append); + Y_HAS_MEMBER(append); + Y_HAS_MEMBER(insert); template <typename Tc> struct TByAppend { @@ -325,13 +325,13 @@ namespace NAccessors { } }; - using TDo = std::conditional_t< + using TDo = std::conditional_t< THasAppend<Tb>::value, TByAppend<Tb>, - std::conditional_t< + std::conditional_t< THasappend<Tb>::value, TByappend<Tb>, - std::conditional_t< + std::conditional_t< THasinsert<Tb>::value, TByinsert<Tb>, TByNone<Tb>>>>; @@ -362,8 +362,8 @@ namespace NAccessors { template <typename Tb> struct TIndirectMemoryRegionAssign { - Y_HAS_MEMBER(Assign); - Y_HAS_MEMBER(assign); + Y_HAS_MEMBER(Assign); + Y_HAS_MEMBER(assign); template <typename Tc> struct TByAssign { @@ -394,13 +394,13 @@ namespace NAccessors { } }; - using TDo = std::conditional_t< + using TDo = std::conditional_t< THasAssign<Tb>::value, TByAssign<Tb>, - std::conditional_t< + std::conditional_t< THasassign<Tb>::value, TByassign<Tb>, - std::conditional_t< + std::conditional_t< TMemoryTraits<Tb>::OwnsMemory, TByClearAppend<Tb>, TByConstruction<Tb>>>>; @@ -410,7 +410,7 @@ namespace NAccessors { } }; - using TDo = std::conditional_t<TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionAssign<Ta>, TIndirectMemoryRegionAssign<Ta>>; + using TDo = std::conditional_t<TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionAssign<Ta>, TIndirectMemoryRegionAssign<Ta>>; static void Do(Ta& b, const TElementType* beg, const TElementType* end) { TDo::Do(b, beg, end); diff --git a/library/cpp/deprecated/enum_codegen/enum_codegen.h b/library/cpp/deprecated/enum_codegen/enum_codegen.h index 26addd9495..dfb04ecac2 100644 --- a/library/cpp/deprecated/enum_codegen/enum_codegen.h +++ b/library/cpp/deprecated/enum_codegen/enum_codegen.h @@ -22,7 +22,7 @@ } \ } \ \ - static inline IOutputStream& operator<<(IOutputStream& os, type value) { \ + static inline IOutputStream& operator<<(IOutputStream& os, type value) { \ switch (value) { \ MAP(ENUM_LTLT_IMPL_ITEM) \ default: \ diff --git a/library/cpp/deprecated/enum_codegen/enum_codegen_ut.cpp b/library/cpp/deprecated/enum_codegen/enum_codegen_ut.cpp index 06ddb8107d..f8f1c9b6df 100644 --- a/library/cpp/deprecated/enum_codegen/enum_codegen_ut.cpp +++ b/library/cpp/deprecated/enum_codegen/enum_codegen_ut.cpp @@ -26,12 +26,12 @@ enum EMultiplier { ENUM_TO_STRING(EMultiplier, MULTIPLIER_MAP) -Y_UNIT_TEST_SUITE(EnumCodegen) { - Y_UNIT_TEST(GenWithValue) { +Y_UNIT_TEST_SUITE(EnumCodegen) { + Y_UNIT_TEST(GenWithValue) { UNIT_ASSERT_VALUES_EQUAL(6, MB); } - Y_UNIT_TEST(ToCString) { + Y_UNIT_TEST(ToCString) { UNIT_ASSERT_VALUES_EQUAL("RED", ToCString(RED)); UNIT_ASSERT_VALUES_EQUAL("BLUE", ToCString(BLUE)); UNIT_ASSERT_VALUES_EQUAL("GREEN", (TStringBuilder() << GREEN)); diff --git a/library/cpp/deprecated/kmp/kmp.h b/library/cpp/deprecated/kmp/kmp.h index ce7783e2fc..a7f72eece6 100644 --- a/library/cpp/deprecated/kmp/kmp.h +++ b/library/cpp/deprecated/kmp/kmp.h @@ -18,9 +18,9 @@ void ComputePrefixFunction(const T* begin, const T* end, ssize_t** result) { j = resultHolder[j]; ++i; ++j; - Y_ASSERT(i >= 0); - Y_ASSERT(j >= 0); - Y_ASSERT(j < len); + Y_ASSERT(i >= 0); + Y_ASSERT(j >= 0); + Y_ASSERT(j < len); if ((i < len) && (begin[i] == begin[j])) resultHolder[i] = resultHolder[j]; else @@ -41,7 +41,7 @@ public: TKMPMatcher(const TString& pattern); bool SubStr(const char* begin, const char* end, const char*& result) const { - Y_ASSERT(begin <= end); + Y_ASSERT(begin <= end); ssize_t m = Pattern.size(); ssize_t n = end - begin; ssize_t i, j; diff --git a/library/cpp/deprecated/kmp/kmp_ut.cpp b/library/cpp/deprecated/kmp/kmp_ut.cpp index dc60429596..c2eda83c57 100644 --- a/library/cpp/deprecated/kmp/kmp_ut.cpp +++ b/library/cpp/deprecated/kmp/kmp_ut.cpp @@ -71,8 +71,8 @@ public: int data[] = {1, 2, 3, 5, 2, 2, 3, 2, 4, 3, 2}; TKMPSimpleCallback callback(pattern, pattern + 2); TKMPStreamMatcher<int> matcher(pattern, pattern + 2, &callback); - for (auto& i : data) - matcher.Push(i); + for (auto& i : data) + matcher.Push(i); UNIT_ASSERT_EQUAL(2, callback.GetCount()); } }; diff --git a/library/cpp/deprecated/mapped_file/mapped_file.cpp b/library/cpp/deprecated/mapped_file/mapped_file.cpp index 90752ea263..b0e4511299 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.cpp +++ b/library/cpp/deprecated/mapped_file/mapped_file.cpp @@ -15,7 +15,7 @@ TMappedFile::TMappedFile(TFileMap* map, const char* dbgName) { } TMappedFile::TMappedFile(const TFile& file, TFileMap::EOpenMode om, const char* dbgName) - : Map_(nullptr) + : Map_(nullptr) { init(file, om, dbgName); } diff --git a/library/cpp/deprecated/mapped_file/mapped_file.h b/library/cpp/deprecated/mapped_file/mapped_file.h index 3245f74249..45859ed65a 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.h +++ b/library/cpp/deprecated/mapped_file/mapped_file.h @@ -23,7 +23,7 @@ private: public: TMappedFile() { - Map_ = nullptr; + Map_ = nullptr; } ~TMappedFile() { @@ -31,7 +31,7 @@ public: } explicit TMappedFile(const TString& name) { - Map_ = nullptr; + Map_ = nullptr; init(name, TFileMap::oRdOnly); } @@ -51,7 +51,7 @@ public: if (Map_) { Map_->Unmap(); delete Map_; - Map_ = nullptr; + Map_ = nullptr; } } @@ -60,7 +60,7 @@ public: } void* getData(size_t pos = 0) const { - Y_ASSERT(!Map_ || (pos <= getSize())); + Y_ASSERT(!Map_ || (pos <= getSize())); return (Map_ ? (void*)((unsigned char*)Map_->Ptr() + pos) : nullptr); } diff --git a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp b/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp index 6eaa063562..afbd5b3358 100644 --- a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp +++ b/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp @@ -3,9 +3,9 @@ #include <util/system/fs.h> -Y_UNIT_TEST_SUITE(TMappedFileTest) { +Y_UNIT_TEST_SUITE(TMappedFileTest) { static const char* FileName_("./mappped_file"); - Y_UNIT_TEST(TestFileMapEmpty) { + Y_UNIT_TEST(TestFileMapEmpty) { TFile file(FileName_, CreateAlways | WrOnly); file.Close(); diff --git a/library/cpp/deprecated/split/delim_string_iter.h b/library/cpp/deprecated/split/delim_string_iter.h index af0d86872d..8e4ca171a0 100644 --- a/library/cpp/deprecated/split/delim_string_iter.h +++ b/library/cpp/deprecated/split/delim_string_iter.h @@ -173,8 +173,8 @@ public: TKeyValueDelimStringIter(const TStringBuf str, const TStringBuf delim); bool Valid() const; TKeyValueDelimStringIter& operator++(); - const TStringBuf& Key() const; - const TStringBuf& Value() const; + const TStringBuf& Key() const; + const TStringBuf& Value() const; private: TDelimStringIter DelimIter; diff --git a/library/cpp/deprecated/split/delim_string_iter_ut.cpp b/library/cpp/deprecated/split/delim_string_iter_ut.cpp index 644d72e56f..18a8b2a160 100644 --- a/library/cpp/deprecated/split/delim_string_iter_ut.cpp +++ b/library/cpp/deprecated/split/delim_string_iter_ut.cpp @@ -16,22 +16,22 @@ static void AssertStringSplit(const TString& str, const TString& delim, const TV UNIT_ASSERT(!it.Valid()); }; -Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { - Y_UNIT_TEST(SingleCharacterAsDelimiter) { +Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { + Y_UNIT_TEST(SingleCharacterAsDelimiter) { AssertStringSplit( "Hello words!", " ", {"Hello", "words!"}); } - Y_UNIT_TEST(MultipleCharactersAsDelimiter) { + Y_UNIT_TEST(MultipleCharactersAsDelimiter) { AssertStringSplit( "0, 1, 1, 2, 3, 5, 8, 13, 21, 34", "1, ", {"0, ", "", "2, 3, 5, 8, 13, 2", "34"}); } - Y_UNIT_TEST(NoDelimitersPresent) { + Y_UNIT_TEST(NoDelimitersPresent) { AssertStringSplit("This string could be yours", "\t", {"This string could be yours"}); } - Y_UNIT_TEST(Cdr) { + Y_UNIT_TEST(Cdr) { TDelimStringIter it("a\tc\t", "\t"); UNIT_ASSERT_STRINGS_EQUAL(*it, "a"); UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), "c\t"); @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), ""); } - Y_UNIT_TEST(ForIter) { + Y_UNIT_TEST(ForIter) { TVector<TStringBuf> expected = {"1", "", "3@4", ""}; TVector<TStringBuf> got; @@ -52,8 +52,8 @@ Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { } static void AssertKeyValueStringSplit( - const TStringBuf str, - const TStringBuf delim, + const TStringBuf str, + const TStringBuf delim, const TVector<std::pair<TStringBuf, TStringBuf>>& expected) { TKeyValueDelimStringIter it(str, delim); @@ -66,28 +66,28 @@ static void AssertKeyValueStringSplit( UNIT_ASSERT(!it.Valid()); } -Y_UNIT_TEST_SUITE(TKeyValueDelimStringIterTestSuite) { - Y_UNIT_TEST(SingleCharacterAsDelimiter) { +Y_UNIT_TEST_SUITE(TKeyValueDelimStringIterTestSuite) { + Y_UNIT_TEST(SingleCharacterAsDelimiter) { AssertKeyValueStringSplit( "abc=123,cde=qwer", ",", {{"abc", "123"}, {"cde", "qwer"}}); } - Y_UNIT_TEST(MultipleCharactersAsDelimiter) { + Y_UNIT_TEST(MultipleCharactersAsDelimiter) { AssertKeyValueStringSplit( "abc=xyz@@qwerty=zxcv", "@@", {{"abc", "xyz"}, {"qwerty", "zxcv"}}); } - Y_UNIT_TEST(NoDelimiters) { + Y_UNIT_TEST(NoDelimiters) { AssertKeyValueStringSplit( "abc=zz", ",", {{"abc", "zz"}}); } - Y_UNIT_TEST(EmptyElements) { + Y_UNIT_TEST(EmptyElements) { AssertKeyValueStringSplit( "@@abc=zxy@@@@qwerty=y@@", "@@", {{"", ""}, diff --git a/library/cpp/deprecated/split/split_iterator.cpp b/library/cpp/deprecated/split/split_iterator.cpp index ca46799dd6..32262d25bd 100644 --- a/library/cpp/deprecated/split/split_iterator.cpp +++ b/library/cpp/deprecated/split/split_iterator.cpp @@ -155,7 +155,7 @@ TDelimitersSplitWithoutTags::TDelimitersSplitWithoutTags(const TString& s, const } size_t TDelimitersSplitWithoutTags::SkipTag(size_t pos) const { - Y_ASSERT('<' == Str[pos]); + Y_ASSERT('<' == Str[pos]); while ((pos < Len) && ('>' != Str[pos])) ++pos; return pos + 1; @@ -236,7 +236,7 @@ TCharSplitWithoutTags::TCharSplitWithoutTags(const TString& s) } size_t TCharSplitWithoutTags::SkipTag(size_t pos) const { - Y_ASSERT('<' == Str[pos]); + Y_ASSERT('<' == Str[pos]); while ((pos < Len) && ('>' != Str[pos])) ++pos; return pos + 1; diff --git a/library/cpp/deprecated/split/split_iterator.h b/library/cpp/deprecated/split/split_iterator.h index b1a39d81be..0eacc29228 100644 --- a/library/cpp/deprecated/split/split_iterator.h +++ b/library/cpp/deprecated/split/split_iterator.h @@ -25,7 +25,7 @@ struct TNumPair { : Begin(begin) , End(end) { - Y_ASSERT(begin <= end); + Y_ASSERT(begin <= end); } T Length() const { @@ -264,7 +264,7 @@ public: TSplitIterator(const TSplit& split) : Split(split) , Pos(Split.Begin()) - , CurrentStroka(nullptr) + , CurrentStroka(nullptr) { } diff --git a/library/cpp/diff/diff.cpp b/library/cpp/diff/diff.cpp index 776b686546..be57da7f39 100644 --- a/library/cpp/diff/diff.cpp +++ b/library/cpp/diff/diff.cpp @@ -66,8 +66,8 @@ size_t NDiff::InlineDiff(TVector<TChunk<char>>& chunks, const TStringBuf& left, TCollection<char> c2(right, delims); TVector<TChunk<ui64>> diff; const size_t dist = InlineDiff<ui64>(diff, c1.GetKeys(), c2.GetKeys()); - for (const auto& it : diff) { - chunks.push_back(TChunk<char>(c1.Remap(it.Left), c2.Remap(it.Right), c1.Remap(it.Common))); + for (const auto& it : diff) { + chunks.push_back(TChunk<char>(c1.Remap(it.Left), c2.Remap(it.Right), c1.Remap(it.Common))); } return dist; } @@ -80,7 +80,7 @@ size_t NDiff::InlineDiff(TVector<TChunk<wchar16>>& chunks, const TWtringBuf& lef TCollection<wchar16> c2(right, delims); TVector<TChunk<ui64>> diff; const size_t dist = InlineDiff<ui64>(diff, c1.GetKeys(), c2.GetKeys()); - for (const auto& it : diff) { + for (const auto& it : diff) { chunks.push_back(TChunk<wchar16>(c1.Remap(it.Left), c2.Remap(it.Right), c1.Remap(it.Common))); } return dist; diff --git a/library/cpp/diff/diff.h b/library/cpp/diff/diff.h index 252564f53a..94fb00cd0b 100644 --- a/library/cpp/diff/diff.h +++ b/library/cpp/diff/diff.h @@ -44,8 +44,8 @@ namespace NDiff { NLCS::MakeLCS<T>(s1, s2, &lcs, &ctx); // Start points of current common and diff parts - const T* c1 = nullptr; - const T* c2 = nullptr; + const T* c1 = nullptr; + const T* c2 = nullptr; const T* d1 = s1.begin(); const T* d2 = s2.begin(); diff --git a/library/cpp/diff/diff_ut.cpp b/library/cpp/diff/diff_ut.cpp index dd75fa6754..b82a7b000e 100644 --- a/library/cpp/diff/diff_ut.cpp +++ b/library/cpp/diff/diff_ut.cpp @@ -36,7 +36,7 @@ struct TDiffTester { } }; -Y_UNIT_TEST_SUITE(DiffTokens) { +Y_UNIT_TEST_SUITE(DiffTokens) { Y_UNIT_TEST(ReturnValue) { TVector<TChunk<char>> res; UNIT_ASSERT_VALUES_EQUAL(InlineDiff(res, "aaa", "aaa"), 0); @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(InlineDiff(res, "abc", "xyz"), 3); } - Y_UNIT_TEST(EqualStringsOneToken) { + Y_UNIT_TEST(EqualStringsOneToken) { TDiffTester tester; tester.Test("aaa", "aaa"); @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa"); } - Y_UNIT_TEST(NonCrossingStringsOneToken) { + Y_UNIT_TEST(NonCrossingStringsOneToken) { TDiffTester tester; tester.Test("aaa", "bbb"); @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|bbbb)"); } - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TDiffTester tester; tester.Test("aaa", "abb", ""); @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "[1, (2|3), 3]"); } - Y_UNIT_TEST(CommonCharOneToken) { + Y_UNIT_TEST(CommonCharOneToken) { TDiffTester tester; tester.Test("abcde", "accfg"); @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(abcde|accfg)"); } - Y_UNIT_TEST(EqualStringsTwoTokens) { + Y_UNIT_TEST(EqualStringsTwoTokens) { TDiffTester tester; TStringBuf str("aaa bbb"); @@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa bbb"); } - Y_UNIT_TEST(NonCrossingStringsTwoTokens) { + Y_UNIT_TEST(NonCrossingStringsTwoTokens) { TDiffTester tester; tester.Test("aaa bbb", "ccc ddd"); @@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|c) (bbb|d)"); } - Y_UNIT_TEST(SimpleTwoTokens) { + Y_UNIT_TEST(SimpleTwoTokens) { TDiffTester tester; tester.Test("aaa ccd", "abb cce"); @@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aac|aa) (cbb|bb)"); } - Y_UNIT_TEST(MixedTwoTokens) { + Y_UNIT_TEST(MixedTwoTokens) { TDiffTester tester; tester.Test("aaa bbb", "bbb aaa"); @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|) (bb|bbb aa)"); } - Y_UNIT_TEST(TwoTokensInOneString) { + Y_UNIT_TEST(TwoTokensInOneString) { TDiffTester tester; tester.Test("aaa bbb", "aaa"); @@ -171,7 +171,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa |)bbb"); } - Y_UNIT_TEST(Multiline) { + Y_UNIT_TEST(Multiline) { TDiffTester tester; tester.Test("aaa\nabc\nbbb", "aaa\nacc\nbbb"); @@ -183,7 +183,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa\n(abc|ac)\nbbb"); } - Y_UNIT_TEST(DifferentDelimiters) { + Y_UNIT_TEST(DifferentDelimiters) { TDiffTester tester; tester.Test("aaa bbb", "aaa\tbbb"); diff --git a/library/cpp/digest/argonish/ut/ut.cpp b/library/cpp/digest/argonish/ut/ut.cpp index e663ac15ac..12ef530a18 100644 --- a/library/cpp/digest/argonish/ut/ut.cpp +++ b/library/cpp/digest/argonish/ut/ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/digest/argonish/blake2b.h> #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(ArgonishTest) { +Y_UNIT_TEST_SUITE(ArgonishTest) { const ui8 GenKatPassword[32] = { 0x01, 0x01, @@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { 0x04, }; - Y_UNIT_TEST(Argon2_Fr_Test) { + Y_UNIT_TEST(Argon2_Fr_Test) { const ui32 mcost = 16; const ui32 tcost = 1; TArrayHolder<ui8> memory(new ui8[mcost * 1024]); @@ -176,7 +176,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2_Factory_SelfTest) { + Y_UNIT_TEST(Argon2_Factory_SelfTest) { try { NArgonish::TArgon2Factory factory; factory.GetInstructionSet(); @@ -185,7 +185,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Blake2B_Factory_SelfTest) { + Y_UNIT_TEST(Blake2B_Factory_SelfTest) { try { NArgonish::TBlake2BFactory factory; factory.GetInstructionSet(); @@ -194,7 +194,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d) { + Y_UNIT_TEST(Argon2d) { const ui8 TResult[32] = { 0x7b, 0xa5, 0xa1, 0x7a, 0x72, 0xf7, 0xe5, 0x99, 0x77, 0xf7, 0xf2, 0x3d, 0x10, 0xe6, 0x21, 0x89, @@ -221,7 +221,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i) { + Y_UNIT_TEST(Argon2i) { const ui8 TResult[32] = { 0x87, 0x4d, 0x23, 0xfb, 0x9f, 0x55, 0xe2, 0xff, 0x66, 0xbc, 0x19, 0x03, 0x46, 0xe7, 0x01, 0x19, @@ -248,7 +248,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id) { + Y_UNIT_TEST(Argon2id) { const ui8 TResult[32] = { 0x99, 0xdf, 0xcf, 0xc2, 0x89, 0x76, 0x93, 0x9d, 0xa2, 0x97, 0x09, 0x44, 0x34, 0xd8, 0x6f, 0xd0, @@ -275,7 +275,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p) { + Y_UNIT_TEST(Argon2d_2p) { const ui8 TResult[32] = { 0x59, 0xb0, 0x94, 0x62, 0xcf, 0xdc, 0xd2, 0xb4, 0x0a, 0xbd, 0x17, 0x81, 0x0a, 0x47, 0x4a, 0x8e, @@ -302,7 +302,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i_2p) { + Y_UNIT_TEST(Argon2i_2p) { const ui8 TResult[32] = { 0xc1, 0x0f, 0x00, 0x5e, 0xf8, 0x78, 0xc8, 0x07, 0x0e, 0x2c, 0xc5, 0x2f, 0x57, 0x75, 0x25, 0xc9, @@ -329,7 +329,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id_2p) { + Y_UNIT_TEST(Argon2id_2p) { const ui8 TResult[32] = { 0x6c, 0x00, 0xb7, 0xa9, 0x00, 0xe5, 0x00, 0x4c, 0x24, 0x46, 0x9e, 0xc1, 0xe7, 0xc0, 0x1a, 0x99, @@ -356,7 +356,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p_2th) { + Y_UNIT_TEST(Argon2d_2p_2th) { const ui8 TResult[32] = { 0x2b, 0x47, 0x35, 0x39, 0x4a, 0x40, 0x3c, 0xc9, 0x05, 0xfb, 0x51, 0x25, 0x96, 0x68, 0x64, 0x43, @@ -383,7 +383,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id_2p_4th) { + Y_UNIT_TEST(Argon2id_2p_4th) { const ui8 TResult[32] = { 0x4f, 0x93, 0xb5, 0xad, 0x78, 0xa4, 0xa9, 0x49, 0xfb, 0xe3, 0x55, 0x96, 0xd5, 0xa0, 0xc2, 0xab, @@ -410,7 +410,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p_4th) { + Y_UNIT_TEST(Argon2d_2p_4th) { const ui8 TResult[32] = { 0x8f, 0xa2, 0x7c, 0xed, 0x28, 0x38, 0x79, 0x0f, 0xba, 0x5c, 0x11, 0x85, 0x1c, 0xdf, 0x90, 0x88, @@ -437,7 +437,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i_2p_4th) { + Y_UNIT_TEST(Argon2i_2p_4th) { const ui8 TResult[32] = { 0x61, 0x1c, 0x99, 0x3c, 0xb0, 0xb7, 0x23, 0x16, 0xbd, 0xa2, 0x6c, 0x4c, 0x2f, 0xe8, 0x2d, 0x39, @@ -464,7 +464,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_128) { + Y_UNIT_TEST(Argon2d_128) { const ui8 TResult[128] = { 0x4e, 0xc4, 0x6c, 0x4e, 0x8c, 0x32, 0x89, 0x65, 0xf9, 0x82, 0x2b, 0x00, 0x95, 0x00, 0x50, 0x0a, @@ -503,7 +503,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Blake2B_16_ABC) { + Y_UNIT_TEST(Blake2B_16_ABC) { const ui8 TResult[16] = { 0xcf, 0x4a, 0xb7, 0x91, 0xc6, 0x2b, 0x8d, 0x2b, 0x21, 0x09, 0xc9, 0x02, 0x75, 0x28, 0x78, 0x16}; @@ -522,7 +522,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Blake2B_64_ABC) { + Y_UNIT_TEST(Blake2B_64_ABC) { const ui8 TResult[64] = { 0xba, 0x80, 0xa5, 0x3f, 0x98, 0x1c, 0x4d, 0x0d, 0x6a, 0x27, 0x97, 0xb6, 0x9f, 0x12, 0xf6, 0xe9, diff --git a/library/cpp/digest/argonish/ut_fat/ut.cpp b/library/cpp/digest/argonish/ut_fat/ut.cpp index 81bc9a696a..41fa001685 100644 --- a/library/cpp/digest/argonish/ut_fat/ut.cpp +++ b/library/cpp/digest/argonish/ut_fat/ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/digest/argonish/blake2b.h> #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(ArgonishTest) { +Y_UNIT_TEST_SUITE(ArgonishTest) { const ui8 GenKatPassword[32] = { 0x01, 0x01, @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { #endif ; - Y_UNIT_TEST(Argon2_Factory_SelfTest) { + Y_UNIT_TEST(Argon2_Factory_SelfTest) { try { NArgonish::TArgon2Factory factory; } catch (...) { @@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d) { + Y_UNIT_TEST(Argon2d) { const ui8 TResult[32] = { 0x7b, 0xa5, 0xa1, 0x7a, 0x72, 0xf7, 0xe5, 0x99, 0x77, 0xf7, 0xf2, 0x3d, 0x10, 0xe6, 0x21, 0x89, @@ -125,7 +125,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i) { + Y_UNIT_TEST(Argon2i) { const ui8 TResult[32] = { 0x87, 0x4d, 0x23, 0xfb, 0x9f, 0x55, 0xe2, 0xff, 0x66, 0xbc, 0x19, 0x03, 0x46, 0xe7, 0x01, 0x19, @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id) { + Y_UNIT_TEST(Argon2id) { const ui8 TResult[32] = { 0x99, 0xdf, 0xcf, 0xc2, 0x89, 0x76, 0x93, 0x9d, 0xa2, 0x97, 0x09, 0x44, 0x34, 0xd8, 0x6f, 0xd0, @@ -177,7 +177,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p) { + Y_UNIT_TEST(Argon2d_2p) { const ui8 TResult[32] = { 0x59, 0xb0, 0x94, 0x62, 0xcf, 0xdc, 0xd2, 0xb4, 0x0a, 0xbd, 0x17, 0x81, 0x0a, 0x47, 0x4a, 0x8e, @@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i_2p) { + Y_UNIT_TEST(Argon2i_2p) { const ui8 TResult[32] = { 0xc1, 0x0f, 0x00, 0x5e, 0xf8, 0x78, 0xc8, 0x07, 0x0e, 0x2c, 0xc5, 0x2f, 0x57, 0x75, 0x25, 0xc9, @@ -229,7 +229,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id_2p) { + Y_UNIT_TEST(Argon2id_2p) { const ui8 TResult[32] = { 0x6c, 0x00, 0xb7, 0xa9, 0x00, 0xe5, 0x00, 0x4c, 0x24, 0x46, 0x9e, 0xc1, 0xe7, 0xc0, 0x1a, 0x99, @@ -255,7 +255,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p_2th) { + Y_UNIT_TEST(Argon2d_2p_2th) { const ui8 TResult[32] = { 0x2b, 0x47, 0x35, 0x39, 0x4a, 0x40, 0x3c, 0xc9, 0x05, 0xfb, 0x51, 0x25, 0x96, 0x68, 0x64, 0x43, @@ -281,7 +281,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2id_2p_4th) { + Y_UNIT_TEST(Argon2id_2p_4th) { const ui8 TResult[32] = { 0x4f, 0x93, 0xb5, 0xad, 0x78, 0xa4, 0xa9, 0x49, 0xfb, 0xe3, 0x55, 0x96, 0xd5, 0xa0, 0xc2, 0xab, @@ -307,7 +307,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_2p_4th) { + Y_UNIT_TEST(Argon2d_2p_4th) { const ui8 TResult[32] = { 0x8f, 0xa2, 0x7c, 0xed, 0x28, 0x38, 0x79, 0x0f, 0xba, 0x5c, 0x11, 0x85, 0x1c, 0xdf, 0x90, 0x88, @@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2i_2p_4th) { + Y_UNIT_TEST(Argon2i_2p_4th) { const ui8 TResult[32] = { 0x61, 0x1c, 0x99, 0x3c, 0xb0, 0xb7, 0x23, 0x16, 0xbd, 0xa2, 0x6c, 0x4c, 0x2f, 0xe8, 0x2d, 0x39, @@ -359,7 +359,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Argon2d_128) { + Y_UNIT_TEST(Argon2d_128) { const ui8 TResult[128] = { 0x4e, 0xc4, 0x6c, 0x4e, 0x8c, 0x32, 0x89, 0x65, 0xf9, 0x82, 0x2b, 0x00, 0x95, 0x00, 0x50, 0x0a, @@ -397,7 +397,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Blake2B_16_ABC) { + Y_UNIT_TEST(Blake2B_16_ABC) { const ui8 TResult[16] = { 0xcf, 0x4a, 0xb7, 0x91, 0xc6, 0x2b, 0x8d, 0x2b, 0x21, 0x09, 0xc9, 0x02, 0x75, 0x28, 0x78, 0x16}; @@ -415,7 +415,7 @@ Y_UNIT_TEST_SUITE(ArgonishTest) { } } - Y_UNIT_TEST(Blake2B_64_ABC) { + Y_UNIT_TEST(Blake2B_64_ABC) { const ui8 TResult[64] = { 0xba, 0x80, 0xa5, 0x3f, 0x98, 0x1c, 0x4d, 0x0d, 0x6a, 0x27, 0x97, 0xb6, 0x9f, 0x12, 0xf6, 0xe9, diff --git a/library/cpp/digest/crc32c/crc32c_ut.cpp b/library/cpp/digest/crc32c/crc32c_ut.cpp index 1343fb80c1..aa31b83422 100644 --- a/library/cpp/digest/crc32c/crc32c_ut.cpp +++ b/library/cpp/digest/crc32c/crc32c_ut.cpp @@ -2,12 +2,12 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestCrc32c) { - Y_UNIT_TEST(TestCalc) { +Y_UNIT_TEST_SUITE(TestCrc32c) { + Y_UNIT_TEST(TestCalc) { UNIT_ASSERT_VALUES_EQUAL(Crc32c("abc", 3), ui32(910901175)); } - Y_UNIT_TEST(TestUnaligned) { + Y_UNIT_TEST(TestUnaligned) { const TString str(1000, 'a'); for (size_t substrLen = 0; substrLen <= str.length(); ++substrLen) { const ui32 crc = Crc32c(str.data(), substrLen); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TestCrc32c) { } } - Y_UNIT_TEST(TestExtend) { + Y_UNIT_TEST(TestExtend) { UNIT_ASSERT_VALUES_EQUAL(Crc32cExtend(1, "abc", 3), ui32(2466950601)); } } diff --git a/library/cpp/digest/lower_case/hash_ops_ut.cpp b/library/cpp/digest/lower_case/hash_ops_ut.cpp index 645ef7bb5c..a7ab0b86ea 100644 --- a/library/cpp/digest/lower_case/hash_ops_ut.cpp +++ b/library/cpp/digest/lower_case/hash_ops_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestCIHash) { - Y_UNIT_TEST(TestYHash1) { +Y_UNIT_TEST_SUITE(TestCIHash) { + Y_UNIT_TEST(TestYHash1) { THashMap<TStringBuf, int, TCIOps, TCIOps> h; h["Ab"] = 1; @@ -13,7 +13,7 @@ Y_UNIT_TEST_SUITE(TestCIHash) { UNIT_ASSERT_VALUES_EQUAL(h["ab"], 2); } - Y_UNIT_TEST(TestYHash2) { + Y_UNIT_TEST(TestYHash2) { THashMap<const char*, int, TCIOps, TCIOps> h; h["Ab"] = 1; @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TestCIHash) { UNIT_ASSERT_VALUES_EQUAL(h["bc"], 3); } - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { UNIT_ASSERT_VALUES_EQUAL(TCIOps()("aBc3"), TCIOps()(TStringBuf("AbC3"))); UNIT_ASSERT(TCIOps()("aBc4", "AbC4")); } diff --git a/library/cpp/digest/lower_case/lchash_ut.cpp b/library/cpp/digest/lower_case/lchash_ut.cpp index acd9f64934..5711fe7cd7 100644 --- a/library/cpp/digest/lower_case/lchash_ut.cpp +++ b/library/cpp/digest/lower_case/lchash_ut.cpp @@ -2,19 +2,19 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TWebDaemonHash) { - Y_UNIT_TEST(Stability) { +Y_UNIT_TEST_SUITE(TWebDaemonHash) { + Y_UNIT_TEST(Stability) { UNIT_ASSERT_VALUES_EQUAL(FnvCaseLess<ui64>("blah"), ULL(5923727754379976229)); UNIT_ASSERT_VALUES_EQUAL(FnvCaseLess<ui64>("blahminor"), ULL(8755704309003440816)); } - Y_UNIT_TEST(CaseLess) { + Y_UNIT_TEST(CaseLess) { UNIT_ASSERT_VALUES_EQUAL(FnvCaseLess<ui64>("blah"), FnvCaseLess<ui64>("bLah")); UNIT_ASSERT_VALUES_EQUAL(FnvCaseLess<ui64>("blah"), FnvCaseLess<ui64>("blAh")); UNIT_ASSERT_VALUES_EQUAL(FnvCaseLess<ui64>("blah"), FnvCaseLess<ui64>("BLAH")); } - Y_UNIT_TEST(Robustness) { + Y_UNIT_TEST(Robustness) { UNIT_ASSERT(FnvCaseLess<ui64>("x-real-ip") != FnvCaseLess<ui64>("x-req-id")); UNIT_ASSERT(FnvCaseLess<ui64>("x-real-ip") != FnvCaseLess<ui64>("x-start-time")); } diff --git a/library/cpp/digest/md5/md5.cpp b/library/cpp/digest/md5/md5.cpp index 60eda2abea..24a5b69eef 100644 --- a/library/cpp/digest/md5/md5.cpp +++ b/library/cpp/digest/md5/md5.cpp @@ -14,7 +14,7 @@ namespace { constexpr size_t MD5_PADDING_SHIFT = 56; constexpr size_t MD5_HEX_DIGEST_LENGTH = 32; - struct TMd5Stream: public IOutputStream { + struct TMd5Stream: public IOutputStream { inline TMd5Stream(MD5* md5) : M_(md5) { @@ -44,7 +44,7 @@ char* MD5::File(const char* filename, char* buf) { } catch (...) { } - return nullptr; + return nullptr; } TString MD5::File(const TString& filename) { @@ -61,7 +61,7 @@ char* MD5::Data(const TArrayRef<const ui8>& data, char* buf) { return MD5().Update(data).End(buf); } -char* MD5::Data(const void* data, size_t len, char* buf) { +char* MD5::Data(const void* data, size_t len, char* buf) { return Data(MakeUnsignedArrayRef(data, len), buf); } @@ -76,11 +76,11 @@ TString MD5::Data(TStringBuf data) { return Data(MakeUnsignedArrayRef(data)); } -char* MD5::Stream(IInputStream* in, char* buf) { +char* MD5::Stream(IInputStream* in, char* buf) { return MD5().Update(in).End(buf); } -MD5& MD5::Update(IInputStream* in) { +MD5& MD5::Update(IInputStream* in) { TMd5Stream md5(this); TransferData(in, &md5); @@ -179,7 +179,7 @@ char* MD5::End(char* buf) { if (!buf) buf = (char*)malloc(33); if (!buf) - return nullptr; + return nullptr; Final(digest); for (ui8 i = 0; i < MD5_HEX_DIGEST_LENGTH / 2; i++) { buf[i * 2] = hex[digest[i] >> 4]; @@ -194,10 +194,10 @@ char* MD5::End_b64(char* buf) { if (!buf) buf = (char*)malloc(25); if (!buf) - return nullptr; + return nullptr; Final(digest); Base64Encode(buf, digest, 16); - buf[24] = '\0'; + buf[24] = '\0'; return buf; } diff --git a/library/cpp/digest/md5/md5.h b/library/cpp/digest/md5/md5.h index 74c002a82c..2c17aa0518 100644 --- a/library/cpp/digest/md5/md5.h +++ b/library/cpp/digest/md5/md5.h @@ -3,7 +3,7 @@ #include <util/generic/array_ref.h> #include <util/generic/strbuf.h> -class IInputStream; +class IInputStream; class MD5 { public: @@ -38,7 +38,7 @@ public: // 8-byte xor-based mix ui64 EndHalfMix(); - MD5& Update(IInputStream* in); + MD5& Update(IInputStream* in); /* * Return hex-encoded md5 checksum for given file. @@ -48,11 +48,11 @@ public: static char* File(const char* filename, char* buf); static TString File(const TString& filename); - static char* Data(const void* data, size_t len, char* buf); + static char* Data(const void* data, size_t len, char* buf); static char* Data(const TArrayRef<const ui8>& data, char* buf); static TString Data(const TArrayRef<const ui8>& data); static TString Data(TStringBuf data); - static char* Stream(IInputStream* in, char* buf); + static char* Stream(IInputStream* in, char* buf); static TString Calc(TStringBuf data); // 32-byte hex-encoded static TString Calc(const TArrayRef<const ui8>& data); // 32-byte hex-encoded diff --git a/library/cpp/digest/md5/md5_medium_ut.cpp b/library/cpp/digest/md5/md5_medium_ut.cpp index 4ea147ff36..a940c5cb66 100644 --- a/library/cpp/digest/md5/md5_medium_ut.cpp +++ b/library/cpp/digest/md5/md5_medium_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TMD5MediumTest) { - Y_UNIT_TEST(TestOverflow) { +Y_UNIT_TEST_SUITE(TMD5MediumTest) { + Y_UNIT_TEST(TestOverflow) { if (sizeof(size_t) > sizeof(unsigned int)) { const size_t maxUi32 = (size_t)Max<unsigned int>(); TArrayHolder<char> buf(new char[maxUi32]); diff --git a/library/cpp/digest/md5/md5_ut.cpp b/library/cpp/digest/md5/md5_ut.cpp index 7c955f2f5a..1c3e4ad0a9 100644 --- a/library/cpp/digest/md5/md5_ut.cpp +++ b/library/cpp/digest/md5/md5_ut.cpp @@ -5,8 +5,8 @@ #include <util/system/fs.h> #include <util/stream/file.h> -Y_UNIT_TEST_SUITE(TMD5Test) { - Y_UNIT_TEST(TestMD5) { +Y_UNIT_TEST_SUITE(TMD5Test) { + Y_UNIT_TEST(TestMD5) { // echo -n 'qwertyuiopqwertyuiopasdfghjklasdfghjkl' | md5sum constexpr const char* b = "qwertyuiopqwertyuiopasdfghjklasdfghjkl"; @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TMD5Test) { UNIT_ASSERT_NO_DIFF(result, TStringBuf("3ac00dd696b966fd74deee3c35a59d8f")); } - Y_UNIT_TEST(TestFile) { + Y_UNIT_TEST(TestFile) { TString s = NUnitTest::RandomString(1000000, 1); const TString tmpFile = "tmp"; @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TMD5Test) { UNIT_ASSERT_EQUAL(fileHash.size(), 0); } - Y_UNIT_TEST(TestIsMD5) { + Y_UNIT_TEST(TestIsMD5) { UNIT_ASSERT_EQUAL(false, MD5::IsMD5(TStringBuf())); UNIT_ASSERT_EQUAL(false, MD5::IsMD5(TStringBuf("4136ebb0e4c45d21e2b09294c75cfa0"))); // length 31 UNIT_ASSERT_EQUAL(false, MD5::IsMD5(TStringBuf("4136ebb0e4c45d21e2b09294c75cfa000"))); // length 33 diff --git a/library/cpp/digest/md5/ya.make b/library/cpp/digest/md5/ya.make index 16575b3926..c09ec1c326 100644 --- a/library/cpp/digest/md5/ya.make +++ b/library/cpp/digest/md5/ya.make @@ -9,9 +9,9 @@ SRCS( md5.cpp ) -PEERDIR( +PEERDIR( contrib/libs/nayuki_md5 library/cpp/string_utils/base64 -) - +) + END() diff --git a/library/cpp/digest/old_crc/crc_ut.cpp b/library/cpp/digest/old_crc/crc_ut.cpp index b53225729f..46e1d5d29b 100644 --- a/library/cpp/digest/old_crc/crc_ut.cpp +++ b/library/cpp/digest/old_crc/crc_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> class TCrcTest: public TTestBase { UNIT_TEST_SUITE(TCrcTest); diff --git a/library/cpp/digest/old_crc/gencrc/main.cpp b/library/cpp/digest/old_crc/gencrc/main.cpp index d718fe67b7..d5821304ce 100644 --- a/library/cpp/digest/old_crc/gencrc/main.cpp +++ b/library/cpp/digest/old_crc/gencrc/main.cpp @@ -1,4 +1,4 @@ -#include <util/stream/output.h> +#include <util/stream/output.h> #define POLY_16 0x1021 #define POLY_32 0xEDB88320UL diff --git a/library/cpp/digest/sfh/sfh.h b/library/cpp/digest/sfh/sfh.h index 38cd654e1e..372938654c 100644 --- a/library/cpp/digest/sfh/sfh.h +++ b/library/cpp/digest/sfh/sfh.h @@ -1,7 +1,7 @@ #pragma once #include <util/system/defaults.h> -#include <util/system/unaligned_mem.h> +#include <util/system/unaligned_mem.h> inline ui32 SuperFastHash(const void* d, size_t l) noexcept { ui32 hash = (ui32)l; diff --git a/library/cpp/digest/sfh/sfh_ut.cpp b/library/cpp/digest/sfh/sfh_ut.cpp index d7b9c2fbf9..912999bae7 100644 --- a/library/cpp/digest/sfh/sfh_ut.cpp +++ b/library/cpp/digest/sfh/sfh_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> class TSfhTest: public TTestBase { UNIT_TEST_SUITE(TSfhTest); diff --git a/library/cpp/dns/cache.cpp b/library/cpp/dns/cache.cpp index fe2bf56496..05c14e82fc 100644 --- a/library/cpp/dns/cache.cpp +++ b/library/cpp/dns/cache.cpp @@ -122,7 +122,7 @@ namespace { } else if (rt.Method == TResolveTask::Threaded) { na = ThreadedResolve(host, rt.Info.Port); } else { - Y_ASSERT(0); + Y_ASSERT(0); throw yexception() << TStringBuf("invalid resolve method"); } diff --git a/library/cpp/dns/ut/dns_ut.cpp b/library/cpp/dns/ut/dns_ut.cpp index edf8c8f431..aae05a742c 100644 --- a/library/cpp/dns/ut/dns_ut.cpp +++ b/library/cpp/dns/ut/dns_ut.cpp @@ -2,14 +2,14 @@ #include <library/cpp/dns/cache.h> #include <util/network/address.h> -Y_UNIT_TEST_SUITE(TestDNS) { +Y_UNIT_TEST_SUITE(TestDNS) { using namespace NDns; - Y_UNIT_TEST(TestMagic) { + Y_UNIT_TEST(TestMagic) { UNIT_ASSERT_EXCEPTION(CachedThrResolve(TResolveInfo("?", 80)), yexception); } - Y_UNIT_TEST(TestAsteriskAlias) { + Y_UNIT_TEST(TestAsteriskAlias) { AddHostAlias("*", "localhost"); const TResolvedHost* rh = CachedThrResolve(TResolveInfo("yandex.ru", 80)); UNIT_ASSERT(rh != nullptr); diff --git a/library/cpp/enumbitset/enumbitset.h b/library/cpp/enumbitset/enumbitset.h index 433132358a..41864c3a04 100644 --- a/library/cpp/enumbitset/enumbitset.h +++ b/library/cpp/enumbitset/enumbitset.h @@ -1,11 +1,11 @@ #pragma once -#include <util/ysaveload.h> -#include <util/generic/bitmap.h> +#include <util/ysaveload.h> +#include <util/generic/bitmap.h> #include <util/generic/serialized_enum.h> -#include <util/generic/yexception.h> -#include <util/string/cast.h> -#include <util/string/printf.h> +#include <util/generic/yexception.h> +#include <util/string/cast.h> +#include <util/string/printf.h> #include <util/system/yassert.h> // Stack memory bitmask for TEnum values [begin, end). @@ -134,7 +134,7 @@ public: } bool operator<(const TThis& right) const { - Y_ASSERT(this->GetChunkCount() == right.GetChunkCount()); + Y_ASSERT(this->GetChunkCount() == right.GetChunkCount()); for (size_t i = 0; i < this->GetChunkCount(); ++i) { if (this->GetChunks()[i] < right.GetChunks()[i]) return true; @@ -258,7 +258,7 @@ public: } //serialization to/from stream - void Save(IOutputStream* buffer) const { + void Save(IOutputStream* buffer) const { ::Save(buffer, (ui32)Count()); for (TEnum bit : *this) { ::Save(buffer, (ui32)bit); @@ -363,7 +363,7 @@ public: } TEnum operator*() const noexcept { - Y_ASSERT(Value < EndIndex); + Y_ASSERT(Value < EndIndex); return static_cast<TEnum>(Value); } @@ -372,7 +372,7 @@ public: } TIterator& operator++() noexcept { - Y_ASSERT(Value < EndIndex); + Y_ASSERT(Value < EndIndex); TEnum res; if (BitMap->FindNext(static_cast<TEnum>(Value), res)) { Value = static_cast<int>(res); @@ -399,7 +399,7 @@ public: private: static size_t Pos(TEnum c) { - Y_ASSERT(IsValid(c)); + Y_ASSERT(IsValid(c)); return static_cast<size_t>(int(c) - BeginIndex); } diff --git a/library/cpp/enumbitset/enumbitset_ut.cpp b/library/cpp/enumbitset/enumbitset_ut.cpp index 2c95603347..e55b3251c3 100644 --- a/library/cpp/enumbitset/enumbitset_ut.cpp +++ b/library/cpp/enumbitset/enumbitset_ut.cpp @@ -21,8 +21,8 @@ enum ETestEnum { }; using TTestBitSet = TEnumBitSet<ETestEnum, TE_FIRST, TE_MAX>; -Y_UNIT_TEST_SUITE(TEnumBitSetTest) { - Y_UNIT_TEST(TestMainFunctions) { +Y_UNIT_TEST_SUITE(TEnumBitSetTest) { + Y_UNIT_TEST(TestMainFunctions) { auto ebs = TTestBitSet(TE_FIRST, TE_MIDDLE); UNIT_ASSERT(ebs.SafeTest(TE_FIRST)); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(TEnumBitSetTest) { UNIT_ASSERT(!ebs.SafeTest(TE_OVERFLOW)); } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { TTestBitSet mask; UNIT_ASSERT(mask.Empty()); if (mask) @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TEnumBitSetTest) { UNIT_ASSERT(false && "should not be empty"); } - Y_UNIT_TEST(TestIter) { + Y_UNIT_TEST(TestIter) { TTestBitSet mask = TTestBitSet(TE_1, TE_3, TE_7); TTestBitSet mask2; @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(TEnumBitSetTest) { UNIT_ASSERT(mask == mask2); } - Y_UNIT_TEST(TestSerialization) { + Y_UNIT_TEST(TestSerialization) { auto ebs = TTestBitSet(TE_MIDDLE, TE_6, TE_7); TStringStream ss; @@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TEnumBitSetTest) { UNIT_ASSERT_EQUAL(ebs, ebs2); } - Y_UNIT_TEST(TestStringRepresentation) { + Y_UNIT_TEST(TestStringRepresentation) { auto ebs = TTestBitSet(TE_MIDDLE, TE_6, TE_7); UNIT_ASSERT_EQUAL(ebs.ToString(), "D00000000000000000"); diff --git a/library/cpp/execprofile/profile.cpp b/library/cpp/execprofile/profile.cpp index 43559884e4..d05de20203 100644 --- a/library/cpp/execprofile/profile.cpp +++ b/library/cpp/execprofile/profile.cpp @@ -136,7 +136,7 @@ private: } ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); - Y_ASSERT(SInstance != nullptr); + Y_ASSERT(SInstance != nullptr); SInstance->CaptureIP(GetIp(&ucontext->uc_mcontext)); } @@ -241,7 +241,7 @@ private: void Clear() { - Y_ASSERT(WriteFlag == 1); + Y_ASSERT(WriteFlag == 1); for (size_t i = 0; i < SZ; ++i) { Ips[i] = std::make_pair((void*)nullptr, (size_t)0); diff --git a/library/cpp/getopt/small/last_getopt_parser.cpp b/library/cpp/getopt/small/last_getopt_parser.cpp index aec0f97252..7668b12a03 100644 --- a/library/cpp/getopt/small/last_getopt_parser.cpp +++ b/library/cpp/getopt/small/last_getopt_parser.cpp @@ -232,7 +232,7 @@ namespace NLastGetopt { Pos_ = pc; bool r = ParseOptArg(Pos_); - Y_ASSERT(r); + Y_ASSERT(r); while (Pos_ == pc) { Y_ASSERT(Sop_ > 0); r = ParseShortOptWithinArg(Pos_, Sop_); diff --git a/library/cpp/getopt/small/modchooser.cpp b/library/cpp/getopt/small/modchooser.cpp index 91cc88dc22..2fa5cfd070 100644 --- a/library/cpp/getopt/small/modchooser.cpp +++ b/library/cpp/getopt/small/modchooser.cpp @@ -290,7 +290,7 @@ void TModChooser::PrintHelp(const TString& progName) const { } if (ShowSeparated) { - for (const auto& unsortedMode : UnsortedModes) + for (const auto& unsortedMode : UnsortedModes) if (!unsortedMode->Hidden) { if (unsortedMode->Name.size()) { Cerr << " " << unsortedMode->FormatFullName(maxModeLen + 4) << unsortedMode->Description << Endl; diff --git a/library/cpp/getopt/small/opt.cpp b/library/cpp/getopt/small/opt.cpp index 9cc4b9c6fe..744501765c 100644 --- a/library/cpp/getopt/small/opt.cpp +++ b/library/cpp/getopt/small/opt.cpp @@ -88,7 +88,7 @@ int Opt::Get(int* longOptionIndex) { } } -void Opt::DummyHelp(IOutputStream& os) { +void Opt::DummyHelp(IOutputStream& os) { Opts_->PrintUsage(GetProgramName(), os); } diff --git a/library/cpp/getopt/small/opt.h b/library/cpp/getopt/small/opt.h index ad057edb67..ecb57439bc 100644 --- a/library/cpp/getopt/small/opt.h +++ b/library/cpp/getopt/small/opt.h @@ -106,7 +106,7 @@ public: int GetArgC() const; const char** GetArgV() const; - void DummyHelp(IOutputStream& os = Cerr); + void DummyHelp(IOutputStream& os = Cerr); }; // call before getopt. returns non-negative int, removing it from arguments (not found: -1) diff --git a/library/cpp/getopt/small/opt2.cpp b/library/cpp/getopt/small/opt2.cpp index c3316ffe04..0cdc774e78 100644 --- a/library/cpp/getopt/small/opt2.cpp +++ b/library/cpp/getopt/small/opt2.cpp @@ -272,16 +272,16 @@ int Opt2::AutoUsage(const char* free_arg_names) { fprintf(where, "Usage: %s%s%s%s%s%s%s%s\n", prog, req ? " -" : "", req_str, nreq ? " [-" : "", nreq_str, nreq ? "]" : "", free_arg_names && *free_arg_names ? " " : "", free_arg_names); - for (auto& spec : Specs) { + for (auto& spec : Specs) { const char* hlp = !spec.HelpUsage.empty() ? spec.HelpUsage.data() : spec.HasArg ? "<arg>" : ""; - if (!spec.HasArg || spec.IsRequired) - fprintf(where, " -%c %s\n", spec.opt, hlp); - else if (!spec.IsNumeric) - fprintf(where, " -%c %s [Default: %s]\n", spec.opt, hlp, spec.DefValue); + if (!spec.HasArg || spec.IsRequired) + fprintf(where, " -%c %s\n", spec.opt, hlp); + else if (!spec.IsNumeric) + fprintf(where, " -%c %s [Default: %s]\n", spec.opt, hlp, spec.DefValue); else - fprintf(where, " -%c %s [Def.val: %li]\n", spec.opt, hlp, (long)(uintptr_t)spec.DefValue); - if (spec.LongOptName) - fprintf(where, " --%s%s - same as -%c\n", spec.LongOptName, spec.HasArg ? "=<argument>" : "", spec.opt); + fprintf(where, " -%c %s [Def.val: %li]\n", spec.opt, hlp, (long)(uintptr_t)spec.DefValue); + if (spec.LongOptName) + fprintf(where, " --%s%s - same as -%c\n", spec.LongOptName, spec.HasArg ? "=<argument>" : "", spec.opt); } if (OptionMissingArg) fprintf(where, " *** Option '%c' is missing required argument\n", OptionMissingArg); @@ -300,7 +300,7 @@ int Opt2::AutoUsage(const char* free_arg_names) { fprintf(where, " *** %i free argument(s) supplied, expected %i to %i\n", (int)Pos.size(), MinArgs, MaxArgs); if (BadPosCount && MinArgs == MaxArgs) fprintf(where, " *** %i free argument(s) supplied, expected %i\n", (int)Pos.size(), MinArgs); - for (const auto& userErrorMessage : UserErrorMessages) + for (const auto& userErrorMessage : UserErrorMessages) fprintf(where, " *** %s\n", userErrorMessage.data()); return UnknownOption == '?' ? 1 : 2; } diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp index 393ef79d8e..c99a1d053d 100644 --- a/library/cpp/getopt/ut/last_getopt_ut.cpp +++ b/library/cpp/getopt/ut/last_getopt_ut.cpp @@ -132,8 +132,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TLastGetoptTests) { - Y_UNIT_TEST(TestEqual) { +Y_UNIT_TEST_SUITE(TLastGetoptTests) { + Y_UNIT_TEST(TestEqual) { TOptsNoDefault opts; opts.AddLongOption("from"); opts.AddLongOption("to"); @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_EXCEPTION(r.Get("left"), TException); } - Y_UNIT_TEST(TestCharOptions) { + Y_UNIT_TEST(TestCharOptions) { TOptsNoDefault opts; opts.AddCharOption('R', NO_ARGUMENT); opts.AddCharOption('l', NO_ARGUMENT); @@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL("/tmp/etc", r.GetFreeArgs()[1]); } - Y_UNIT_TEST(TestFreeArgs) { + Y_UNIT_TEST(TestFreeArgs) { TOptsNoDefault opts; opts.SetFreeArgsNum(1, 3); TOptsParseResultTestWrapper r11(&opts, V({"cp", "/etc"})); @@ -184,7 +184,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { TOptsParseResultTestWrapper r22(&opts, V({"cp", "/etc", "/var/tmp"})); } - Y_UNIT_TEST(TestCharOptionsRequiredOptional) { + Y_UNIT_TEST(TestCharOptionsRequiredOptional) { TOptsNoDefault opts; opts.AddCharOption('d', REQUIRED_ARGUMENT); opts.AddCharOption('e', REQUIRED_ARGUMENT); @@ -198,7 +198,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL("44", r.Get('y')); } - Y_UNIT_TEST(TestReturnInOrder) { + Y_UNIT_TEST(TestReturnInOrder) { TOptsParserTester tester; tester.Opts_.AddLongOption('v', "value"); tester.Opts_.ArgPermutation_ = RETURN_IN_ORDER; @@ -222,7 +222,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestRequireOrder) { + Y_UNIT_TEST(TestRequireOrder) { TOptsParserTester tester; tester.Opts_.ArgPermutation_ = REQUIRE_ORDER; tester.Opts_.AddLongOption('v', "value"); @@ -242,7 +242,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestPlusForLongOption) { + Y_UNIT_TEST(TestPlusForLongOption) { TOptsParserTester tester; tester.Opts_.AddLongOption('v', "value"); tester.Opts_.AllowPlusForLong_ = true; @@ -261,7 +261,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestBug1) { + Y_UNIT_TEST(TestBug1) { TOptsParserTester tester; tester.Opts_.AddCharOptions("A:b:cd:"); @@ -283,7 +283,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestPermuteComplex) { + Y_UNIT_TEST(TestPermuteComplex) { TOptsParserTester tester; tester.Opts_.AddCharOption('x').NoArgument(); @@ -311,7 +311,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestFinalDashDash) { + Y_UNIT_TEST(TestFinalDashDash) { TOptsParserTester tester; tester.Opts_.AddLongOption("size"); @@ -322,7 +322,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestDashDashAfterDashDash) { + Y_UNIT_TEST(TestDashDashAfterDashDash) { TOptsParserTester tester; tester.Opts_.AddLongOption("size"); @@ -337,7 +337,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptEndOfFreeArgs(); } - Y_UNIT_TEST(TestUnexpectedUnknownOption) { + Y_UNIT_TEST(TestUnexpectedUnknownOption) { TOptsParserTester tester; tester.Argv_.push_back("cmd"); @@ -346,7 +346,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { tester.AcceptUnexpectedOption(); } - Y_UNIT_TEST(TestDuplicatedOptionCrash) { + Y_UNIT_TEST(TestDuplicatedOptionCrash) { // this test is broken, cause UNIT_ASSERT(false) always throws return; @@ -363,7 +363,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT(exception); } - Y_UNIT_TEST(TestPositionWhenNoArgs) { + Y_UNIT_TEST(TestPositionWhenNoArgs) { TOptsParserTester tester; tester.Argv_.push_back("cmd"); @@ -375,7 +375,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL(1u, tester.Parser_->Pos_); } - Y_UNIT_TEST(TestExpectedUnknownCharOption) { + Y_UNIT_TEST(TestExpectedUnknownCharOption) { TOptsParserTester tester; tester.Argv_.push_back("cmd"); @@ -400,7 +400,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } #if 0 - Y_UNIT_TEST(TestRequiredParams) { + Y_UNIT_TEST(TestRequiredParams) { TOptsParserTester tester; tester.Argv_.push_back("cmd"); @@ -415,7 +415,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } #endif - Y_UNIT_TEST(TestStoreResult) { + Y_UNIT_TEST(TestStoreResult) { TOptsNoDefault opts; TString data; int number; @@ -436,7 +436,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL(*optionalNumber1, 8); } - Y_UNIT_TEST(TestStoreValue) { + Y_UNIT_TEST(TestStoreValue) { int a = 0, b = 0; size_t c = 0; EHasArg e = NO_ARGUMENT; @@ -454,7 +454,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL(12345u, c); } - Y_UNIT_TEST(TestSetFlag) { + Y_UNIT_TEST(TestSetFlag) { bool a = false, b = true, c = false, d = true; TOptsNoDefault opts; @@ -471,7 +471,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT(!d); } - Y_UNIT_TEST(TestDefaultValue) { + Y_UNIT_TEST(TestDefaultValue) { TOptsNoDefault opts; opts.AddLongOption("path").DefaultValue("/etc"); int value = 42; @@ -481,7 +481,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL(32, value); } - Y_UNIT_TEST(TestSplitValue) { + Y_UNIT_TEST(TestSplitValue) { TOptsNoDefault opts; TVector<TString> vals; opts.AddLongOption('s', "split").SplitHandler(&vals, ','); @@ -492,7 +492,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_EQUAL(vals[2], "c"); } - Y_UNIT_TEST(TestRangeSplitValue) { + Y_UNIT_TEST(TestRangeSplitValue) { TOptsNoDefault opts; TVector<ui32> vals; opts.AddLongOption('s', "split").RangeSplitHandler(&vals, ',', '-'); @@ -507,7 +507,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_EQUAL(vals[6], 14); } - Y_UNIT_TEST(TestParseArgs) { + Y_UNIT_TEST(TestParseArgs) { TOptsNoDefault o("AbCx:y:z::"); UNIT_ASSERT_EQUAL(o.GetCharOption('A').HasArg_, NO_ARGUMENT); UNIT_ASSERT_EQUAL(o.GetCharOption('b').HasArg_, NO_ARGUMENT); @@ -517,7 +517,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_EQUAL(o.GetCharOption('z').HasArg_, OPTIONAL_ARGUMENT); } - Y_UNIT_TEST(TestRequiredOpts) { + Y_UNIT_TEST(TestRequiredOpts) { TOptsNoDefault opts; TOpt& opt_d = opts.AddCharOption('d'); @@ -547,7 +547,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { *Flag = true; } }; - Y_UNIT_TEST(TestHandlers) { + Y_UNIT_TEST(TestHandlers) { { TOptsNoDefault opts; bool flag = false; @@ -574,7 +574,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } } - Y_UNIT_TEST(TestTitleAndPrintUsage) { + Y_UNIT_TEST(TestTitleAndPrintUsage) { TOpts opts; const char* prog = "my_program"; TString title = TString("Sample ") + TString(prog).Quote() + " application"; @@ -590,7 +590,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT(out.Str().find(" " + TString(prog) + " ") != TString::npos); } - Y_UNIT_TEST(TestCustomCmdLineDescr) { + Y_UNIT_TEST(TestCustomCmdLineDescr) { TOpts opts; const char* prog = "my_program"; TString customDescr = "<FILE|TABLE> USER [OPTIONS]"; @@ -604,7 +604,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT(out.Str().find(customDescr) != TString::npos); } - Y_UNIT_TEST(TestColorPrint) { + Y_UNIT_TEST(TestColorPrint) { TOpts opts; const char* prog = "my_program"; opts.AddLongOption("long_option").Required(); @@ -658,7 +658,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT(out2.Str().find(colors.OldColor()) == TString::npos); } - Y_UNIT_TEST(TestPadding) { + Y_UNIT_TEST(TestPadding) { const bool withColorsOpt[] = {false, true}; for (bool withColors : withColorsOpt) { TOpts opts; @@ -700,7 +700,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } } - Y_UNIT_TEST(TestAppendTo) { + Y_UNIT_TEST(TestAppendTo) { TVector<int> ints; TOptsNoDefault opts; @@ -726,7 +726,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL("//nice", std::get<0>(richPaths.at(1))); } - Y_UNIT_TEST(TestKVHandler) { + Y_UNIT_TEST(TestKVHandler) { TStringBuilder keyvals; TOptsNoDefault opts; @@ -737,7 +737,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL(keyvals, "x:1,y:2,z:3,"); } - Y_UNIT_TEST(TestEasySetup) { + Y_UNIT_TEST(TestEasySetup) { TEasySetup opts; bool flag = false; opts('v', "version", "print version information")('a', "abstract", "some abstract param", true)('b', "buffer", "SIZE", "some param with argument")('c', "count", "SIZE", "some param with required argument")('t', "true", HandlerStoreTrue(&flag), "Some arg with handler")("global", SimpleHander, "Another arg with handler"); @@ -768,7 +768,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } } - Y_UNIT_TEST(TestTOptsParseResultException) { + Y_UNIT_TEST(TestTOptsParseResultException) { // verify that TOptsParseResultException actually throws a TUsageException instead of exit() // not using wrapper here because it can hide bugs (see review #243810 and r2737774) TOptsNoDefault opts; diff --git a/library/cpp/getopt/ut/modchooser_ut.cpp b/library/cpp/getopt/ut/modchooser_ut.cpp index 430582e3f6..a14c8a5853 100644 --- a/library/cpp/getopt/ut/modchooser_ut.cpp +++ b/library/cpp/getopt/ut/modchooser_ut.cpp @@ -37,17 +37,17 @@ int Five(int argc, const char** argv) { typedef int (*F_PTR)(int, const char**); static const F_PTR FUNCTIONS[] = {One, Two, Three, Four, Five}; static const char* NAMES[] = {"one", "two", "three", "four", "five"}; -static_assert(Y_ARRAY_SIZE(FUNCTIONS) == Y_ARRAY_SIZE(NAMES), "Incorrect input tests data"); +static_assert(Y_ARRAY_SIZE(FUNCTIONS) == Y_ARRAY_SIZE(NAMES), "Incorrect input tests data"); -Y_UNIT_TEST_SUITE(TModChooserTest) { - Y_UNIT_TEST(TestModesSimpleRunner) { +Y_UNIT_TEST_SUITE(TModChooserTest) { + Y_UNIT_TEST(TestModesSimpleRunner) { TModChooser chooser; - for (size_t idx = 0; idx < Y_ARRAY_SIZE(NAMES); ++idx) { + for (size_t idx = 0; idx < Y_ARRAY_SIZE(NAMES); ++idx) { chooser.AddMode(NAMES[idx], FUNCTIONS[idx], NAMES[idx]); } // test argc, argv - for (size_t idx = 0; idx < Y_ARRAY_SIZE(NAMES); ++idx) { + for (size_t idx = 0; idx < Y_ARRAY_SIZE(NAMES); ++idx) { int argc = 2; const char* argv[] = {"UNITTEST", NAMES[idx], nullptr}; UNIT_ASSERT_EQUAL(static_cast<int>(idx) + 1, chooser.Run(argc, argv)); @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(TModChooserTest) { } } - Y_UNIT_TEST(TestHelpMessage) { + Y_UNIT_TEST(TestHelpMessage) { TModChooser chooser; int argc = 2; diff --git a/library/cpp/getopt/ut/opt2_ut.cpp b/library/cpp/getopt/ut/opt2_ut.cpp index 74aa2fe1d6..0e7464747c 100644 --- a/library/cpp/getopt/ut/opt2_ut.cpp +++ b/library/cpp/getopt/ut/opt2_ut.cpp @@ -4,8 +4,8 @@ //using namespace NLastGetopt; -Y_UNIT_TEST_SUITE(Opt2Test) { - Y_UNIT_TEST(TestSimple) { +Y_UNIT_TEST_SUITE(Opt2Test) { + Y_UNIT_TEST(TestSimple) { int argc = 8; char* argv[] = { (char*)"cmd", @@ -43,7 +43,7 @@ Y_UNIT_TEST_SUITE(Opt2Test) { UNIT_ASSERT_STRINGS_EQUAL("2", x.at(1)); } - Y_UNIT_TEST(TestErrors1) { + Y_UNIT_TEST(TestErrors1) { int argc = 4; char* argv[] = { (char*)"cmd", diff --git a/library/cpp/getopt/ut/opt_ut.cpp b/library/cpp/getopt/ut/opt_ut.cpp index ad9d36a45f..441aa493a0 100644 --- a/library/cpp/getopt/ut/opt_ut.cpp +++ b/library/cpp/getopt/ut/opt_ut.cpp @@ -3,8 +3,8 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/string/vector.h> -Y_UNIT_TEST_SUITE(OptTest) { - Y_UNIT_TEST(TestSimple) { +Y_UNIT_TEST_SUITE(OptTest) { + Y_UNIT_TEST(TestSimple) { int argc = 3; char* argv[] = { (char*)"cmd", (char*)"-x"}; @@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(OptTest) { UNIT_ASSERT_VALUES_EQUAL(EOF, opt.Get()); } - Y_UNIT_TEST(TestFreeArguments) { + Y_UNIT_TEST(TestFreeArguments) { Opt::Ion options[] = { {"some-option", Opt::WithArg, nullptr, 123}, {nullptr, Opt::WithoutArg, nullptr, 0}}; @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(OptTest) { UNIT_ASSERT_VALUES_EQUAL(JoinStrings(opts.GetFreeArgs(), ", "), "ARG1, ARG3"); } - Y_UNIT_TEST(TestLongOption) { + Y_UNIT_TEST(TestLongOption) { const int SOME_OPTION_ID = 12345678; Opt::Ion options[] = { {"some-option", Opt::WithArg, nullptr, SOME_OPTION_ID}, diff --git a/library/cpp/getopt/ut/posix_getopt_ut.cpp b/library/cpp/getopt/ut/posix_getopt_ut.cpp index 9689717dab..b6d374bf28 100644 --- a/library/cpp/getopt/ut/posix_getopt_ut.cpp +++ b/library/cpp/getopt/ut/posix_getopt_ut.cpp @@ -4,8 +4,8 @@ using namespace NLastGetopt; -Y_UNIT_TEST_SUITE(TPosixGetoptTest) { - Y_UNIT_TEST(TestSimple) { +Y_UNIT_TEST_SUITE(TPosixGetoptTest) { + Y_UNIT_TEST(TestSimple) { int argc = 6; const char* argv0[] = {"program", "-b", "-f1", "-f", "2", "zzzz"}; char** const argv = (char**)argv0; @@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) { UNIT_ASSERT_VALUES_EQUAL(5, NLastGetopt::optind); } - Y_UNIT_TEST(TestLong) { + Y_UNIT_TEST(TestLong) { int daggerset = 0; /* options descriptor */ const NLastGetopt::option longopts[] = { @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) { UNIT_ASSERT_VALUES_EQUAL(6, NLastGetopt::optind); } - Y_UNIT_TEST(TestLongPermutation) { + Y_UNIT_TEST(TestLongPermutation) { int daggerset = 0; /* options descriptor */ const NLastGetopt::option longopts[] = { @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) { UNIT_ASSERT_VALUES_EQUAL(3, NLastGetopt::optind); } - Y_UNIT_TEST(TestNoOptionsOptionsWithDoubleDash) { + Y_UNIT_TEST(TestNoOptionsOptionsWithDoubleDash) { const NLastGetopt::option longopts[] = { {"buffy", no_argument, nullptr, 'b'}, {"fluoride", no_argument, nullptr, 'f'}, @@ -84,7 +84,7 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) { UNIT_ASSERT_VALUES_EQUAL('?', NLastGetopt::getopt_long(argc, argv, "bf", longopts, nullptr)); } - Y_UNIT_TEST(TestLongOnly) { + Y_UNIT_TEST(TestLongOnly) { const NLastGetopt::option longopts[] = { {"foo", no_argument, nullptr, 'F'}, {"fluoride", no_argument, nullptr, 'f'}, @@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) { UNIT_ASSERT_VALUES_EQUAL(-1, NLastGetopt::getopt_long_only(argc, argv, "fo", longopts, nullptr)); } - Y_UNIT_TEST(TestLongWithoutOnlySingleDashNowAllowed) { + Y_UNIT_TEST(TestLongWithoutOnlySingleDashNowAllowed) { const NLastGetopt::option longopts[] = { {"foo", no_argument, nullptr, 'F'}, {"zoo", no_argument, nullptr, 'z'}, diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.cpp b/library/cpp/histogram/adaptive/adaptive_histogram.cpp index ce204de6fd..cbfc494021 100644 --- a/library/cpp/histogram/adaptive/adaptive_histogram.cpp +++ b/library/cpp/histogram/adaptive/adaptive_histogram.cpp @@ -80,7 +80,7 @@ namespace NKiwiAggr { histo.GetType() == HT_ADAPTIVE_WARD_HISTOGRAM || histo.GetType() == HT_ADAPTIVE_HISTOGRAM) { - Y_VERIFY(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); + Y_VERIFY(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); for (size_t j = 0; j < histo.FreqSize(); ++j) { double value = histo.GetPosition(j); double weight = histo.GetFreq(j); @@ -350,7 +350,7 @@ namespace NKiwiAggr { } double TAdaptiveHistogram::CalcUpperBound(double sum) { - Y_VERIFY(sum >= 0, "Sum must be >= 0"); + Y_VERIFY(sum >= 0, "Sum must be >= 0"); if (sum == 0.0) { return MinValue; } @@ -391,7 +391,7 @@ namespace NKiwiAggr { } double TAdaptiveHistogram::CalcLowerBound(double sum) { - Y_VERIFY(sum >= 0, "Sum must be >= 0"); + Y_VERIFY(sum >= 0, "Sum must be >= 0"); if (sum == 0.0) { return MaxValue; } @@ -509,13 +509,13 @@ namespace NKiwiAggr { ++rightBin; TWeightedValue newBin(value, weight + currentBin->second); if (rightBin != Bins.end()) { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) == 1, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) == 1, "Erase failed"); BinsByQuality.insert(CalcQuality(newBin, *rightBin)); } if (currentBin != Bins.begin()) { TPairSet::iterator leftBin = currentBin; --leftBin; - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) == 1, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) == 1, "Erase failed"); BinsByQuality.insert(CalcQuality(*leftBin, newBin)); } Bins.erase(currentBin); @@ -530,7 +530,7 @@ namespace NKiwiAggr { if (rightBin == Bins.end()) { BinsByQuality.insert(CalcQuality(*leftBin, weightedValue)); } else { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *rightBin)) == 1, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *rightBin)) == 1, "Erase failed"); BinsByQuality.insert(CalcQuality(*leftBin, weightedValue)); BinsByQuality.insert(CalcQuality(weightedValue, *rightBin)); } @@ -543,20 +543,20 @@ namespace NKiwiAggr { void TAdaptiveHistogram::Erase(double value) { TPairSet::iterator currentBin = Bins.lower_bound(TWeightedValue(value, -1.0)); - Y_VERIFY(currentBin != Bins.end() && currentBin->first == value, "Can't find bin that should be erased"); + Y_VERIFY(currentBin != Bins.end() && currentBin->first == value, "Can't find bin that should be erased"); TPairSet::iterator rightBin = currentBin; ++rightBin; if (currentBin == Bins.begin()) { - Y_VERIFY(rightBin != Bins.end(), "No right bin for the first bin"); - Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); + Y_VERIFY(rightBin != Bins.end(), "No right bin for the first bin"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); } else { TPairSet::iterator leftBin = currentBin; --leftBin; if (rightBin == Bins.end()) { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); } else { - Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); - Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*leftBin, *currentBin)) != 0, "Erase failed"); + Y_VERIFY(BinsByQuality.erase(CalcQuality(*currentBin, *rightBin)) != 0, "Erase failed"); BinsByQuality.insert(CalcQuality(*leftBin, *rightBin)); } } @@ -565,12 +565,12 @@ namespace NKiwiAggr { void TAdaptiveHistogram::Shrink() { TPairSet::iterator worstBin = BinsByQuality.begin(); - Y_VERIFY(worstBin != BinsByQuality.end(), "No right bin for the first bin"); + Y_VERIFY(worstBin != BinsByQuality.end(), "No right bin for the first bin"); TPairSet::iterator leftBin = Bins.lower_bound(TWeightedValue(worstBin->second, -1.0)); - Y_VERIFY(leftBin != Bins.end() && leftBin->first == worstBin->second, "Can't find worst bin"); + Y_VERIFY(leftBin != Bins.end() && leftBin->first == worstBin->second, "Can't find worst bin"); TPairSet::iterator rightBin = leftBin; ++rightBin; - Y_VERIFY(rightBin != Bins.end(), "Can't find right bin"); + Y_VERIFY(rightBin != Bins.end(), "Can't find right bin"); TWeightedValue newBin((leftBin->first * leftBin->second + rightBin->first * rightBin->second) / (leftBin->second + rightBin->second), leftBin->second + rightBin->second); if (Bins.size() > 2) { diff --git a/library/cpp/histogram/adaptive/auto_histogram.h b/library/cpp/histogram/adaptive/auto_histogram.h index 08e4e3d9d4..9fdf0b9abe 100644 --- a/library/cpp/histogram/adaptive/auto_histogram.h +++ b/library/cpp/histogram/adaptive/auto_histogram.h @@ -20,8 +20,8 @@ namespace NKiwiAggr { public: TAutoHistogram(size_t intervals, ui64 id = 0) { - Y_UNUSED(intervals); - Y_UNUSED(id); + Y_UNUSED(intervals); + Y_UNUSED(id); ythrow yexception() << "Empty constructor is not defined for TAutoHistogram"; } @@ -33,9 +33,9 @@ namespace NKiwiAggr { } TAutoHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0) { - Y_UNUSED(histo); - Y_UNUSED(defaultIntervals); - Y_UNUSED(defaultId); + Y_UNUSED(histo); + Y_UNUSED(defaultIntervals); + Y_UNUSED(defaultId); ythrow yexception() << "IHistogram constructor is not defined for TAutoHistogram"; } diff --git a/library/cpp/histogram/adaptive/block_histogram.cpp b/library/cpp/histogram/adaptive/block_histogram.cpp index 7003255916..6586d13ff6 100644 --- a/library/cpp/histogram/adaptive/block_histogram.cpp +++ b/library/cpp/histogram/adaptive/block_histogram.cpp @@ -149,7 +149,7 @@ namespace NKiwiAggr { histo.GetType() == HT_ADAPTIVE_WARD_HISTOGRAM || histo.GetType() == HT_ADAPTIVE_HISTOGRAM) { - Y_VERIFY(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); + Y_VERIFY(histo.FreqSize() == histo.PositionSize(), "Corrupted histo"); for (size_t j = 0; j < histo.FreqSize(); ++j) { double value = histo.GetPosition(j); double weight = histo.GetFreq(j); @@ -189,7 +189,7 @@ namespace NKiwiAggr { } void TBlockHistogram::Merge(TVector<IHistogramPtr> histogramsToMerge) { - Y_UNUSED(histogramsToMerge); + Y_UNUSED(histogramsToMerge); ythrow yexception() << "IHistogram::Merge(TVector<IHistogramPtr>) is not defined for TBlockHistogram"; } @@ -286,7 +286,7 @@ namespace NKiwiAggr { } void TBlockHistogram::SortAndShrink(size_t intervals, bool final) { - Y_VERIFY(intervals > 0); + Y_VERIFY(intervals > 0); if (Bins.size() <= intervals) { return; @@ -382,7 +382,7 @@ namespace NKiwiAggr { ui32 a = (ui32)(bins[b].Prev() - bins); ui32 c = (ui32)(bins[b].Next() - bins); ui32 d = (ui32)(bins[b].Next()->Next() - bins); - Y_VERIFY(Bins[c].second != -1); + Y_VERIFY(Bins[c].second != -1); double mass = Bins[b].second + Bins[c].second; Bins[c].first = (Bins[b].first * Bins[b].second + Bins[c].first * Bins[c].second) / mass; @@ -411,48 +411,48 @@ namespace NKiwiAggr { Bins.resize(pos); PrevSize = pos; - Y_VERIFY(pos == intervals); + Y_VERIFY(pos == intervals); } double TBlockHistogram::GetSumInRange(double leftBound, double rightBound) { - Y_UNUSED(leftBound); - Y_UNUSED(rightBound); + Y_UNUSED(leftBound); + Y_UNUSED(rightBound); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::GetSumAboveBound(double bound) { - Y_UNUSED(bound); + Y_UNUSED(bound); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::GetSumBelowBound(double bound) { - Y_UNUSED(bound); + Y_UNUSED(bound); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::CalcUpperBound(double sum) { - Y_UNUSED(sum); + Y_UNUSED(sum); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::CalcLowerBound(double sum) { - Y_UNUSED(sum); + Y_UNUSED(sum); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::CalcUpperBoundSafe(double sum) { - Y_UNUSED(sum); + Y_UNUSED(sum); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } double TBlockHistogram::CalcLowerBoundSafe(double sum) { - Y_UNUSED(sum); + Y_UNUSED(sum); ythrow yexception() << "Method is not implemented for TBlockHistogram"; return 0; } @@ -528,7 +528,7 @@ namespace NKiwiAggr { } void TBlockWardHistogram::FastGreedyShrink(size_t intervals) { - Y_VERIFY(intervals > 0); + Y_VERIFY(intervals > 0); if (Bins.size() <= intervals) { return; diff --git a/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp b/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp index aa33174f2d..558aba9e2d 100644 --- a/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp +++ b/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp @@ -512,7 +512,7 @@ namespace NKiwiAggr { } void TFixedBinHistogram::Shrink(double newReferencePoint, double newMaxValue) { - Y_VERIFY(newReferencePoint < newMaxValue, "Invalid Shrink()"); + Y_VERIFY(newReferencePoint < newMaxValue, "Invalid Shrink()"); memset(&(ReserveFreqs[0]), 0, ReserveFreqs.size() * sizeof(double)); double newBinRange = CalcBinRange(newReferencePoint, newMaxValue); diff --git a/library/cpp/histogram/hdr/histogram_iter_ut.cpp b/library/cpp/histogram/hdr/histogram_iter_ut.cpp index 2d6ffc68d9..9c291a2547 100644 --- a/library/cpp/histogram/hdr/histogram_iter_ut.cpp +++ b/library/cpp/histogram/hdr/histogram_iter_ut.cpp @@ -4,8 +4,8 @@ using namespace NHdr; -Y_UNIT_TEST_SUITE(THistogramIterTest) { - Y_UNIT_TEST(RecordedValues) { +Y_UNIT_TEST_SUITE(THistogramIterTest) { + Y_UNIT_TEST(RecordedValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValues(1000, 1000)); UNIT_ASSERT(h.RecordValue(1000 * 1000)); @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(index, 2); } - Y_UNIT_TEST(CorrectedRecordedValues) { + Y_UNIT_TEST(CorrectedRecordedValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValuesWithExpectedInterval(1000, 1000, 1000)); UNIT_ASSERT(h.RecordValueWithExpectedInterval(1000 * 1000, 1000)); @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(totalCount, 2000); } - Y_UNIT_TEST(LinearValues) { + Y_UNIT_TEST(LinearValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValues(1000, 1000)); UNIT_ASSERT(h.RecordValue(1000 * 1000)); @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(index, 1000); } - Y_UNIT_TEST(CorrectLinearValues) { + Y_UNIT_TEST(CorrectLinearValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValuesWithExpectedInterval(1000, 1000, 1000)); UNIT_ASSERT(h.RecordValueWithExpectedInterval(1000 * 1000, 1000)); @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(totalCount, 2000); } - Y_UNIT_TEST(LogarithmicValues) { + Y_UNIT_TEST(LogarithmicValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValues(1000, 1000)); UNIT_ASSERT(h.RecordValue(1000 * 1000)); @@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(index, 11); } - Y_UNIT_TEST(CorrectedLogarithmicValues) { + Y_UNIT_TEST(CorrectedLogarithmicValues) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValuesWithExpectedInterval(1000, 1000, 1000)); UNIT_ASSERT(h.RecordValueWithExpectedInterval(1000 * 1000, 1000)); @@ -181,7 +181,7 @@ Y_UNIT_TEST_SUITE(THistogramIterTest) { UNIT_ASSERT_EQUAL(totalCount, 2000); } - Y_UNIT_TEST(LinearIterBucketsCorrectly) { + Y_UNIT_TEST(LinearIterBucketsCorrectly) { THistogram h(255, 2); UNIT_ASSERT(h.RecordValue(193)); UNIT_ASSERT(h.RecordValue(255)); diff --git a/library/cpp/histogram/hdr/histogram_ut.cpp b/library/cpp/histogram/hdr/histogram_ut.cpp index 8974e60e2b..4841b76e71 100644 --- a/library/cpp/histogram/hdr/histogram_ut.cpp +++ b/library/cpp/histogram/hdr/histogram_ut.cpp @@ -16,14 +16,14 @@ void LoadData(THistogram* h1, THistogram* h2) { UNIT_ASSERT(h2->RecordValueWithExpectedInterval(1000 * 1000, 1000)); } -Y_UNIT_TEST_SUITE(THistogramTest) { - Y_UNIT_TEST(Creation) { +Y_UNIT_TEST_SUITE(THistogramTest) { + Y_UNIT_TEST(Creation) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT_EQUAL(h.GetMemorySize(), 188512); UNIT_ASSERT_EQUAL(h.GetCountsLen(), 23552); } - Y_UNIT_TEST(CreateWithLargeValues) { + Y_UNIT_TEST(CreateWithLargeValues) { THistogram h(20L * 1000 * 1000, 100L * 1000 * 1000, 5); UNIT_ASSERT(h.RecordValue(100L * 1000 * 1000)); UNIT_ASSERT(h.RecordValue(20L * 1000 * 1000)); @@ -45,18 +45,18 @@ Y_UNIT_TEST_SUITE(THistogramTest) { UNIT_ASSERT(h.ValuesAreEqual(v99, 100L * 1000 * 1000)); } - Y_UNIT_TEST(InvalidSignificantValueDigits) { + Y_UNIT_TEST(InvalidSignificantValueDigits) { UNIT_ASSERT_EXCEPTION(THistogram(1000, -1), yexception); UNIT_ASSERT_EXCEPTION(THistogram(1000, 0), yexception); UNIT_ASSERT_EXCEPTION(THistogram(1000, 6), yexception); } - Y_UNIT_TEST(InvalidLowestDiscernibleValue) { + Y_UNIT_TEST(InvalidLowestDiscernibleValue) { UNIT_ASSERT_EXCEPTION(THistogram(0, 100, 3), yexception); UNIT_ASSERT_EXCEPTION(THistogram(110, 100, 3), yexception); } - Y_UNIT_TEST(TotalCount) { + Y_UNIT_TEST(TotalCount) { i64 oneHour = SafeIntegerCast<i64>(TDuration::Hours(1).MicroSeconds()); THistogram h1(oneHour, 3); THistogram h2(oneHour, 3); @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(THistogramTest) { UNIT_ASSERT_EQUAL(h2.GetTotalCount(), 2000); } - Y_UNIT_TEST(StatsValues) { + Y_UNIT_TEST(StatsValues) { i64 oneHour = SafeIntegerCast<i64>(TDuration::Hours(1).MicroSeconds()); THistogram h1(oneHour, 3); THistogram h2(oneHour, 3); @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(THistogramTest) { } } - Y_UNIT_TEST(Percentiles) { + Y_UNIT_TEST(Percentiles) { i64 oneHour = SafeIntegerCast<i64>(TDuration::Hours(1).MicroSeconds()); THistogram h1(oneHour, 3); THistogram h2(oneHour, 3); @@ -156,13 +156,13 @@ Y_UNIT_TEST_SUITE(THistogramTest) { } } - Y_UNIT_TEST(OutOfRangeValues) { + Y_UNIT_TEST(OutOfRangeValues) { THistogram h(1000, 4); UNIT_ASSERT(h.RecordValue(32767)); UNIT_ASSERT(!h.RecordValue(32768)); } - Y_UNIT_TEST(Reset) { + Y_UNIT_TEST(Reset) { THistogram h(TDuration::Hours(1).MicroSeconds(), 3); UNIT_ASSERT(h.RecordValues(1000, 1000)); UNIT_ASSERT(h.RecordValue(1000 * 1000)); diff --git a/library/cpp/html/escape/ut/escape_ut.cpp b/library/cpp/html/escape/ut/escape_ut.cpp index 7a28d7c12b..cd7b955138 100644 --- a/library/cpp/html/escape/ut/escape_ut.cpp +++ b/library/cpp/html/escape/ut/escape_ut.cpp @@ -3,8 +3,8 @@ using namespace NHtml; -Y_UNIT_TEST_SUITE(TEscapeHtml) { - Y_UNIT_TEST(Escape) { +Y_UNIT_TEST_SUITE(TEscapeHtml) { + Y_UNIT_TEST(Escape) { UNIT_ASSERT_EQUAL(EscapeText("in & out"), "in & out"); UNIT_ASSERT_EQUAL(EscapeText("&&"), "&&"); UNIT_ASSERT_EQUAL(EscapeText("&"), "&amp;"); diff --git a/library/cpp/html/pcdata/pcdata.cpp b/library/cpp/html/pcdata/pcdata.cpp index 7cc0f6da85..740c240fd2 100644 --- a/library/cpp/html/pcdata/pcdata.cpp +++ b/library/cpp/html/pcdata/pcdata.cpp @@ -61,7 +61,7 @@ TString EncodeHtmlPcdata(const TStringBuf str, bool qAmp) { TString DecodeHtmlPcdata(const TString& sz) { TString res; - const char* codes[] = {""", "<", ">", "'", "'", "&", "'", nullptr}; + const char* codes[] = {""", "<", ">", "'", "'", "&", "'", nullptr}; const char chars[] = {'\"', '<', '>', '\'', '\'', '&', '\''}; for (size_t i = 0; i < sz.length(); ++i) { char c = sz[i]; diff --git a/library/cpp/html/pcdata/pcdata.h b/library/cpp/html/pcdata/pcdata.h index 786e98ac02..7dd741f53d 100644 --- a/library/cpp/html/pcdata/pcdata.h +++ b/library/cpp/html/pcdata/pcdata.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/fwd.h> +#include <util/generic/fwd.h> /// Converts a text into HTML-code. Special characters of HTML («<», «>», ...) replaced with entities. TString EncodeHtmlPcdata(const TStringBuf str, bool qAmp = true); diff --git a/library/cpp/html/pcdata/pcdata_ut.cpp b/library/cpp/html/pcdata/pcdata_ut.cpp index 90088712e2..5833f8bc59 100644 --- a/library/cpp/html/pcdata/pcdata_ut.cpp +++ b/library/cpp/html/pcdata/pcdata_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TPcdata) { - Y_UNIT_TEST(TestStress) { +Y_UNIT_TEST_SUITE(TPcdata) { + Y_UNIT_TEST(TestStress) { { ui64 key = 0x000017C0B76C4E87ull; TString res = EncodeHtmlPcdata(TStringBuf((const char*)&key, sizeof(key))); @@ -16,23 +16,23 @@ Y_UNIT_TEST_SUITE(TPcdata) { } } - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { const TString tests[] = { "qw&qw", "&<", ">&qw", "\'&aaa"}; - for (auto s : tests) { + for (auto s : tests) { UNIT_ASSERT_VALUES_EQUAL(DecodeHtmlPcdata(EncodeHtmlPcdata(s)), s); } } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { UNIT_ASSERT_VALUES_EQUAL(EncodeHtmlPcdata("&qqq"), "&qqq"); } - Y_UNIT_TEST(TestEncodeHtmlPcdataAppend) { + Y_UNIT_TEST(TestEncodeHtmlPcdataAppend) { TString s; EncodeHtmlPcdataAppend("m&m", s); EncodeHtmlPcdataAppend("'s", s); @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TPcdata) { UNIT_ASSERT_VALUES_EQUAL("m&m's", s); } - Y_UNIT_TEST(TestStrangeAmpParameter) { + Y_UNIT_TEST(TestStrangeAmpParameter) { UNIT_ASSERT_VALUES_EQUAL(EncodeHtmlPcdata("m&m's", true), "m&m's"); UNIT_ASSERT_VALUES_EQUAL(EncodeHtmlPcdata("m&m's"), "m&m's"); //default UNIT_ASSERT_VALUES_EQUAL(EncodeHtmlPcdata("m&m's", false), "m&m's"); diff --git a/library/cpp/http/fetch/http_digest.cpp b/library/cpp/http/fetch/http_digest.cpp index 480f4b0c51..1eaa02b7f2 100644 --- a/library/cpp/http/fetch/http_digest.cpp +++ b/library/cpp/http/fetch/http_digest.cpp @@ -1,8 +1,8 @@ #include "http_digest.h" #include <library/cpp/digest/md5/md5.h> -#include <util/stream/output.h> -#include <util/stream/str.h> +#include <util/stream/output.h> +#include <util/stream/str.h> /************************************************************/ /************************************************************/ diff --git a/library/cpp/http/fetch/httpfsm_ut.cpp b/library/cpp/http/fetch/httpfsm_ut.cpp index 63790456bc..b018e80101 100644 --- a/library/cpp/http/fetch/httpfsm_ut.cpp +++ b/library/cpp/http/fetch/httpfsm_ut.cpp @@ -488,7 +488,7 @@ void THttpHeaderParserTestSuite::TestRepeatedContentEncoding() { UNIT_TEST_SUITE_REGISTRATION(THttpHeaderParserTestSuite); -Y_UNIT_TEST_SUITE(TestHttpChunkParser) { +Y_UNIT_TEST_SUITE(TestHttpChunkParser) { static THttpChunkParser initParser() { THttpChunkParser parser; parser.Init(); @@ -513,7 +513,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { return parseByteByByte(blob, states); } - Y_UNIT_TEST(TestWithoutEolHead) { + Y_UNIT_TEST(TestWithoutEolHead) { const TStringBuf blob{ "4\r\n" "____\r\n"}; @@ -527,7 +527,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { parseByteByByte(blob, states); } - Y_UNIT_TEST(TestTrivialChunk) { + Y_UNIT_TEST(TestTrivialChunk) { const TStringBuf blob{ "\r\n" "4\r\n"}; @@ -536,7 +536,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { UNIT_ASSERT_EQUAL(parser.cnt64, 4); } - Y_UNIT_TEST(TestNegative) { + Y_UNIT_TEST(TestNegative) { const TStringBuf blob{ "\r\n" "-1"}; @@ -547,7 +547,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { parseByteByByte(blob, states); } - Y_UNIT_TEST(TestLeadingZero) { + Y_UNIT_TEST(TestLeadingZero) { const TStringBuf blob{ "\r\n" "042\r\n"}; @@ -555,7 +555,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { UNIT_ASSERT_EQUAL(parser.chunk_length, 0x42); } - Y_UNIT_TEST(TestIntOverflow) { + Y_UNIT_TEST(TestIntOverflow) { const TStringBuf blob{ "\r\n" "deadbeef"}; @@ -564,7 +564,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { UNIT_ASSERT_EQUAL(parser.cnt64, 0xdeadbeef); } - Y_UNIT_TEST(TestTrivialChunkWithTail) { + Y_UNIT_TEST(TestTrivialChunkWithTail) { const TStringBuf blob{ "\r\n" "4\r\n" @@ -577,7 +577,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { parseByteByByte(blob, states); } - Y_UNIT_TEST(TestLastChunk) { + Y_UNIT_TEST(TestLastChunk) { // NB: current parser does not permit whitespace before `foo`, // but I've never seen the feature in real-life traffic const TStringBuf blob{ diff --git a/library/cpp/http/fetch/httpparser.h b/library/cpp/http/fetch/httpparser.h index 078eb5f99d..769828e4ae 100644 --- a/library/cpp/http/fetch/httpparser.h +++ b/library/cpp/http/fetch/httpparser.h @@ -207,7 +207,7 @@ protected: size -= long(ChunkParser.lastchar - (char*)buf + 1); buf = ChunkParser.lastchar + 1; ChunkSize = ChunkParser.chunk_length; - Y_ASSERT(ChunkSize >= 0); + Y_ASSERT(ChunkSize >= 0); State = ChunkSize ? hp_read_chunk : hp_eof; } else { Header->entity_size += size; @@ -264,7 +264,7 @@ public: return 0; } long Read(void*& buf) { - Y_ASSERT(Bufsize >= 0); + Y_ASSERT(Bufsize >= 0); if (!Bufsize) { Bufsize = -1; return 0; diff --git a/library/cpp/http/fetch/httpparser_ut.cpp b/library/cpp/http/fetch/httpparser_ut.cpp index e63964c5f5..3b3b938e7a 100644 --- a/library/cpp/http/fetch/httpparser_ut.cpp +++ b/library/cpp/http/fetch/httpparser_ut.cpp @@ -9,7 +9,7 @@ } template <> -void Out<THttpParserBase::States>(IOutputStream& out, THttpParserBase::States st) { +void Out<THttpParserBase::States>(IOutputStream& out, THttpParserBase::States st) { using type = THttpParserBase::States; switch (st) { ENUM_OUT(hp_error) @@ -46,8 +46,8 @@ namespace { } -Y_UNIT_TEST_SUITE(TestHttpParser) { - Y_UNIT_TEST(TestTrivialRequest) { +Y_UNIT_TEST_SUITE(TestHttpParser) { + Y_UNIT_TEST(TestTrivialRequest) { const TString blob{ "GET /search?q=hi HTTP/1.1\r\n" "Host: www.google.ru:8080 \r\n" @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { } // XXX: `entity_size` is i32 and `content_length` is i64! - Y_UNIT_TEST(TestTrivialResponse) { + Y_UNIT_TEST(TestTrivialResponse) { const TString blob{ "HTTP/1.1 200 Ok\r\n" "Content-Length: 2\r\n" @@ -80,7 +80,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { } // XXX: `entity_size` is off by one in TE:chunked case. - Y_UNIT_TEST(TestChunkedResponse) { + Y_UNIT_TEST(TestChunkedResponse) { const TString blob{ "HTTP/1.1 200 OK\r\n" "Transfer-Encoding: chunked\r\n" @@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { "\r\n")); } - Y_UNIT_TEST(TestPipelineClenByteByByte) { + Y_UNIT_TEST(TestPipelineClenByteByByte) { const TString& blob = PipelineClenBlob_; THttpHeader hdr; TTestHttpParser parser; @@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { } // XXX: Content-Length is ignored, Body() looks unexpected! - Y_UNIT_TEST(TestPipelineClenOneChunk) { + Y_UNIT_TEST(TestPipelineClenOneChunk) { const TString& blob = PipelineClenBlob_; THttpHeader hdr; TTestHttpParser parser; @@ -205,7 +205,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { "\r\n")); } - Y_UNIT_TEST(TestPipelineChunkedByteByByte) { + Y_UNIT_TEST(TestPipelineChunkedByteByByte) { const TString& blob = PipelineChunkedBlob_; THttpHeader hdr; TTestHttpParser parser; @@ -220,7 +220,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { AssertPipelineChunked(parser, hdr); } - Y_UNIT_TEST(TestPipelineChunkedOneChunk) { + Y_UNIT_TEST(TestPipelineChunkedOneChunk) { const TString& blob = PipelineChunkedBlob_; THttpHeader hdr; TTestHttpParser parser; diff --git a/library/cpp/http/fetch/httpzreader.h b/library/cpp/http/fetch/httpzreader.h index fe106dabf7..68eb00853d 100644 --- a/library/cpp/http/fetch/httpzreader.h +++ b/library/cpp/http/fetch/httpzreader.h @@ -107,7 +107,7 @@ public: int err = inflate(&Stream, Z_SYNC_FLUSH); - //Y_ASSERT(Stream.avail_in == 0); + //Y_ASSERT(Stream.avail_in == 0); switch (err) { case Z_OK: diff --git a/library/cpp/http/io/chunk.cpp b/library/cpp/http/io/chunk.cpp index b43ca235f5..6975d9eac1 100644 --- a/library/cpp/http/io/chunk.cpp +++ b/library/cpp/http/io/chunk.cpp @@ -50,7 +50,7 @@ static inline char* ToHex(size_t len, char* buf) { class TChunkedInput::TImpl { public: - inline TImpl(IInputStream* slave, TMaybe<THttpHeaders>* trailers) + inline TImpl(IInputStream* slave, TMaybe<THttpHeaders>* trailers) : Slave_(slave) , Trailers_(trailers) , Pending_(0) @@ -136,13 +136,13 @@ private: } private: - IInputStream* Slave_; + IInputStream* Slave_; TMaybe<THttpHeaders>* Trailers_; size_t Pending_; bool LastChunkReaded_; }; -TChunkedInput::TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers) +TChunkedInput::TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers) : Impl_(new TImpl(slave, trailers)) { } @@ -159,10 +159,10 @@ size_t TChunkedInput::DoSkip(size_t len) { } class TChunkedOutput::TImpl { - typedef IOutputStream::TPart TPart; + typedef IOutputStream::TPart TPart; public: - inline TImpl(IOutputStream* slave) + inline TImpl(IOutputStream* slave) : Slave_(slave) { } @@ -209,10 +209,10 @@ public: } private: - IOutputStream* Slave_; + IOutputStream* Slave_; }; -TChunkedOutput::TChunkedOutput(IOutputStream* slave) +TChunkedOutput::TChunkedOutput(IOutputStream* slave) : Impl_(new TImpl(slave)) { } diff --git a/library/cpp/http/io/chunk.h b/library/cpp/http/io/chunk.h index 340515b2f7..88d89fafda 100644 --- a/library/cpp/http/io/chunk.h +++ b/library/cpp/http/io/chunk.h @@ -1,6 +1,6 @@ #pragma once -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/generic/maybe.h> #include <util/generic/ptr.h> @@ -11,11 +11,11 @@ class THttpHeaders; /// Ввод данных порциями. /// @details Последовательное чтение блоков данных. Предполагается, что /// данные записаны в виде <длина блока><блок данных>. -class TChunkedInput: public IInputStream { +class TChunkedInput: public IInputStream { public: /// Если передан указатель на trailers, то туда будут записаны HTTP trailer'ы (возможно пустые), /// которые идут после чанков. - TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers = nullptr); + TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers = nullptr); ~TChunkedInput() override; private: @@ -30,9 +30,9 @@ private: /// Вывод данных порциями. /// @details Вывод данных блоками в виде <длина блока><блок данных>. Если объем /// данных превышает 64K, они записываются в виде n блоков по 64K + то, что осталось. -class TChunkedOutput: public IOutputStream { +class TChunkedOutput: public IOutputStream { public: - TChunkedOutput(IOutputStream* slave); + TChunkedOutput(IOutputStream* slave); ~TChunkedOutput() override; private: diff --git a/library/cpp/http/io/chunk_ut.cpp b/library/cpp/http/io/chunk_ut.cpp index 44b2b9a66a..da283f8568 100644 --- a/library/cpp/http/io/chunk_ut.cpp +++ b/library/cpp/http/io/chunk_ut.cpp @@ -4,11 +4,11 @@ #include <util/stream/file.h> #include <util/system/tempfile.h> -#include <util/stream/null.h> +#include <util/stream/null.h> #define CDATA "./chunkedio" -Y_UNIT_TEST_SUITE(TestChunkedIO) { +Y_UNIT_TEST_SUITE(TestChunkedIO) { static const char test_data[] = "87s6cfbsudg cuisg s igasidftasiy tfrcua6s"; TString CombString(const TString& s, size_t chunkSize) { @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { return result; } - void WriteTestData(IOutputStream * stream, TString * contents) { + void WriteTestData(IOutputStream * stream, TString * contents) { contents->clear(); for (size_t i = 0; i < sizeof(test_data); ++i) { stream->Write(test_data, i); @@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { } } - void ReadInSmallChunks(IInputStream * stream, TString * contents) { + void ReadInSmallChunks(IInputStream * stream, TString * contents) { char buf[11]; size_t read = 0; @@ -37,8 +37,8 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { } while (read > 0); } - void ReadCombed(IInputStream * stream, TString * contents, size_t chunkSize) { - Y_ASSERT(chunkSize < 128); + void ReadCombed(IInputStream * stream, TString * contents, size_t chunkSize) { + Y_ASSERT(chunkSize < 128); char buf[128]; contents->clear(); @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { } } - Y_UNIT_TEST(TestChunkedIo) { + Y_UNIT_TEST(TestChunkedIo) { TTempFile tmpFile(CDATA); TString tmp; @@ -88,7 +88,7 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { } } - Y_UNIT_TEST(TestBadChunk) { + Y_UNIT_TEST(TestBadChunk) { bool hasError = false; try { diff --git a/library/cpp/http/io/headers.cpp b/library/cpp/http/io/headers.cpp index 6358d23f01..4ec27a29e8 100644 --- a/library/cpp/http/io/headers.cpp +++ b/library/cpp/http/io/headers.cpp @@ -1,10 +1,10 @@ #include "headers.h" #include "stream.h" -#include <util/generic/strbuf.h> +#include <util/generic/strbuf.h> #include <util/generic/yexception.h> -#include <util/stream/output.h> -#include <util/string/ascii.h> +#include <util/stream/output.h> +#include <util/string/ascii.h> #include <util/string/cast.h> #include <util/string/strip.h> @@ -12,25 +12,25 @@ static inline TStringBuf Trim(const char* b, const char* e) noexcept { return StripString(TStringBuf(b, e)); } -THttpInputHeader::THttpInputHeader(const TStringBuf header) { +THttpInputHeader::THttpInputHeader(const TStringBuf header) { size_t pos = header.find(':'); if (pos == TString::npos) { ythrow THttpParseException() << "can not parse http header(" << TString{header}.Quote() << ")"; } - Name_ = TString(header.cbegin(), header.cbegin() + pos); - Value_ = ::ToString(Trim(header.cbegin() + pos + 1, header.cend())); + Name_ = TString(header.cbegin(), header.cbegin() + pos); + Value_ = ::ToString(Trim(header.cbegin() + pos + 1, header.cend())); } -THttpInputHeader::THttpInputHeader(TString name, TString value) - : Name_(std::move(name)) - , Value_(std::move(value)) +THttpInputHeader::THttpInputHeader(TString name, TString value) + : Name_(std::move(name)) + , Value_(std::move(value)) { } -void THttpInputHeader::OutTo(IOutputStream* stream) const { - typedef IOutputStream::TPart TPart; +void THttpInputHeader::OutTo(IOutputStream* stream) const { + typedef IOutputStream::TPart TPart; const TPart parts[] = { TPart(Name_), @@ -42,7 +42,7 @@ void THttpInputHeader::OutTo(IOutputStream* stream) const { stream->Write(parts, sizeof(parts) / sizeof(*parts)); } -THttpHeaders::THttpHeaders(IInputStream* stream) { +THttpHeaders::THttpHeaders(IInputStream* stream) { TString header; TString line; @@ -53,28 +53,28 @@ THttpHeaders::THttpHeaders(IInputStream* stream) { if (rdOk && ((line[0] == ' ') || (line[0] == '\t'))) { header += line; } else { - AddHeader(THttpInputHeader(header)); + AddHeader(THttpInputHeader(header)); header = line; } } } -bool THttpHeaders::HasHeader(const TStringBuf header) const { +bool THttpHeaders::HasHeader(const TStringBuf header) const { return FindHeader(header); } -const THttpInputHeader* THttpHeaders::FindHeader(const TStringBuf header) const { +const THttpInputHeader* THttpHeaders::FindHeader(const TStringBuf header) const { for (const auto& hdr : Headers_) { - if (AsciiCompareIgnoreCase(hdr.Name(), header) == 0) { + if (AsciiCompareIgnoreCase(hdr.Name(), header) == 0) { return &hdr; } } return nullptr; } -void THttpHeaders::RemoveHeader(const TStringBuf header) { - for (auto h = Headers_.begin(); h != Headers_.end(); ++h) { - if (AsciiCompareIgnoreCase(h->Name(), header) == 0) { +void THttpHeaders::RemoveHeader(const TStringBuf header) { + for (auto h = Headers_.begin(); h != Headers_.end(); ++h) { + if (AsciiCompareIgnoreCase(h->Name(), header) == 0) { Headers_.erase(h); return; } @@ -82,9 +82,9 @@ void THttpHeaders::RemoveHeader(const TStringBuf header) { } void THttpHeaders::AddOrReplaceHeader(const THttpInputHeader& header) { - for (auto& hdr : Headers_) { - if (AsciiCompareIgnoreCase(hdr.Name(), header.Name()) == 0) { - hdr = header; + for (auto& hdr : Headers_) { + if (AsciiCompareIgnoreCase(hdr.Name(), header.Name()) == 0) { + hdr = header; return; } } @@ -92,17 +92,17 @@ void THttpHeaders::AddOrReplaceHeader(const THttpInputHeader& header) { AddHeader(header); } -void THttpHeaders::AddHeader(THttpInputHeader header) { - Headers_.push_back(std::move(header)); +void THttpHeaders::AddHeader(THttpInputHeader header) { + Headers_.push_back(std::move(header)); } -void THttpHeaders::OutTo(IOutputStream* stream) const { +void THttpHeaders::OutTo(IOutputStream* stream) const { for (TConstIterator header = Begin(); header != End(); ++header) { header->OutTo(stream); } } template <> -void Out<THttpHeaders>(IOutputStream& out, const THttpHeaders& h) { +void Out<THttpHeaders>(IOutputStream& out, const THttpHeaders& h) { h.OutTo(&out); } diff --git a/library/cpp/http/io/headers.h b/library/cpp/http/io/headers.h index 43c6818cd6..a71793d1c6 100644 --- a/library/cpp/http/io/headers.h +++ b/library/cpp/http/io/headers.h @@ -6,8 +6,8 @@ #include <util/generic/vector.h> #include <util/string/cast.h> -class IInputStream; -class IOutputStream; +class IInputStream; +class IOutputStream; /// @addtogroup Streams_HTTP /// @{ @@ -15,10 +15,10 @@ class IOutputStream; class THttpInputHeader { public: /// @param[in] header - строка вида 'параметр: значение'. - THttpInputHeader(TStringBuf header); + THttpInputHeader(TStringBuf header); /// @param[in] name - имя параметра. /// @param[in] value - значение параметра. - THttpInputHeader(TString name, TString value); + THttpInputHeader(TString name, TString value); /// Возвращает имя параметра. inline const TString& Name() const noexcept { @@ -31,7 +31,7 @@ public: } /// Записывает заголовок вида "имя параметра: значение\r\n" в поток. - void OutTo(IOutputStream* stream) const; + void OutTo(IOutputStream* stream) const; /// Возвращает строку "имя параметра: значение". inline TString ToString() const { @@ -45,15 +45,15 @@ private: /// Контейнер для хранения HTTP-заголовков class THttpHeaders { - using THeaders = TDeque<THttpInputHeader>; + using THeaders = TDeque<THttpInputHeader>; public: - using TConstIterator = THeaders::const_iterator; + using TConstIterator = THeaders::const_iterator; + + THttpHeaders() = default; - THttpHeaders() = default; - /// Добавляет каждую строку из потока в контейнер, считая ее правильным заголовком. - THttpHeaders(IInputStream* stream); + THttpHeaders(IInputStream* stream); /// Стандартный итератор. inline TConstIterator Begin() const noexcept { @@ -82,11 +82,11 @@ public: } /// Добавляет заголовок в контейнер. - void AddHeader(THttpInputHeader header); + void AddHeader(THttpInputHeader header); template <typename ValueType> - void AddHeader(TString name, const ValueType& value) { - AddHeader(THttpInputHeader(std::move(name), ToString(value))); + void AddHeader(TString name, const ValueType& value) { + AddHeader(THttpInputHeader(std::move(name), ToString(value))); } /// Добавляет заголовок в контейнер, если тот не содержит заголовка @@ -100,18 +100,18 @@ public: } // Проверяет, есть ли такой заголовок - bool HasHeader(TStringBuf header) const; + bool HasHeader(TStringBuf header) const; /// Удаляет заголовок, если он есть. - void RemoveHeader(TStringBuf header); + void RemoveHeader(TStringBuf header); /// Ищет заголовок по указанному имени /// Возвращает nullptr, если не нашел - const THttpInputHeader* FindHeader(TStringBuf header) const; + const THttpInputHeader* FindHeader(TStringBuf header) const; /// Записывает все заголовки контейнера в поток. /// @details Каждый заголовк записывается в виде "имя параметра: значение\r\n". - void OutTo(IOutputStream* stream) const; + void OutTo(IOutputStream* stream) const; /// Обменивает наборы заголовков двух контейнеров. void Swap(THttpHeaders& headers) noexcept { diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp index 317ce6a215..6689be684f 100644 --- a/library/cpp/http/io/stream.cpp +++ b/library/cpp/http/io/stream.cpp @@ -6,7 +6,7 @@ #include <util/stream/buffered.h> #include <util/stream/length.h> #include <util/stream/multi.h> -#include <util/stream/null.h> +#include <util/stream/null.h> #include <util/stream/tee.h> #include <util/system/compat.h> @@ -15,7 +15,7 @@ #include <util/network/socket.h> #include <util/string/cast.h> -#include <util/string/strip.h> +#include <util/string/strip.h> #include <util/generic/string.h> #include <util/generic/utility.h> @@ -134,7 +134,7 @@ class THttpInput::TImpl { typedef THashSet<TString> TAcceptCodings; public: - inline TImpl(IInputStream* slave) + inline TImpl(IInputStream* slave) : Slave_(slave) , Buffered_(Slave_, SuggestBufferSize()) , ChunkedInput_(nullptr) @@ -148,7 +148,7 @@ public: , Expect100Continue_(false) { BuildInputChain(); - Y_ASSERT(Input_); + Y_ASSERT(Input_); } static TString ReadFirstLine(TBufferedInput& in) { @@ -361,19 +361,19 @@ private: } private: - IInputStream* Slave_; + IInputStream* Slave_; /* * input helpers */ TBufferedInput Buffered_; - TStreams<IInputStream, 8> Streams_; - IInputStream* ChunkedInput_; + TStreams<IInputStream, 8> Streams_; + IInputStream* ChunkedInput_; /* * final input stream */ - IInputStream* Input_; + IInputStream* Input_; TString FirstLine_; THttpHeaders Headers_; @@ -389,7 +389,7 @@ private: bool Expect100Continue_; }; -THttpInput::THttpInput(IInputStream* slave) +THttpInput::THttpInput(IInputStream* slave) : Impl_(new TImpl(slave)) { } @@ -457,7 +457,7 @@ bool THttpInput::HasExpect100Continue() const noexcept { } class THttpOutput::TImpl { - class TSizeCalculator: public IOutputStream { + class TSizeCalculator: public IOutputStream { public: inline TSizeCalculator() noexcept { } @@ -484,19 +484,19 @@ class THttpOutput::TImpl { }; struct TFlush { - inline void operator()(IOutputStream* s) { + inline void operator()(IOutputStream* s) { s->Flush(); } }; struct TFinish { - inline void operator()(IOutputStream* s) { + inline void operator()(IOutputStream* s) { s->Finish(); } }; public: - inline TImpl(IOutputStream* slave, THttpInput* request) + inline TImpl(IOutputStream* slave, THttpInput* request) : Slave_(slave) , State_(Begin) , Output_(Slave_) @@ -710,7 +710,7 @@ private: } inline void Process(const TString& s) { - Y_ASSERT(State_ != HeadersSent); + Y_ASSERT(State_ != HeadersSent); if (State_ == Begin) { FirstLine_ = s; @@ -722,12 +722,12 @@ private: WriteCached(); State_ = HeadersSent; } else { - AddHeader(THttpInputHeader(s)); + AddHeader(THttpInputHeader(s)); } } } - inline void WriteCachedImpl(IOutputStream* s) const { + inline void WriteCachedImpl(IOutputStream* s) const { s->Write(FirstLine_.data(), FirstLine_.size()); s->Write("\r\n", 2); Headers_.OutTo(s); @@ -855,10 +855,10 @@ private: } private: - IOutputStream* Slave_; + IOutputStream* Slave_; TState State_; - IOutputStream* Output_; - TStreams<IOutputStream, 8> Streams_; + IOutputStream* Output_; + TStreams<IOutputStream, 8> Streams_; TString Line_; TString FirstLine_; THttpHeaders Headers_; @@ -876,12 +876,12 @@ private: TSizeCalculator SizeCalculator_; }; -THttpOutput::THttpOutput(IOutputStream* slave) +THttpOutput::THttpOutput(IOutputStream* slave) : Impl_(new TImpl(slave, nullptr)) { } -THttpOutput::THttpOutput(IOutputStream* slave, THttpInput* request) +THttpOutput::THttpOutput(IOutputStream* slave, THttpInput* request) : Impl_(new TImpl(slave, request)) { } @@ -979,21 +979,21 @@ void SendMinimalHttpRequest(TSocket& s, const TStringBuf& host, const TStringBuf output.EnableKeepAlive(false); output.EnableCompression(false); - const IOutputStream::TPart parts[] = { + const IOutputStream::TPart parts[] = { IOutputStream::TPart(TStringBuf("GET ")), - IOutputStream::TPart(request), + IOutputStream::TPart(request), IOutputStream::TPart(TStringBuf(" HTTP/1.1")), - IOutputStream::TPart::CrLf(), + IOutputStream::TPart::CrLf(), IOutputStream::TPart(TStringBuf("Host: ")), - IOutputStream::TPart(host), - IOutputStream::TPart::CrLf(), + IOutputStream::TPart(host), + IOutputStream::TPart::CrLf(), IOutputStream::TPart(TStringBuf("User-Agent: ")), - IOutputStream::TPart(agent), - IOutputStream::TPart::CrLf(), + IOutputStream::TPart(agent), + IOutputStream::TPart::CrLf(), IOutputStream::TPart(TStringBuf("From: ")), - IOutputStream::TPart(from), - IOutputStream::TPart::CrLf(), - IOutputStream::TPart::CrLf(), + IOutputStream::TPart(from), + IOutputStream::TPart::CrLf(), + IOutputStream::TPart::CrLf(), }; output.Write(parts, sizeof(parts) / sizeof(*parts)); diff --git a/library/cpp/http/io/stream.h b/library/cpp/http/io/stream.h index 1003042281..78ca4fc814 100644 --- a/library/cpp/http/io/stream.h +++ b/library/cpp/http/io/stream.h @@ -2,7 +2,7 @@ #include "headers.h" -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/generic/maybe.h> #include <util/generic/ptr.h> #include <util/generic/string.h> @@ -22,9 +22,9 @@ struct THttpReadException: public THttpException { }; /// Чтение ответа HTTP-сервера. -class THttpInput: public IInputStream { +class THttpInput: public IInputStream { public: - THttpInput(IInputStream* slave); + THttpInput(IInputStream* slave); THttpInput(THttpInput&& httpInput); ~THttpInput() override; @@ -96,10 +96,10 @@ private: }; /// Передача запроса HTTP-серверу. -class THttpOutput: public IOutputStream { +class THttpOutput: public IOutputStream { public: - THttpOutput(IOutputStream* slave); - THttpOutput(IOutputStream* slave, THttpInput* request); + THttpOutput(IOutputStream* slave); + THttpOutput(IOutputStream* slave, THttpInput* request); ~THttpOutput() override; /* diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index 9578b4e7e0..1ea35df675 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -8,11 +8,11 @@ #include <util/string/printf.h> #include <util/network/socket.h> -#include <util/stream/file.h> -#include <util/stream/output.h> -#include <util/stream/tee.h> +#include <util/stream/file.h> +#include <util/stream/output.h> +#include <util/stream/tee.h> #include <util/stream/zlib.h> -#include <util/stream/null.h> +#include <util/stream/null.h> Y_UNIT_TEST_SUITE(THttpStreamTest) { class TTestHttpServer: public THttpServer::ICallBack { @@ -78,11 +78,11 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { size_t LastRequestSentSize_ = 0; }; - Y_UNIT_TEST(TestCodings1) { + Y_UNIT_TEST(TestCodings1) { UNIT_ASSERT(SupportedCodings().size() > 0); } - Y_UNIT_TEST(TestHttpInput) { + Y_UNIT_TEST(TestHttpInput) { TString res = "I'm a teapot"; TPortManager pm; const ui16 port = pm.GetPort(); @@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { server.Stop(); } - Y_UNIT_TEST(TestHttpInputDelete) { + Y_UNIT_TEST(TestHttpInputDelete) { TString res = "I'm a teapot"; TPortManager pm; const ui16 port = pm.GetPort(); @@ -174,11 +174,11 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { server.Stop(); } - Y_UNIT_TEST(TestParseHttpRetCode) { + Y_UNIT_TEST(TestParseHttpRetCode) { UNIT_ASSERT_VALUES_EQUAL(ParseHttpRetCode("HTTP/1.1 301"), 301u); } - Y_UNIT_TEST(TestKeepAlive) { + Y_UNIT_TEST(TestKeepAlive) { { TString s = "GET / HTTP/1.0\r\n\r\n"; TStringInput si(s); @@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } } - Y_UNIT_TEST(TestMinRequest) { + Y_UNIT_TEST(TestMinRequest) { TString res = "qqqqqq"; TPortManager pm; const ui16 port = pm.GetPort(); @@ -262,7 +262,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { server.Stop(); } - Y_UNIT_TEST(TestResponseWithBlanks) { + Y_UNIT_TEST(TestResponseWithBlanks) { TString res = "qqqqqq\r\n\r\nsdasdsad\r\n"; TPortManager pm; const ui16 port = pm.GetPort(); @@ -287,7 +287,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { server.Stop(); } - Y_UNIT_TEST(TestOutputFlush) { + Y_UNIT_TEST(TestOutputFlush) { TString str; TStringOutput strOut(str); TBufferedOutput bufOut(&strOut, 8192); @@ -307,7 +307,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(curLen + strlen(body), str.size()); } - Y_UNIT_TEST(TestOutputPostFlush) { + Y_UNIT_TEST(TestOutputPostFlush) { TString str; TString checkStr; TStringOutput strOut(str); @@ -372,7 +372,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT(MakeHttpOutputBody(body, true) == SimulateBodyEncoding(body)); } - Y_UNIT_TEST(TestOutputFinish) { + Y_UNIT_TEST(TestOutputFinish) { TString str; TStringOutput strOut(str); TBufferedOutput bufOut(&strOut, 8192); @@ -392,7 +392,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(curLen + strlen(body), str.size()); } - Y_UNIT_TEST(TestMultilineHeaders) { + Y_UNIT_TEST(TestMultilineHeaders) { const char* headerLine0 = "HTTP/1.1 200 OK"; const char* headerLine1 = "Content-Language: en"; const char* headerLine2 = "Vary: Accept-Encoding, "; @@ -419,7 +419,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL((++it)->ToString(), TString(headerLine4)); } - Y_UNIT_TEST(ContentLengthRemoval) { + Y_UNIT_TEST(ContentLengthRemoval) { TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip\r\n\r\n"); THttpInput i(&request); TString result; @@ -487,7 +487,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT(result.Contains("content-encoding: gzip")); } - Y_UNIT_TEST(HasTrailers) { + Y_UNIT_TEST(HasTrailers) { TMemoryInput response( "HTTP/1.1 200 OK\r\n" "Transfer-Encoding: chunked\r\n" @@ -506,7 +506,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(trailers.GetRef().Begin()->ToString(), "Bar: baz"); } - Y_UNIT_TEST(NoTrailersWithChunks) { + Y_UNIT_TEST(NoTrailersWithChunks) { TMemoryInput response( "HTTP/1.1 200 OK\r\n" "Transfer-Encoding: chunked\r\n" @@ -523,7 +523,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(trailers.GetRef().Count(), 0); } - Y_UNIT_TEST(NoTrailersNoChunks) { + Y_UNIT_TEST(NoTrailersNoChunks) { TMemoryInput response( "HTTP/1.1 200 OK\r\n" "Content-Length: 3\r\n" @@ -537,7 +537,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(trailers.GetRef().Count(), 0); } - Y_UNIT_TEST(RequestWithoutContentLength) { + Y_UNIT_TEST(RequestWithoutContentLength) { TStringStream request; { THttpOutput httpOutput(&request); @@ -565,7 +565,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } } - Y_UNIT_TEST(TestInputHasContent) { + Y_UNIT_TEST(TestInputHasContent) { { TStringStream request; request << "POST / HTTP/1.1\r\n" @@ -611,7 +611,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } } - Y_UNIT_TEST(TestHttpInputHeadRequest) { + Y_UNIT_TEST(TestHttpInputHeadRequest) { class THeadOnlyInput: public IInputStream { public: THeadOnlyInput() = default; @@ -645,7 +645,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(httpInput.ReadAll(), ""); } - Y_UNIT_TEST(TestHttpOutputResponseToHeadRequestNoZeroChunk) { + Y_UNIT_TEST(TestHttpOutputResponseToHeadRequestNoZeroChunk) { TStringStream request; request << "HEAD / HTTP/1.1\r\n" "Host: yandex.ru\r\n" diff --git a/library/cpp/http/io/stream_ut_medium.cpp b/library/cpp/http/io/stream_ut_medium.cpp index fb5c425b02..2c125eb21e 100644 --- a/library/cpp/http/io/stream_ut_medium.cpp +++ b/library/cpp/http/io/stream_ut_medium.cpp @@ -3,7 +3,7 @@ #include <util/stream/zlib.h> Y_UNIT_TEST_SUITE(THttpTestMedium) { - Y_UNIT_TEST(TestCodings2) { + Y_UNIT_TEST(TestCodings2) { TStringBuf data = "aaaaaaaaaaaaaaaaaaaaaaa"; for (auto codec : SupportedCodings()) { diff --git a/library/cpp/http/misc/httpdate.cpp b/library/cpp/http/misc/httpdate.cpp index 563f356787..4a3031bbf4 100644 --- a/library/cpp/http/misc/httpdate.cpp +++ b/library/cpp/http/misc/httpdate.cpp @@ -71,13 +71,13 @@ char* format_http_date(time_t when, char* buf, size_t buflen) { return nullptr; } - Y_ASSERT(len > 0 && size_t(len) < buflen); + Y_ASSERT(len > 0 && size_t(len) < buflen); return buf; } TString FormatHttpDate(time_t when) { char str[64] = {0}; - format_http_date(str, Y_ARRAY_SIZE(str), when); + format_http_date(str, Y_ARRAY_SIZE(str), when); return TString(str); } diff --git a/library/cpp/http/misc/httpdate_ut.cpp b/library/cpp/http/misc/httpdate_ut.cpp index 30c8a1b19f..c1a0103501 100644 --- a/library/cpp/http/misc/httpdate_ut.cpp +++ b/library/cpp/http/misc/httpdate_ut.cpp @@ -2,14 +2,14 @@ #include "httpdate.h" -Y_UNIT_TEST_SUITE(TestHttpDate) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(TestHttpDate) { + Y_UNIT_TEST(Test1) { char buf1[100]; char buf2[100]; UNIT_ASSERT((int)strlen(format_http_date(0, buf1, sizeof(buf1))) == format_http_date(buf2, sizeof(buf2), 0)); } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { UNIT_ASSERT_STRINGS_EQUAL(FormatHttpDate(1234567890), "Fri, 13 Feb 2009 23:31:30 GMT"); } } diff --git a/library/cpp/http/misc/httpreqdata.cpp b/library/cpp/http/misc/httpreqdata.cpp index 2ae2c36339..f6951f68cd 100644 --- a/library/cpp/http/misc/httpreqdata.cpp +++ b/library/cpp/http/misc/httpreqdata.cpp @@ -29,7 +29,7 @@ TBaseServerRequestData::TBaseServerRequestData(const char* qs, SOCKET s) void TBaseServerRequestData::AppendQueryString(const char* str, size_t length) { if (Y_UNLIKELY(Search)) { - Y_ASSERT(strlen(Search) == SearchLength); + Y_ASSERT(strlen(Search) == SearchLength); ModifiedQueryString.Reserve(SearchLength + length + 2); ModifiedQueryString.Assign(Search, SearchLength); if (SearchLength > 0 && Search[SearchLength - 1] != '&' && @@ -170,7 +170,7 @@ bool TBaseServerRequestData::Parse(const char* origReq) { ptrdiff_t delta = fragment - Search; // indeed, second case is a parse error SearchLength = (delta >= 0) ? delta : (urlEnd - Search); - Y_ASSERT(strlen(Search) == SearchLength); + Y_ASSERT(strlen(Search) == SearchLength); } else { SearchLength = 0; } diff --git a/library/cpp/http/misc/httpreqdata_ut.cpp b/library/cpp/http/misc/httpreqdata_ut.cpp index 88ec48c666..e7f16ef27c 100644 --- a/library/cpp/http/misc/httpreqdata_ut.cpp +++ b/library/cpp/http/misc/httpreqdata_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TRequestServerDataTest) { - Y_UNIT_TEST(Headers) { +Y_UNIT_TEST_SUITE(TRequestServerDataTest) { + Y_UNIT_TEST(Headers) { TServerRequestData sd; sd.AddHeader("x-xx", "y-yy"); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT_VALUES_EQUAL(TStringBuf(sd.HeaderIn("X-XXX")), TStringBuf("y-yyy")); } - Y_UNIT_TEST(ComplexHeaders) { + Y_UNIT_TEST(ComplexHeaders) { TServerRequestData sd; sd.SetHost("zzz", 1); @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT_VALUES_EQUAL(sd.ServerPort(), "678"); } - Y_UNIT_TEST(ParseScan) { + Y_UNIT_TEST(ParseScan) { TServerRequestData rd; // Parse parses url without host @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { rd.Clear(); } - Y_UNIT_TEST(Ctor) { + Y_UNIT_TEST(Ctor) { const TString qs("gta=fake&haha=da"); TServerRequestData rd(qs.c_str()); @@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT(!rd.CgiParam.Has("no-param")); } - Y_UNIT_TEST(HashCut) { + Y_UNIT_TEST(HashCut) { const TString qs(">a=fake&haha=da"); const TString header = " /yandsearch?" + qs + "#&uberParam=yes&q=? HTTP 1.1 OK"; @@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT(!rd.CgiParam.Has("uberParam")); } - Y_UNIT_TEST(MisplacedHashCut) { + Y_UNIT_TEST(MisplacedHashCut) { TServerRequestData rd; rd.Parse(" /y#ndsearch?>a=fake&haha=da&uberParam=yes&q=? HTTP 1.1 OK"); @@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT(rd.CgiParam.empty()); } - Y_UNIT_TEST(CornerCase) { + Y_UNIT_TEST(CornerCase) { TServerRequestData rd; rd.Parse(" /yandsearch?#"); @@ -112,7 +112,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT(rd.CgiParam.empty()); } - Y_UNIT_TEST(AppendQueryString) { + Y_UNIT_TEST(AppendQueryString) { const TString qs("gta=fake&haha=da"); TServerRequestData rd(qs.c_str()); @@ -134,7 +134,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT(rd.CgiParam.Has("gta", "new")); } - Y_UNIT_TEST(SetRemoteAddrSimple) { + Y_UNIT_TEST(SetRemoteAddrSimple) { static const TString TEST = "abacaba.search.yandex.net"; TServerRequestData rd; @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT_STRINGS_EQUAL(TEST, rd.RemoteAddr()); } - Y_UNIT_TEST(SetRemoteAddrRandom) { + Y_UNIT_TEST(SetRemoteAddrRandom) { for (size_t size = 0; size < 2 * INET6_ADDRSTRLEN; ++size) { const TString test = NUnitTest::RandomString(size, size); TServerRequestData rd; diff --git a/library/cpp/http/misc/parsed_request.cpp b/library/cpp/http/misc/parsed_request.cpp index d109239054..e332a24e91 100644 --- a/library/cpp/http/misc/parsed_request.cpp +++ b/library/cpp/http/misc/parsed_request.cpp @@ -1,6 +1,6 @@ #include "parsed_request.h" -#include <util/string/strip.h> +#include <util/string/strip.h> #include <util/generic/yexception.h> #include <util/string/cast.h> diff --git a/library/cpp/http/misc/parsed_request_ut.cpp b/library/cpp/http/misc/parsed_request_ut.cpp index 095c7e59c8..da6d95c6ab 100644 --- a/library/cpp/http/misc/parsed_request_ut.cpp +++ b/library/cpp/http/misc/parsed_request_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(THttpParse) { - Y_UNIT_TEST(TestParse) { +Y_UNIT_TEST_SUITE(THttpParse) { + Y_UNIT_TEST(TestParse) { TParsedHttpFull h("GET /yandsearch?text=nokia HTTP/1.1"); UNIT_ASSERT_EQUAL(h.Method, "GET"); @@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(THttpParse) { UNIT_ASSERT_EQUAL(h.Cgi, "text=nokia"); } - Y_UNIT_TEST(TestError) { + Y_UNIT_TEST(TestError) { bool wasError = false; try { diff --git a/library/cpp/http/server/conn.cpp b/library/cpp/http/server/conn.cpp index 801656dc88..38a76c4c30 100644 --- a/library/cpp/http/server/conn.cpp +++ b/library/cpp/http/server/conn.cpp @@ -1,7 +1,7 @@ #include "conn.h" #include <util/network/socket.h> -#include <util/stream/buffered.h> +#include <util/stream/buffered.h> class THttpServerConn::TImpl { public: diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index b8d634edec..128583bdd7 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -15,7 +15,7 @@ #include <util/system/defaults.h> #include <util/system/event.h> #include <util/system/mutex.h> -#include <util/system/pipe.h> +#include <util/system/pipe.h> #include <util/system/thread.h> #include <util/thread/factory.h> diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp index e60d67673d..cc62bb988e 100644 --- a/library/cpp/http/server/http_ut.cpp +++ b/library/cpp/http/server/http_ut.cpp @@ -5,12 +5,12 @@ #include <library/cpp/testing/unittest/tests_data.h> #include <util/generic/cast.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/stream/zlib.h> #include <util/system/datetime.h> #include <util/system/sem.h> -Y_UNIT_TEST_SUITE(THttpServerTest) { +Y_UNIT_TEST_SUITE(THttpServerTest) { class TEchoServer: public THttpServer::ICallBack { class TRequest: public THttpClientRequestEx { public: @@ -320,7 +320,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { return res; } - Y_UNIT_TEST(TestEchoServer) { + Y_UNIT_TEST(TestEchoServer) { TString res = TestData(); TPortManager pm; const ui16 port = pm.GetPort(); @@ -368,7 +368,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { } } - Y_UNIT_TEST(TestReusePortEnabled) { + Y_UNIT_TEST(TestReusePortEnabled) { if (!IsReusePortAvailable()) { return; // skip test } @@ -403,7 +403,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { } } - Y_UNIT_TEST(TestReusePortDisabled) { + Y_UNIT_TEST(TestReusePortDisabled) { // check that with the ReusePort option disabled it's impossible to start two servers on the same port // check that ReusePort option is disabled by default (don't set it explicitly in the test) TPortManager pm; @@ -422,7 +422,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { UNIT_ASSERT(false == server1.Start()); } - Y_UNIT_TEST(TestFailServer) { + Y_UNIT_TEST(TestFailServer) { /** * Emulate request processing failures * Data should be large enough not to fit into socket buffer @@ -541,7 +541,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { server.Stop(); }; - Y_UNIT_TEST(TTestReleaseConnection) { + Y_UNIT_TEST(TTestReleaseConnection) { TPortManager pm; const ui16 port = pm.GetPort(); @@ -685,7 +685,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { }; #if 0 - Y_UNIT_TEST(TestSocketsLeak) { + Y_UNIT_TEST(TestSocketsLeak) { const bool trueFalse[] = {true, false}; TPortManager portManager; const ui16 port = portManager.GetPort(); diff --git a/library/cpp/http/server/options.cpp b/library/cpp/http/server/options.cpp index 3aed3757ed..05c954384a 100644 --- a/library/cpp/http/server/options.cpp +++ b/library/cpp/http/server/options.cpp @@ -24,7 +24,7 @@ static inline TNetworkAddress ToNetworkAddr(const TString& address, ui16 port) { void THttpServerOptions::BindAddresses(TBindAddresses& ret) const { THashSet<TString> check; - for (auto addr : BindSockaddr) { + for (auto addr : BindSockaddr) { if (!addr.Port) { addr.Port = Port; } diff --git a/library/cpp/http/server/response.cpp b/library/cpp/http/server/response.cpp index cbdb29aab7..52d64c91ce 100644 --- a/library/cpp/http/server/response.cpp +++ b/library/cpp/http/server/response.cpp @@ -17,7 +17,7 @@ THttpResponse& THttpResponse::SetContentType(const TStringBuf& contentType) { return *this; } -void THttpResponse::OutTo(IOutputStream& os) const { +void THttpResponse::OutTo(IOutputStream& os) const { TVector<IOutputStream::TPart> parts; const size_t FIRST_LINE_PARTS = 3; const size_t HEADERS_PARTS = Headers.Count() * 4; @@ -26,15 +26,15 @@ void THttpResponse::OutTo(IOutputStream& os) const { // first line parts.push_back(IOutputStream::TPart(TStringBuf("HTTP/1.1 "))); - parts.push_back(IOutputStream::TPart(HttpCodeStrEx(Code))); - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart(HttpCodeStrEx(Code))); + parts.push_back(IOutputStream::TPart::CrLf()); // headers for (THttpHeaders::TConstIterator i = Headers.Begin(); i != Headers.End(); ++i) { - parts.push_back(IOutputStream::TPart(i->Name())); + parts.push_back(IOutputStream::TPart(i->Name())); parts.push_back(IOutputStream::TPart(TStringBuf(": "))); - parts.push_back(IOutputStream::TPart(i->Value())); - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart(i->Value())); + parts.push_back(IOutputStream::TPart::CrLf()); } char buf[50]; @@ -45,21 +45,21 @@ void THttpResponse::OutTo(IOutputStream& os) const { mo << Content.size(); parts.push_back(IOutputStream::TPart(TStringBuf("Content-Length: "))); - parts.push_back(IOutputStream::TPart(buf, mo.Buf() - buf)); - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart(buf, mo.Buf() - buf)); + parts.push_back(IOutputStream::TPart::CrLf()); } // content - parts.push_back(IOutputStream::TPart::CrLf()); + parts.push_back(IOutputStream::TPart::CrLf()); if (!Content.empty()) { - parts.push_back(IOutputStream::TPart(Content)); + parts.push_back(IOutputStream::TPart(Content)); } os.Write(parts.data(), parts.size()); } template <> -void Out<THttpResponse>(IOutputStream& os, const THttpResponse& resp) { +void Out<THttpResponse>(IOutputStream& os, const THttpResponse& resp) { resp.OutTo(os); } diff --git a/library/cpp/http/server/response.h b/library/cpp/http/server/response.h index 2e68d873ac..a75cb85605 100644 --- a/library/cpp/http/server/response.h +++ b/library/cpp/http/server/response.h @@ -7,7 +7,7 @@ #include <util/string/cast.h> class THttpHeaders; -class IOutputStream; +class IOutputStream; class THttpResponse { public: @@ -42,8 +42,8 @@ public: /** * @note If @arg content isn't empty its size is automatically added as a - * "Content-Length" header during output to IOutputStream. - * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) + * "Content-Length" header during output to IOutputStream. + * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) */ THttpResponse& SetContent(const TString& content) { Content = content; @@ -57,8 +57,8 @@ public: /** * @note If @arg content isn't empty its size is automatically added as a - * "Content-Length" header during output to IOutputStream. - * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) + * "Content-Length" header during output to IOutputStream. + * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) */ THttpResponse& SetContent(const TString& content, const TStringBuf& contentType) { return SetContent(content).SetContentType(contentType); @@ -73,7 +73,7 @@ public: return *this; } - void OutTo(IOutputStream& out) const; + void OutTo(IOutputStream& out) const; private: HttpCodes Code; diff --git a/library/cpp/http/server/response_ut.cpp b/library/cpp/http/server/response_ut.cpp index eb40ce6701..73e2112ad3 100644 --- a/library/cpp/http/server/response_ut.cpp +++ b/library/cpp/http/server/response_ut.cpp @@ -4,20 +4,20 @@ #include <util/string/cast.h> -Y_UNIT_TEST_SUITE(TestHttpResponse) { - Y_UNIT_TEST(TestCodeOnly) { +Y_UNIT_TEST_SUITE(TestHttpResponse) { + Y_UNIT_TEST(TestCodeOnly) { UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse()), "HTTP/1.1 200 Ok\r\n\r\n"); UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse(HTTP_NOT_FOUND)), "HTTP/1.1 404 Not found\r\n\r\n"); } - Y_UNIT_TEST(TestRedirect) { + Y_UNIT_TEST(TestRedirect) { THttpResponse resp = THttpResponse(HTTP_FOUND).AddHeader("Location", "yandex.ru"); UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), "HTTP/1.1 302 Moved temporarily\r\n" "Location: yandex.ru\r\n" "\r\n"); } - Y_UNIT_TEST(TestAddHeader) { + Y_UNIT_TEST(TestAddHeader) { THttpResponse resp(HTTP_FORBIDDEN); resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne")); resp.AddHeader("X-Header-2", 10); @@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), EXPECTED); } - Y_UNIT_TEST(TestAddMultipleHeaders) { + Y_UNIT_TEST(TestAddMultipleHeaders) { THttpHeaders headers; headers.AddHeader(THttpInputHeader("X-Header-1", "ValueOne")); headers.AddHeader(THttpInputHeader("X-Header-2", "ValueTwo")); @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { } - Y_UNIT_TEST(TestSetContent) { + Y_UNIT_TEST(TestSetContent) { const char* EXPECTED = "HTTP/1.1 200 Ok\r\n" "Content-Length: 10\r\n" "\r\n" @@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { EXPECTED); } - Y_UNIT_TEST(TestSetContentWithContentType) { + Y_UNIT_TEST(TestSetContentWithContentType) { const char* EXPECTED = "HTTP/1.1 200 Ok\r\n" "Content-Type: text/xml\r\n" "Content-Length: 28\r\n" @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), EXPECTED); } - Y_UNIT_TEST(TestCopyConstructor) { + Y_UNIT_TEST(TestCopyConstructor) { THttpResponse resp(HTTP_FORBIDDEN); resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne")) .AddHeader("X-Header-2", "ValueTwo") @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { UNIT_ASSERT_STRINGS_EQUAL(ToString(copy), ToString(resp)); } - Y_UNIT_TEST(TestAssignment) { + Y_UNIT_TEST(TestAssignment) { THttpResponse resp(HTTP_FORBIDDEN); resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne")); resp.AddHeader(THttpInputHeader("X-Header-2", "ValueTwo")); @@ -109,11 +109,11 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) { UNIT_ASSERT_STRINGS_EQUAL(ToString(copy), ToString(resp)); } - Y_UNIT_TEST(TestEmptyContent) { + Y_UNIT_TEST(TestEmptyContent) { UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse().SetContent("")), "HTTP/1.1 200 Ok\r\n\r\n"); } - Y_UNIT_TEST(TestReturnReference) { + Y_UNIT_TEST(TestReturnReference) { THttpResponse resp; UNIT_ASSERT_EQUAL(&resp, &resp.AddHeader("Header1", 1)); UNIT_ASSERT_EQUAL(&resp, &resp.AddHeader(THttpInputHeader("Header2", "2"))); diff --git a/library/cpp/hyperloglog/hyperloglog_ut.cpp b/library/cpp/hyperloglog/hyperloglog_ut.cpp index 7973525e81..b987aa0fa4 100644 --- a/library/cpp/hyperloglog/hyperloglog_ut.cpp +++ b/library/cpp/hyperloglog/hyperloglog_ut.cpp @@ -8,8 +8,8 @@ #include <cmath> -Y_UNIT_TEST_SUITE(THyperLogLog) { - Y_UNIT_TEST(TestPrecision18) { +Y_UNIT_TEST_SUITE(THyperLogLog) { + Y_UNIT_TEST(TestPrecision18) { TMersenne<ui64> rand; auto counter = THyperLogLog::Create(18); diff --git a/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp b/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp index d19ebc959a..9decc2fd48 100644 --- a/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp +++ b/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp @@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(Int128ViaIntrinsicSuite) { return res; } - Y_UNIT_TEST(bigintTest) { + Y_UNIT_TEST(bigintTest) { UNIT_ASSERT(guint128_t(127) == toGcc(ui128(127))); UNIT_ASSERT(guint128_t(127) * guint128_t(127) == toGcc(ui128(127) * ui128(127))); UNIT_ASSERT(guint128_t(127) + guint128_t(127) == toGcc(ui128(127) + ui128(127))); diff --git a/library/cpp/ipv6_address/ipv6_address.cpp b/library/cpp/ipv6_address/ipv6_address.cpp index 7924168a30..be8fcbae13 100644 --- a/library/cpp/ipv6_address/ipv6_address.cpp +++ b/library/cpp/ipv6_address/ipv6_address.cpp @@ -169,11 +169,11 @@ void TIpv6Address::ToSockaddrAndSocklen(sockaddr_in& sockAddrIPv4, sockAddrSize = sizeof(sockAddrIPv6); sockAddrPtr = reinterpret_cast<sockaddr*>(&sockAddrIPv6); } else - Y_VERIFY(false); + Y_VERIFY(false); } void TIpv6Address::ToInAddr(in_addr& Addr4) const { - Y_VERIFY(Type_ == TIpv6Address::Ipv4); + Y_VERIFY(Type_ == TIpv6Address::Ipv4); Zero(Addr4); ui32 Value = GetLow(Ip); @@ -182,7 +182,7 @@ void TIpv6Address::ToInAddr(in_addr& Addr4) const { Addr4.s_addr = SwapBytes(Value); } void TIpv6Address::ToIn6Addr(in6_addr& Addr6) const { - Y_VERIFY(Type_ == TIpv6Address::Ipv6); + Y_VERIFY(Type_ == TIpv6Address::Ipv6); Zero(Addr6); ui64 Raw[2] = {GetHigh(Ip), GetLow(Ip)}; @@ -237,7 +237,7 @@ TIpv6Address TIpv6Address::Normalized() const noexcept { return *this; TIpv6Address Result = TryToExtractIpv4From6(); - Y_VERIFY(Result.IsNull() == false); + Y_VERIFY(Result.IsNull() == false); return Result; } @@ -369,7 +369,7 @@ std::tuple<THostAddressAndPort, TString, TIpPort> ParseHostAndMayBePortFromStrin // --------------------------------------------------------------------- - const size_t ColPos = RawStr.find(':'); + const size_t ColPos = RawStr.find(':'); if (ColPos != TString::npos) { // host:port // ipv4:port diff --git a/library/cpp/ipv6_address/ipv6_address.h b/library/cpp/ipv6_address/ipv6_address.h index ef67b75aa0..1d7eb0b65f 100644 --- a/library/cpp/ipv6_address/ipv6_address.h +++ b/library/cpp/ipv6_address/ipv6_address.h @@ -233,6 +233,6 @@ NAddr::IRemoteAddr* ToIRemoteAddr(const TIpv6Address& Address, TIpPort Port); // template <> // class TSerializer<TIpv6Address> { // public: -// static void Save(IOutputStream *out, const TIpv6Address &ip); -// static void Load(IInputStream *in, TIpv6Address &ip); +// static void Save(IOutputStream *out, const TIpv6Address &ip); +// static void Load(IInputStream *in, TIpv6Address &ip); //}; diff --git a/library/cpp/json/fast_sax/parser.rl6 b/library/cpp/json/fast_sax/parser.rl6 index d25e26b02e..edb4e9ee1b 100644 --- a/library/cpp/json/fast_sax/parser.rl6 +++ b/library/cpp/json/fast_sax/parser.rl6 @@ -124,7 +124,7 @@ struct TParserCtx { } bool OnString(TStringBuf s, EStoredStr t) { - if (Y_LIKELY(OnVal())) { + if (Y_LIKELY(OnVal())) { String = s; Stored = t; return true; @@ -210,21 +210,21 @@ machine fastjson; alphtype char; -action OnNull { if (Y_UNLIKELY(!OnNull())) goto TOKEN_ERROR; } -action OnTrue { if (Y_UNLIKELY(!OnTrue())) goto TOKEN_ERROR; } -action OnFalse { if (Y_UNLIKELY(!OnFalse())) goto TOKEN_ERROR; } -action OnPInt { if (Y_UNLIKELY(!OnPInt())) goto TOKEN_ERROR; } -action OnNInt { if (Y_UNLIKELY(!OnNInt())) goto TOKEN_ERROR; } -action OnFlt { if (Y_UNLIKELY(!OnFlt())) goto TOKEN_ERROR; } -action OnStrU { if (Y_UNLIKELY(!OnStrU())) goto TOKEN_ERROR; } -action OnStrQ { if (Y_UNLIKELY(!OnStrQ())) goto TOKEN_ERROR; } -action OnStrE { if (Y_UNLIKELY(!OnStrE())) goto TOKEN_ERROR; } -action OnDictO { if (Y_UNLIKELY(!OnMapOpen())) goto TOKEN_ERROR; } -action OnDictC { if (Y_UNLIKELY(!OnMapClose())) goto TOKEN_ERROR; } -action OnArrO { if (Y_UNLIKELY(!OnArrOpen())) goto TOKEN_ERROR; } -action OnArrC { if (Y_UNLIKELY(!OnArrClose())) goto TOKEN_ERROR; } -action OnComma { if (Y_UNLIKELY(!OnComma())) goto TOKEN_ERROR; } -action OnColon { if (Y_UNLIKELY(!OnColon())) goto TOKEN_ERROR; } +action OnNull { if (Y_UNLIKELY(!OnNull())) goto TOKEN_ERROR; } +action OnTrue { if (Y_UNLIKELY(!OnTrue())) goto TOKEN_ERROR; } +action OnFalse { if (Y_UNLIKELY(!OnFalse())) goto TOKEN_ERROR; } +action OnPInt { if (Y_UNLIKELY(!OnPInt())) goto TOKEN_ERROR; } +action OnNInt { if (Y_UNLIKELY(!OnNInt())) goto TOKEN_ERROR; } +action OnFlt { if (Y_UNLIKELY(!OnFlt())) goto TOKEN_ERROR; } +action OnStrU { if (Y_UNLIKELY(!OnStrU())) goto TOKEN_ERROR; } +action OnStrQ { if (Y_UNLIKELY(!OnStrQ())) goto TOKEN_ERROR; } +action OnStrE { if (Y_UNLIKELY(!OnStrE())) goto TOKEN_ERROR; } +action OnDictO { if (Y_UNLIKELY(!OnMapOpen())) goto TOKEN_ERROR; } +action OnDictC { if (Y_UNLIKELY(!OnMapClose())) goto TOKEN_ERROR; } +action OnArrO { if (Y_UNLIKELY(!OnArrOpen())) goto TOKEN_ERROR; } +action OnArrC { if (Y_UNLIKELY(!OnArrClose())) goto TOKEN_ERROR; } +action OnComma { if (Y_UNLIKELY(!OnComma())) goto TOKEN_ERROR; } +action OnColon { if (Y_UNLIKELY(!OnColon())) goto TOKEN_ERROR; } action OnError { goto TOKEN_ERROR; } comment1 = "/*" (any* -- "*/") "*/"; @@ -296,7 +296,7 @@ bool TParserCtx::Parse() { write exec; }%% ; - Y_UNUSED(fastjson_en_main); + Y_UNUSED(fastjson_en_main); } catch (const TFromStringException& e) { return OnError(e.what()); } diff --git a/library/cpp/json/rapidjson_helpers.h b/library/cpp/json/rapidjson_helpers.h index 945a9ff7ee..aeb96ff670 100644 --- a/library/cpp/json/rapidjson_helpers.h +++ b/library/cpp/json/rapidjson_helpers.h @@ -58,7 +58,7 @@ namespace NJson { return Count; } - TInputStreamWrapper(IInputStream& helper) + TInputStreamWrapper(IInputStream& helper) : Helper(helper) , Eof(false) , Sz(0) @@ -69,7 +69,7 @@ namespace NJson { static const size_t BUF_SIZE = 1 << 12; - IInputStream& Helper; + IInputStream& Helper; mutable char Buf[BUF_SIZE]; mutable bool Eof; mutable size_t Sz; diff --git a/library/cpp/json/ut/json_prettifier_ut.cpp b/library/cpp/json/ut/json_prettifier_ut.cpp index 4ca9d5bd81..ae5f8dd81a 100644 --- a/library/cpp/json/ut/json_prettifier_ut.cpp +++ b/library/cpp/json/ut/json_prettifier_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(JsonPrettifier) { - Y_UNIT_TEST(PrettifyJsonShort) { +Y_UNIT_TEST_SUITE(JsonPrettifier) { + Y_UNIT_TEST(PrettifyJsonShort) { UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson(""), ""); UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("null"), "null"); UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("true"), "true"); @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(JsonPrettifier) { UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("{k:v}", true, 2), "{\n k : v\n}"); } - Y_UNIT_TEST(PrettifyJsonLong) { + Y_UNIT_TEST(PrettifyJsonLong) { UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("[{k:v},{a:b}]", false, 2, true), "[\n" " {\n" @@ -110,7 +110,7 @@ Y_UNIT_TEST_SUITE(JsonPrettifier) { "}"); } - Y_UNIT_TEST(PrettifyJsonInvalid) { + Y_UNIT_TEST(PrettifyJsonInvalid) { UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("}"), ""); UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("}}"), ""); UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("{}}"), ""); @@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(JsonPrettifier) { UNIT_ASSERT_STRINGS_EQUAL(NJson::PrettifyJson("{,,,}"), ""); } - Y_UNIT_TEST(CompactifyJsonShort) { + Y_UNIT_TEST(CompactifyJsonShort) { UNIT_ASSERT_STRINGS_EQUAL(NJson::CompactifyJson(""), ""); UNIT_ASSERT_STRINGS_EQUAL(NJson::CompactifyJson("null"), "null"); UNIT_ASSERT_STRINGS_EQUAL(NJson::CompactifyJson("true"), "true"); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(JsonPrettifier) { UNIT_ASSERT_STRINGS_EQUAL(NJson::CompactifyJson("{\n 'k' : 'v'\n}", true), "{k:v}"); } - Y_UNIT_TEST(CompactifyJsonLong) { + Y_UNIT_TEST(CompactifyJsonLong) { UNIT_ASSERT_STRINGS_EQUAL(NJson::CompactifyJson( "[\n" " {\n" diff --git a/library/cpp/json/ut/json_reader_ut.cpp b/library/cpp/json/ut/json_reader_ut.cpp index f4c9bf9df6..cd31afa0b8 100644 --- a/library/cpp/json/ut/json_reader_ut.cpp +++ b/library/cpp/json/ut/json_reader_ut.cpp @@ -66,8 +66,8 @@ public: } }; -Y_UNIT_TEST_SUITE(TJsonReaderTest) { - Y_UNIT_TEST(JsonReformatTest) { +Y_UNIT_TEST_SUITE(TJsonReaderTest) { + Y_UNIT_TEST(JsonReformatTest) { TString data = "{\"null value\": null, \"intkey\": 10, \"double key\": 11.11, \"string key\": \"string\", \"array\": [1,2,3,\"TString\"], \"bool key\": true}"; TString result1, result2; @@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } } - Y_UNIT_TEST(TJsonTreeTest) { + Y_UNIT_TEST(TJsonTreeTest) { TString data = "{\"intkey\": 10, \"double key\": 11.11, \"null value\":null, \"string key\": \"string\", \"array\": [1,2,3,\"TString\"], \"bool key\": true}"; TStringStream in; in << data; @@ -154,7 +154,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { UNIT_ASSERT_VALUES_EQUAL(value["array"][3].GetString(), (*array)[3].GetString()); } - Y_UNIT_TEST(TJsonRomaTest) { + Y_UNIT_TEST(TJsonRomaTest) { TString data = "{\"test\": [ {\"name\": \"A\"} ]}"; TStringStream in; @@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { UNIT_ASSERT_VALUES_EQUAL(value["test"][0]["name"].GetString(), TString("A")); } - Y_UNIT_TEST(TJsonReadTreeWithComments) { + Y_UNIT_TEST(TJsonReadTreeWithComments) { { TString leadingCommentData = "{ // \"test\" : 1 \n}"; { @@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } } - Y_UNIT_TEST(TJsonSignedIntegerTest) { + Y_UNIT_TEST(TJsonSignedIntegerTest) { { TStringStream in; in << "{ \"test\" : " << Min<i64>() << " }"; @@ -234,7 +234,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } // Max<i64>() + 1 } - Y_UNIT_TEST(TJsonUnsignedIntegerTest) { + Y_UNIT_TEST(TJsonUnsignedIntegerTest) { { TStringStream in; in << "{ \"test\" : 1 }"; @@ -309,7 +309,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } } // TJsonUnsignedIntegerTest - Y_UNIT_TEST(TJsonDoubleTest) { + Y_UNIT_TEST(TJsonDoubleTest) { { TStringStream in; in << "{ \"test\" : 1.0 }"; @@ -355,7 +355,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } // Max<ui64>() } // TJsonDoubleTest - Y_UNIT_TEST(TJsonInvalidTest) { + Y_UNIT_TEST(TJsonInvalidTest) { { // No exceptions mode. TStringStream in; @@ -373,7 +373,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } } - Y_UNIT_TEST(TJsonMemoryLeakTest) { + Y_UNIT_TEST(TJsonMemoryLeakTest) { // after https://clubs.at.yandex-team.ru/stackoverflow/3691 TString s = "."; NJson::TJsonValue json; diff --git a/library/cpp/json/ut/json_writer_ut.cpp b/library/cpp/json/ut/json_writer_ut.cpp index bda63e3807..ca11d34dad 100644 --- a/library/cpp/json/ut/json_writer_ut.cpp +++ b/library/cpp/json/ut/json_writer_ut.cpp @@ -5,8 +5,8 @@ using namespace NJson; -Y_UNIT_TEST_SUITE(TJsonWriterTest) { - Y_UNIT_TEST(SimpleWriteTest) { +Y_UNIT_TEST_SUITE(TJsonWriterTest) { + Y_UNIT_TEST(SimpleWriteTest) { TString expected1 = "{\"key1\":1,\"key2\":2,\"key3\":3"; TString expected2 = expected1 + ",\"array\":[\"stroka\",false]"; TString expected3 = expected2 + "}"; @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected3); } - Y_UNIT_TEST(SimpleWriteValueTest) { + Y_UNIT_TEST(SimpleWriteValueTest) { TString expected = "{\"key1\":null,\"key2\":{\"subkey1\":[1,{\"subsubkey\":\"test2\"},null,true],\"subkey2\":\"test\"}}"; TJsonValue v; v["key1"] = JSON_NULL; @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); } - Y_UNIT_TEST(FormatOutput) { + Y_UNIT_TEST(FormatOutput) { TString expected = "{\n \"key1\":null,\n \"key2\":\n {\n \"subkey1\":\n [\n 1,\n {\n \"subsubkey\":\"test2\"\n },\n null,\n true\n ],\n \"subkey2\":\"test\"\n }\n}"; TJsonValue v; v["key1"] = JSON_NULL; @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_STRINGS_EQUAL(out.Str(), expected); } - Y_UNIT_TEST(SortKeys) { + Y_UNIT_TEST(SortKeys) { TString expected = "{\"a\":null,\"j\":null,\"n\":null,\"y\":null,\"z\":null}"; TJsonValue v; v["z"] = JSON_NULL; @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_STRINGS_EQUAL(out.Str(), expected); } - Y_UNIT_TEST(SimpleUnsignedIntegerWriteTest) { + Y_UNIT_TEST(SimpleUnsignedIntegerWriteTest) { { TString expected = "{\"test\":1}"; TJsonValue v; @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } // 18446744073709551615 } // SimpleUnsignedIntegerWriteTest - Y_UNIT_TEST(WriteOptionalTest) { + Y_UNIT_TEST(WriteOptionalTest) { { TString expected = "{\"test\":1}"; @@ -180,7 +180,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } } - Y_UNIT_TEST(Callback) { + Y_UNIT_TEST(Callback) { NJsonWriter::TBuf json; json.WriteString("A"); UNIT_ASSERT_VALUES_EQUAL(json.Str(), "\"A\""); @@ -188,7 +188,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_VALUES_EQUAL(WrapJsonToCallback(json, "Foo"), "Foo(\"A\")"); } - Y_UNIT_TEST(FloatPrecision) { + Y_UNIT_TEST(FloatPrecision) { const double value = 1517933989.4242; const NJson::TJsonValue json(value); NJson::TJsonWriterConfig config; diff --git a/library/cpp/json/ut/ya.make b/library/cpp/json/ut/ya.make index edc8f0f3f6..8e0362d84b 100644 --- a/library/cpp/json/ut/ya.make +++ b/library/cpp/json/ut/ya.make @@ -1,5 +1,5 @@ -OWNER(velavokr) - +OWNER(velavokr) + UNITTEST_FOR(library/cpp/json) PEERDIR( diff --git a/library/cpp/json/writer/json.h b/library/cpp/json/writer/json.h index 94a1953630..0aae2531b9 100644 --- a/library/cpp/json/writer/json.h +++ b/library/cpp/json/writer/json.h @@ -41,7 +41,7 @@ namespace NJsonWriter { class TBuf : TNonCopyable { public: - TBuf(EHtmlEscapeMode mode = HEM_DONT_ESCAPE_HTML, IOutputStream* stream = nullptr); + TBuf(EHtmlEscapeMode mode = HEM_DONT_ESCAPE_HTML, IOutputStream* stream = nullptr); TValueContext WriteString(const TStringBuf& s, EHtmlEscapeMode hem); TValueContext WriteString(const TStringBuf& s); @@ -93,7 +93,7 @@ namespace NJsonWriter { /*** Dump and forget the string constructed so far. * You may only call it if the `stream' parameter was NULL * at construction time. */ - void FlushTo(IOutputStream* stream); + void FlushTo(IOutputStream* stream); /*** Write a literal string that represents a JSON value * (string, number, object, array, bool, or null). @@ -145,7 +145,7 @@ namespace NJsonWriter { TValueContext WriteFloatImpl(TFloat f, EFloatToStringMode mode, int ndigits); private: - IOutputStream* Stream; + IOutputStream* Stream; THolder<TStringStream> StringStream; typedef TVector<const TString*> TKeys; TKeys Keys; diff --git a/library/cpp/json/writer/json_ut.cpp b/library/cpp/json/writer/json_ut.cpp index c2b2ccb95c..9980555683 100644 --- a/library/cpp/json/writer/json_ut.cpp +++ b/library/cpp/json/writer/json_ut.cpp @@ -6,8 +6,8 @@ #include <limits> -Y_UNIT_TEST_SUITE(JsonWriter) { - Y_UNIT_TEST(Struct) { +Y_UNIT_TEST_SUITE(JsonWriter) { + Y_UNIT_TEST(Struct) { NJsonWriter::TBuf w; w.BeginList(); w.BeginObject() @@ -29,21 +29,21 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char* exp = "[{\"key\":\"value\",\"xk\":13,\"key2\":[{},{}]},43,\"x\",\"...\"]"; UNIT_ASSERT_EQUAL(w.Str(), exp); } - Y_UNIT_TEST(EscapedString) { + Y_UNIT_TEST(EscapedString) { NJsonWriter::TBuf w(NJsonWriter::HEM_ESCAPE_HTML); w.WriteString(" \n \r \t \007 \b \f ' <tag> &ent; \"txt\" "); TString ws = w.Str(); const char* exp = "\" \\n \\r \\t \\u0007 \\b \\f ' <tag> &ent; "txt" \""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(UnescapedString) { + Y_UNIT_TEST(UnescapedString) { NJsonWriter::TBuf w; w.WriteString(" \n \r \t \b \f '; -- <tag> &ent; \"txt\"", NJsonWriter::HEM_DONT_ESCAPE_HTML); TString ws = w.Str(); const char* exp = "\" \\n \\r \\t \\b \\f \\u0027; -- \\u003Ctag\\u003E &ent; \\\"txt\\\"\""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(UnescapedChaining) { + Y_UNIT_TEST(UnescapedChaining) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML); w.UnsafeWriteRawBytes("(", 1); w.BeginList().WriteString("<>&'\\").BeginList(); @@ -52,27 +52,27 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char* exp = "([\"\\u003C\\u003E&\\u0027\\\\\",[]]"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(Utf8) { + Y_UNIT_TEST(Utf8) { TString ws = NJsonWriter::TBuf().WriteString("яЯ σΣ ש א").Str(); const char* exp = "\"яЯ σΣ ש א\""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(WrongObject) { + Y_UNIT_TEST(WrongObject) { NJsonWriter::TBuf w; w.BeginObject(); UNIT_ASSERT_EXCEPTION(w.WriteString("hehe"), NJsonWriter::TError); } - Y_UNIT_TEST(WrongList) { + Y_UNIT_TEST(WrongList) { NJsonWriter::TBuf w; w.BeginList(); UNIT_ASSERT_EXCEPTION(w.WriteKey("hehe"), NJsonWriter::TError); } - Y_UNIT_TEST(Incomplete) { + Y_UNIT_TEST(Incomplete) { NJsonWriter::TBuf w; w.BeginList(); UNIT_ASSERT_EXCEPTION(w.Str(), NJsonWriter::TError); } - Y_UNIT_TEST(BareKey) { + Y_UNIT_TEST(BareKey) { NJsonWriter::TBuf w; w.BeginObject() .CompatWriteKeyWithoutQuotes("p") @@ -84,24 +84,24 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char* exp = "{p:1,n:0}"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(UnescapedStringInObject) { + Y_UNIT_TEST(UnescapedStringInObject) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML); w.BeginObject().WriteKey("key").WriteString("</&>'").EndObject(); TString ws = w.Str(); const char* exp = "{\"key\":\"\\u003C\\/&\\u003E\\u0027\"}"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(ForeignStreamStr) { + Y_UNIT_TEST(ForeignStreamStr) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML, &Cerr); UNIT_ASSERT_EXCEPTION(w.Str(), NJsonWriter::TError); } - Y_UNIT_TEST(ForeignStreamValue) { + Y_UNIT_TEST(ForeignStreamValue) { TStringStream ss; NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML, &ss); w.WriteInt(1543); UNIT_ASSERT_STRINGS_EQUAL(ss.Str(), "1543"); } - Y_UNIT_TEST(Indentation) { + Y_UNIT_TEST(Indentation) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML); w.SetIndentSpaces(2); w.BeginList() @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(JsonWriter) { "]"; UNIT_ASSERT_STRINGS_EQUAL(exp, w.Str()); } - Y_UNIT_TEST(WriteJsonValue) { + Y_UNIT_TEST(WriteJsonValue) { using namespace NJson; TJsonValue val; val.AppendValue(1); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char exp[] = "[1,\"2\",3.5,{\"key\":\"value\"},null]"; UNIT_ASSERT_STRINGS_EQUAL(exp, w.Str()); } - Y_UNIT_TEST(WriteJsonValueSorted) { + Y_UNIT_TEST(WriteJsonValueSorted) { using namespace NJson; TJsonValue val; val.InsertValue("1", TJsonValue(1)); @@ -159,35 +159,35 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char exp[] = "{\"0\":{\"succ\":1,\"zero\":0},\"1\":1,\"2\":2}"; UNIT_ASSERT_STRINGS_EQUAL(exp, w.Str()); } - Y_UNIT_TEST(Unescaped) { + Y_UNIT_TEST(Unescaped) { NJsonWriter::TBuf buf(NJsonWriter::HEM_UNSAFE); buf.WriteString("</security>'"); UNIT_ASSERT_STRINGS_EQUAL("\"</security>'\"", buf.Str()); } - Y_UNIT_TEST(LittleBobbyJsonp) { + Y_UNIT_TEST(LittleBobbyJsonp) { NJsonWriter::TBuf buf; buf.WriteString("hello\xe2\x80\xa8\xe2\x80\xa9stranger"); UNIT_ASSERT_STRINGS_EQUAL("\"hello\\u2028\\u2029stranger\"", buf.Str()); } - Y_UNIT_TEST(LittleBobbyInvalid) { + Y_UNIT_TEST(LittleBobbyInvalid) { NJsonWriter::TBuf buf; TStringBuf incomplete("\xe2\x80\xa8", 2); buf.WriteString(incomplete); // garbage in - garbage out UNIT_ASSERT_STRINGS_EQUAL("\"\xe2\x80\"", buf.Str()); } - Y_UNIT_TEST(OverlyZealous) { + Y_UNIT_TEST(OverlyZealous) { NJsonWriter::TBuf buf; buf.WriteString("—"); UNIT_ASSERT_STRINGS_EQUAL("\"—\"", buf.Str()); } - Y_UNIT_TEST(RelaxedEscaping) { + Y_UNIT_TEST(RelaxedEscaping) { NJsonWriter::TBuf buf(NJsonWriter::HEM_RELAXED); buf.WriteString("</>"); UNIT_ASSERT_STRINGS_EQUAL("\"\\u003C/\\u003E\"", buf.Str()); } - Y_UNIT_TEST(FloatFormatting) { + Y_UNIT_TEST(FloatFormatting) { NJsonWriter::TBuf buf(NJsonWriter::HEM_DONT_ESCAPE_HTML); buf.BeginList() .WriteFloat(0.12345678987654321f) @@ -206,7 +206,7 @@ Y_UNIT_TEST_SUITE(JsonWriter) { UNIT_ASSERT_STRINGS_EQUAL(exp, buf.Str()); } - Y_UNIT_TEST(NanFormatting) { + Y_UNIT_TEST(NanFormatting) { { NJsonWriter::TBuf buf; buf.BeginObject(); diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index 27da313fd4..c61e8d1dc4 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -18,7 +18,7 @@ static bool AreJsonMapsEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { using namespace NJson; - Y_VERIFY(lhs.GetType() == JSON_MAP, "lhs has not a JSON_MAP type."); + Y_VERIFY(lhs.GetType() == JSON_MAP, "lhs has not a JSON_MAP type."); if (rhs.GetType() != JSON_MAP) return false; @@ -30,12 +30,12 @@ AreJsonMapsEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { if (lhsMap.size() != rhsMap.size()) return false; - for (const auto& lhsIt : lhsMap) { + for (const auto& lhsIt : lhsMap) { TMapType::const_iterator rhsIt = rhsMap.find(lhsIt.first); if (rhsIt == rhsMap.end()) return false; - if (lhsIt.second != rhsIt->second) + if (lhsIt.second != rhsIt->second) return false; } @@ -46,7 +46,7 @@ static bool AreJsonArraysEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { using namespace NJson; - Y_VERIFY(lhs.GetType() == JSON_ARRAY, "lhs has not a JSON_ARRAY type."); + Y_VERIFY(lhs.GetType() == JSON_ARRAY, "lhs has not a JSON_ARRAY type."); if (rhs.GetType() != JSON_ARRAY) return false; @@ -1099,7 +1099,7 @@ namespace NJson { } template <> -void Out<NJson::TJsonValue>(IOutputStream& out, const NJson::TJsonValue& v) { +void Out<NJson::TJsonValue>(IOutputStream& out, const NJson::TJsonValue& v) { NJsonWriter::TBuf buf(NJsonWriter::HEM_DONT_ESCAPE_HTML, &out); buf.WriteJsonValue(&v); } diff --git a/library/cpp/json/writer/json_value_ut.cpp b/library/cpp/json/writer/json_value_ut.cpp index ea33ef0888..dc7f6affdf 100644 --- a/library/cpp/json/writer/json_value_ut.cpp +++ b/library/cpp/json/writer/json_value_ut.cpp @@ -6,8 +6,8 @@ using namespace NJson; -Y_UNIT_TEST_SUITE(TJsonValueTest) { - Y_UNIT_TEST(UndefTest) { +Y_UNIT_TEST_SUITE(TJsonValueTest) { + Y_UNIT_TEST(UndefTest) { TJsonValue undef; TJsonValue null(JSON_NULL); TJsonValue _false(false); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT(undef != emptyMap); } - Y_UNIT_TEST(DefaultCompareTest) { + Y_UNIT_TEST(DefaultCompareTest) { { TJsonValue lhs; TJsonValue rhs; @@ -52,14 +52,14 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(NullCompareTest) { + Y_UNIT_TEST(NullCompareTest) { TJsonValue lhs(JSON_NULL); TJsonValue rhs(JSON_NULL); UNIT_ASSERT(lhs == rhs); UNIT_ASSERT(rhs == lhs); } - Y_UNIT_TEST(StringCompareTest) { + Y_UNIT_TEST(StringCompareTest) { { TJsonValue lhs(JSON_STRING); TJsonValue rhs(JSON_STRING); @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(ArrayCompareTest) { + Y_UNIT_TEST(ArrayCompareTest) { { TJsonValue lhs(JSON_ARRAY); TJsonValue rhs(JSON_ARRAY); @@ -139,7 +139,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(CompareTest) { + Y_UNIT_TEST(CompareTest) { { TJsonValue lhs; lhs.InsertValue("null value", TJsonValue(JSON_NULL)); @@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(SwapTest) { + Y_UNIT_TEST(SwapTest) { { TJsonValue lhs; lhs.InsertValue("a", "b"); @@ -233,7 +233,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(GetValueByPathTest) { + Y_UNIT_TEST(GetValueByPathTest) { { TJsonValue lhs; TJsonValue first; @@ -285,7 +285,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(GetValueByPathConstTest) { + Y_UNIT_TEST(GetValueByPathConstTest) { TJsonValue lhs; TJsonValue first; TJsonValue second; @@ -339,7 +339,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT(third.GetValueByPath("t.[1].c.e", '.')->GetStringRobust() == "f"); } - Y_UNIT_TEST(EraseValueFromArray) { + Y_UNIT_TEST(EraseValueFromArray) { { TJsonValue vec; vec.AppendValue(TJsonValue(0)); @@ -378,7 +378,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(NonConstMethodsTest) { + Y_UNIT_TEST(NonConstMethodsTest) { { TJsonValue src; TJsonValue value1; @@ -506,7 +506,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(NonexistentFieldAccessTest) { + Y_UNIT_TEST(NonexistentFieldAccessTest) { { TJsonValue json; json.InsertValue("some", "key"); @@ -518,7 +518,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(DefaultValuesTest) { + Y_UNIT_TEST(DefaultValuesTest) { { TJsonValue json; json.InsertValue("some", "key"); @@ -540,7 +540,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(GetArrayPointerInArrayTest) { + Y_UNIT_TEST(GetArrayPointerInArrayTest) { TJsonValue outer; { TJsonValue json; @@ -555,7 +555,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*array)[1], 2); } - Y_UNIT_TEST(GetArrayPointerInMapTest) { + Y_UNIT_TEST(GetArrayPointerInMapTest) { TJsonValue outer; { TJsonValue json; @@ -570,7 +570,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*array)[1], 2); } - Y_UNIT_TEST(GetMapPointerInArrayTest) { + Y_UNIT_TEST(GetMapPointerInArrayTest) { TJsonValue outer; { TJsonValue json; @@ -585,7 +585,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*map).at("b"), 2); } - Y_UNIT_TEST(GetMapPointerInMapTest) { + Y_UNIT_TEST(GetMapPointerInMapTest) { TJsonValue outer; { TJsonValue json; @@ -600,14 +600,14 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*map).at("b"), 2); } - Y_UNIT_TEST(GetIntegerRobustBignumStringTest) { + Y_UNIT_TEST(GetIntegerRobustBignumStringTest) { TString value = "1626862681464633683"; TJsonValue json(value); UNIT_ASSERT_VALUES_EQUAL(json.GetUIntegerRobust(), FromString<ui64>(value)); UNIT_ASSERT_VALUES_EQUAL(json.GetIntegerRobust(), FromString<i64>(value)); } - Y_UNIT_TEST(MoveSubpartToSelf) { + Y_UNIT_TEST(MoveSubpartToSelf) { TJsonValue json; json[0] = "testing 0"; json[1] = "testing 1"; diff --git a/library/cpp/json/yson/json2yson_ut.cpp b/library/cpp/json/yson/json2yson_ut.cpp index a486b625c2..9eb23354cf 100644 --- a/library/cpp/json/yson/json2yson_ut.cpp +++ b/library/cpp/json/yson/json2yson_ut.cpp @@ -23,7 +23,7 @@ static TString GetRequestsWithDecoding(const TString& inputPath, const NBlockCod return requests; } -Y_UNIT_TEST_SUITE(Json2Yson) { +Y_UNIT_TEST_SUITE(Json2Yson) { Y_UNIT_TEST(NOAPACHE_REQUESTS) { const ui32 warmUpRetries = 5; const TVector<double> percentiles = {0.25, 0.5, 0.6, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.97, 0.99, 1.0}; diff --git a/library/cpp/lfalloc/alloc_profiler/profiler.h b/library/cpp/lfalloc/alloc_profiler/profiler.h index db5cd610fc..4ea49b9dcc 100644 --- a/library/cpp/lfalloc/alloc_profiler/profiler.h +++ b/library/cpp/lfalloc/alloc_profiler/profiler.h @@ -5,7 +5,7 @@ #include <library/cpp/lfalloc/dbg_info/dbg_info.h> #include <util/generic/noncopyable.h> -#include <util/stream/output.h> +#include <util/stream/output.h> namespace NAllocProfiler { diff --git a/library/cpp/lfalloc/alloc_profiler/stackcollect.h b/library/cpp/lfalloc/alloc_profiler/stackcollect.h index ac6aa9ebb9..80715ed7cb 100644 --- a/library/cpp/lfalloc/alloc_profiler/stackcollect.h +++ b/library/cpp/lfalloc/alloc_profiler/stackcollect.h @@ -5,7 +5,7 @@ #include <util/generic/noncopyable.h> #include <util/generic/ptr.h> -#include <util/stream/output.h> +#include <util/stream/output.h> namespace NAllocProfiler { diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h index 510d02da98..fd2a906d6f 100644 --- a/library/cpp/lfalloc/lf_allocX64.h +++ b/library/cpp/lfalloc/lf_allocX64.h @@ -116,7 +116,7 @@ static inline long AtomicSub(TAtomic& a, long b) { #ifndef _darwin_ #ifndef Y_ARRAY_SIZE -#define Y_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#define Y_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) #endif #ifndef NDEBUG @@ -261,7 +261,7 @@ static volatile int freeChunkCount; static void AddFreeChunk(uintptr_t chunkId) { chunkSizeIdx[chunkId] = -1; - if (Y_UNLIKELY(freeChunkCount == FREE_CHUNK_ARR_BUF)) + if (Y_UNLIKELY(freeChunkCount == FREE_CHUNK_ARR_BUF)) NMalloc::AbortFromCorruptedAllocator("free chunks array overflowed"); freeChunkArr[freeChunkCount++] = chunkId; } @@ -303,7 +303,7 @@ enum EMMapMode { #ifndef _MSC_VER inline void VerifyMmapResult(void* result) { - if (Y_UNLIKELY(result == MAP_FAILED)) + if (Y_UNLIKELY(result == MAP_FAILED)) NMalloc::AbortFromCorruptedAllocator("negative size requested? or just out of mem"); } #endif @@ -336,7 +336,7 @@ static char* AllocWithMMapLinuxImpl(uintptr_t sz, EMMapMode mode) { char* prevAllocPtr = *areaPtr; char* nextAllocPtr = prevAllocPtr + sz; if (uintptr_t(nextAllocPtr - (char*)nullptr) >= areaFinish) { - if (Y_UNLIKELY(wrapped)) { + if (Y_UNLIKELY(wrapped)) { NMalloc::AbortFromCorruptedAllocator("virtual memory is over fragmented"); } // wrap after all area is used @@ -369,13 +369,13 @@ static char* AllocWithMMap(uintptr_t sz, EMMapMode mode) { char* largeBlock = (char*)VirtualAlloc(0, sz, MEM_RESERVE, PAGE_READWRITE); if (Y_UNLIKELY(largeBlock == nullptr)) NMalloc::AbortFromCorruptedAllocator("out of memory"); - if (Y_UNLIKELY(uintptr_t(((char*)largeBlock - ALLOC_START) + sz) >= N_MAX_WORKSET_SIZE)) + if (Y_UNLIKELY(uintptr_t(((char*)largeBlock - ALLOC_START) + sz) >= N_MAX_WORKSET_SIZE)) NMalloc::AbortFromCorruptedAllocator("out of working set, something has broken"); #else #if defined(_freebsd_) || !defined(_64_) char* largeBlock = (char*)mmap(0, sz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); VerifyMmapResult(largeBlock); - if (Y_UNLIKELY(uintptr_t(((char*)largeBlock - ALLOC_START) + sz) >= N_MAX_WORKSET_SIZE)) + if (Y_UNLIKELY(uintptr_t(((char*)largeBlock - ALLOC_START) + sz) >= N_MAX_WORKSET_SIZE)) NMalloc::AbortFromCorruptedAllocator("out of working set, something has broken"); #else char* largeBlock = AllocWithMMapLinuxImpl(sz, mode); @@ -452,7 +452,7 @@ static void* LargeBlockAlloc(size_t _nSize, ELFAllocCounter counter) { size_t pgCount = (_nSize + 4095) / 4096; #ifdef _MSC_VER char* pRes = (char*)VirtualAlloc(0, (pgCount + 1) * 4096ll, MEM_COMMIT, PAGE_READWRITE); - if (Y_UNLIKELY(pRes == 0)) { + if (Y_UNLIKELY(pRes == 0)) { NMalloc::AbortFromCorruptedAllocator("out of memory"); } #else @@ -492,12 +492,12 @@ static void* LargeBlockAlloc(size_t _nSize, ELFAllocCounter counter) { #ifndef _MSC_VER static void FreeAllLargeBlockMem() { - for (auto& lbFreePtr : lbFreePtrs) { + for (auto& lbFreePtr : lbFreePtrs) { for (int i = 0; i < LB_BUF_SIZE; ++i) { - void* p = lbFreePtr[i]; + void* p = lbFreePtr[i]; if (p == nullptr) continue; - if (DoCas(&lbFreePtr[i], (void*)nullptr, p) == p) { + if (DoCas(&lbFreePtr[i], (void*)nullptr, p) == p) { int pgCount = TLargeBlk::As(p)->Pages; AtomicAdd(lbFreePageCount, -pgCount); LargeBlockUnmap(p, pgCount); @@ -782,7 +782,7 @@ static bool DefragmentMem() { IncrementCounter(CT_DEGRAGMENT_CNT, 1); int* nFreeCount = (int*)SystemAlloc(N_CHUNKS * sizeof(int)); - if (Y_UNLIKELY(!nFreeCount)) { + if (Y_UNLIKELY(!nFreeCount)) { //__debugbreak(); NMalloc::AbortFromCorruptedAllocator("debugbreak"); } @@ -792,7 +792,7 @@ static bool DefragmentMem() { for (int nSizeIdx = 0; nSizeIdx < N_SIZES; ++nSizeIdx) { wholeLists[nSizeIdx] = (TFreeListGroup*)globalFreeLists[nSizeIdx].GetWholeList(); for (TFreeListGroup* g = wholeLists[nSizeIdx]; g; g = g->Next) { - for (auto pData : g->Ptrs) { + for (auto pData : g->Ptrs) { if (pData) { uintptr_t nChunk = (pData - ALLOC_START) / N_CHUNK_SIZE; ++nFreeCount[nChunk]; @@ -816,12 +816,12 @@ static bool DefragmentMem() { } } if (bRes) { - for (auto& wholeList : wholeLists) { - TFreeListGroup** ppPtr = &wholeList; + for (auto& wholeList : wholeLists) { + TFreeListGroup** ppPtr = &wholeList; while (*ppPtr) { TFreeListGroup* g = *ppPtr; int dst = 0; - for (auto pData : g->Ptrs) { + for (auto pData : g->Ptrs) { if (pData) { uintptr_t nChunk = (pData - ALLOC_START) / N_CHUNK_SIZE; if (nFreeCount[nChunk] == 0) @@ -964,9 +964,9 @@ static Y_FORCE_INLINE int TakeBlocksFromGlobalFreeList(int nSizeIdx, char** buf) TFreeListGroup* g = (TFreeListGroup*)fl.Alloc(); if (g) { int resCount = 0; - for (auto& ptr : g->Ptrs) { - if (ptr) - buf[resCount++] = ptr; + for (auto& ptr : g->Ptrs) { + if (ptr) + buf[resCount++] = ptr; else break; } @@ -1116,8 +1116,8 @@ struct TThreadAllocInfo { void Init(TThreadAllocInfo** pHead) { memset(this, 0, sizeof(*this)); - for (auto& i : FreePtrIndex) - i = THREAD_BUF; + for (auto& i : FreePtrIndex) + i = THREAD_BUF; #ifdef _win_ BOOL b = DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), @@ -1146,11 +1146,11 @@ struct TThreadAllocInfo { #endif } void Done() { - for (auto sizeIdx : FreePtrIndex) { + for (auto sizeIdx : FreePtrIndex) { Y_ASSERT_NOBT(sizeIdx == THREAD_BUF); } - for (auto& localCounter : LocalCounters) { - localCounter.Flush(); + for (auto& localCounter : LocalCounters) { + localCounter.Flush(); } #if defined(LFALLOC_DBG) for (int tag = 0; tag < DBG_ALLOC_MAX_TAG; ++tag) { @@ -1740,13 +1740,13 @@ static void DumpMemoryBlockUtilizationLocked() { int nEntriesTotal = N_CHUNK_SIZE / nSize; memset(entries, 0, nEntriesTotal); for (TFreeListGroup* g = wholeLists[nSizeIdx]; g; g = g->Next) { - for (auto& ptr : g->Ptrs) - cs.CheckBlock(ptr); + for (auto& ptr : g->Ptrs) + cs.CheckBlock(ptr); } TChunkStats csGB(k, nSize, entries); if (nSizeIdx == FREE_LIST_GROUP_SIZEIDX) { - for (auto g : wholeLists) { - for (; g; g = g->Next) + for (auto g : wholeLists) { + for (; g; g = g->Next) csGB.CheckBlock((char*)g); } for (char* blk = bfList; blk; blk = *(char**)blk) @@ -1769,9 +1769,9 @@ static void DumpMemoryBlockUtilizationLocked() { pages[(nShift + nDelta) / N_PAGE_SIZE] |= nBit; } i64 nBadPages = 0; - for (auto page : pages) { - nBadPages += page == 3; - nTotalPages += page != 1; + for (auto page : pages) { + nBadPages += page == 3; + nTotalPages += page != 1; } DebugTraceMMgr("entry = %lld; size = %lld; free = %lld; system %lld; utilisation = %g%%, fragmentation = %g%%\n", k, nSize, cs.FreeCount * nSize, csGB.FreeCount * nSize, @@ -1869,7 +1869,7 @@ static const char* LFAlloc_GetParam(const char* param) { } static Y_FORCE_INLINE int LFPosixMemalign(void** memptr, size_t alignment, size_t size) { - if (Y_UNLIKELY(alignment > 4096)) { + if (Y_UNLIKELY(alignment > 4096)) { const char* error = "Larger alignment are not guaranteed with this implementation\n"; #ifdef _win_ OutputDebugStringA(error); diff --git a/library/cpp/lfalloc/ya.make b/library/cpp/lfalloc/ya.make index 7cb1ff8523..cace05f9d8 100644 --- a/library/cpp/lfalloc/ya.make +++ b/library/cpp/lfalloc/ya.make @@ -1,7 +1,7 @@ LIBRARY() -OWNER(gulin) - +OWNER(gulin) + NO_UTIL() NO_COMPILER_WARNINGS() diff --git a/library/cpp/linear_regression/linear_regression.h b/library/cpp/linear_regression/linear_regression.h index 20b3ae1e53..e57de5ff6c 100644 --- a/library/cpp/linear_regression/linear_regression.h +++ b/library/cpp/linear_regression/linear_regression.h @@ -146,12 +146,12 @@ public: bool Add(const double* featuresBegin, const double* featuresEnd, const double* goalsBegin, const double* weightsBegin); bool Add(const TVector<double>& features, const TVector<double>& goals) { - Y_ASSERT(features.size() == goals.size()); + Y_ASSERT(features.size() == goals.size()); return Add(features.data(), features.data() + features.size(), goals.data()); } bool Add(const TVector<double>& features, const TVector<double>& goals, const TVector<double>& weights) { - Y_ASSERT(features.size() == goals.size() && features.size() == weights.size()); + Y_ASSERT(features.size() == goals.size() && features.size() == weights.size()); return Add(features.data(), features.data() + features.size(), goals.data(), weights.data()); } @@ -239,7 +239,7 @@ struct TTransformationParameters { double FeatureOffset = 0.; double FeatureNormalizer = 1.; - Y_SAVELOAD_DEFINE(RegressionFactor, + Y_SAVELOAD_DEFINE(RegressionFactor, RegressionIntercept, FeatureOffset, FeatureNormalizer); @@ -251,7 +251,7 @@ private: TTransformationParameters TransformationParameters; public: - Y_SAVELOAD_DEFINE(TransformationType, TransformationParameters); + Y_SAVELOAD_DEFINE(TransformationType, TransformationParameters); TFeaturesTransformer() = default; @@ -273,7 +273,7 @@ public: return TransformationParameters.RegressionIntercept + TransformationParameters.RegressionFactor * transformedValue; } } - Y_ASSERT(0); + Y_ASSERT(0); return 0.; } }; diff --git a/library/cpp/linear_regression/linear_regression_ut.cpp b/library/cpp/linear_regression/linear_regression_ut.cpp index 991a95c0d0..e71a16b67a 100644 --- a/library/cpp/linear_regression/linear_regression_ut.cpp +++ b/library/cpp/linear_regression/linear_regression_ut.cpp @@ -13,8 +13,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TLinearRegressionTest) { - Y_UNIT_TEST(MeanAndDeviationTest) { +Y_UNIT_TEST_SUITE(TLinearRegressionTest) { + Y_UNIT_TEST(MeanAndDeviationTest) { TVector<double> arguments; TVector<double> weights; @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { ValueIsCorrect(deviationCalculator.GetDeviation(), checkRemovingDeviationCalculator.GetDeviation(), 1e-5); } - Y_UNIT_TEST(CovariationTest) { + Y_UNIT_TEST(CovariationTest) { TVector<double> firstValues; TVector<double> secondValues; TVector<double> weights; @@ -176,15 +176,15 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { } } - Y_UNIT_TEST(FastSLRTest) { + Y_UNIT_TEST(FastSLRTest) { SLRTest<TFastSLRSolver>(); } - Y_UNIT_TEST(KahanSLRTest) { + Y_UNIT_TEST(KahanSLRTest) { SLRTest<TKahanSLRSolver>(); } - Y_UNIT_TEST(SLRTest) { + Y_UNIT_TEST(SLRTest) { SLRTest<TSLRSolver>(); } @@ -231,11 +231,11 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { UNIT_ASSERT_DOUBLES_EQUAL(lrSolver.SumSquaredErrors(), expectedSumSquaredErrors, expectedSumSquaredErrors * 0.01); } - Y_UNIT_TEST(FastLRTest) { + Y_UNIT_TEST(FastLRTest) { LinearRegressionTest<TFastLinearRegressionSolver>(); } - Y_UNIT_TEST(LRTest) { + Y_UNIT_TEST(LRTest) { LinearRegressionTest<TLinearRegressionSolver>(); } @@ -275,31 +275,31 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { UNIT_ASSERT_DOUBLES_EQUAL(rmse, 0., 1e-3); } - Y_UNIT_TEST(SigmaTest100) { + Y_UNIT_TEST(SigmaTest100) { TransformationTest(ETransformationType::TT_SIGMA, 100); } - Y_UNIT_TEST(SigmaTest1000) { + Y_UNIT_TEST(SigmaTest1000) { TransformationTest(ETransformationType::TT_SIGMA, 1000); } - Y_UNIT_TEST(SigmaTest10000) { + Y_UNIT_TEST(SigmaTest10000) { TransformationTest(ETransformationType::TT_SIGMA, 10000); } - Y_UNIT_TEST(SigmaTest100000) { + Y_UNIT_TEST(SigmaTest100000) { TransformationTest(ETransformationType::TT_SIGMA, 100000); } - Y_UNIT_TEST(SigmaTest1000000) { + Y_UNIT_TEST(SigmaTest1000000) { TransformationTest(ETransformationType::TT_SIGMA, 1000000); } - Y_UNIT_TEST(SigmaTest10000000) { + Y_UNIT_TEST(SigmaTest10000000) { TransformationTest(ETransformationType::TT_SIGMA, 10000000); } - Y_UNIT_TEST(ResetCalculatorTest) { + Y_UNIT_TEST(ResetCalculatorTest) { TVector<double> arguments; TVector<double> weights; const double eps = 1e-10; diff --git a/library/cpp/linear_regression/welford.h b/library/cpp/linear_regression/welford.h index a39800974c..ee865d6693 100644 --- a/library/cpp/linear_regression/welford.h +++ b/library/cpp/linear_regression/welford.h @@ -11,7 +11,7 @@ private: TKahanAccumulator<double> SumWeights; public: - Y_SAVELOAD_DEFINE(Mean, SumWeights); + Y_SAVELOAD_DEFINE(Mean, SumWeights); void Multiply(const double value); void Add(const double value, const double weight = 1.); @@ -40,7 +40,7 @@ private: TKahanAccumulator<double> SumWeights; public: - Y_SAVELOAD_DEFINE(Covariation, FirstValueMean, SecondValueMean, SumWeights); + Y_SAVELOAD_DEFINE(Covariation, FirstValueMean, SecondValueMean, SumWeights); void Add(const double firstValue, const double secondValue, const double weight = 1.); void Remove(const double firstValue, const double secondValue, const double weight = 1.); @@ -62,7 +62,7 @@ private: TMeanCalculator MeanCalculator; public: - Y_SAVELOAD_DEFINE(Deviation, MeanCalculator); + Y_SAVELOAD_DEFINE(Deviation, MeanCalculator); void Add(const double value, const double weight = 1.); void Remove(const double value, const double weight = 1.); diff --git a/library/cpp/logger/backend.cpp b/library/cpp/logger/backend.cpp index 069c9768ef..b26bf5e88c 100644 --- a/library/cpp/logger/backend.cpp +++ b/library/cpp/logger/backend.cpp @@ -24,7 +24,7 @@ namespace { return; } } - Y_FAIL("Incorrect pointer for log backend"); + Y_FAIL("Incorrect pointer for log backend"); } void Reopen(bool flush) { diff --git a/library/cpp/logger/backend.h b/library/cpp/logger/backend.h index 36023d048d..d088726d6d 100644 --- a/library/cpp/logger/backend.h +++ b/library/cpp/logger/backend.h @@ -1,14 +1,14 @@ #pragma once -#include "priority.h" - +#include "priority.h" + #include <util/generic/noncopyable.h> - + #include <cstddef> struct TLogRecord; -// NOTE: be aware that all `TLogBackend`s are registred in singleton. +// NOTE: be aware that all `TLogBackend`s are registred in singleton. class TLogBackend: public TNonCopyable { public: TLogBackend() noexcept; diff --git a/library/cpp/logger/element.h b/library/cpp/logger/element.h index 0066270efc..fc9bff851f 100644 --- a/library/cpp/logger/element.h +++ b/library/cpp/logger/element.h @@ -21,7 +21,7 @@ public: template <class T> inline TLogElement& operator<<(const T& t) { - static_cast<IOutputStream&>(*this) << t; + static_cast<IOutputStream&>(*this) << t; return *this; } diff --git a/library/cpp/logger/global/common.h b/library/cpp/logger/global/common.h index 6f06d6ae4c..7dcf650dec 100644 --- a/library/cpp/logger/global/common.h +++ b/library/cpp/logger/global/common.h @@ -135,7 +135,7 @@ TSimpleSharedPtr<TLogElement> GetLoggerForce(TLog& log, const TLogRecordContext& namespace NPrivateGlobalLogger { struct TEatStream { - Y_FORCE_INLINE bool operator|(const IOutputStream&) const { + Y_FORCE_INLINE bool operator|(const IOutputStream&) const { return true; } }; diff --git a/library/cpp/logger/global/global.h b/library/cpp/logger/global/global.h index 6940d06fb7..cbe71b16ea 100644 --- a/library/cpp/logger/global/global.h +++ b/library/cpp/logger/global/global.h @@ -10,7 +10,7 @@ void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rota void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter = {}); inline void InitGlobalLog2Null() { - DoInitGlobalLog("null", TLOG_EMERG, false, false); + DoInitGlobalLog("null", TLOG_EMERG, false, false); } inline void InitGlobalLog2Console(int loglevel = TLOG_INFO) { @@ -91,7 +91,7 @@ namespace NPrivateGlobalLogger { ~TVerifyEvent(); template <class T> inline TVerifyEvent& operator<<(const T& t) { - static_cast<IOutputStream&>(*this) << t; + static_cast<IOutputStream&>(*this) << t; return *this; } diff --git a/library/cpp/logger/global/rty_formater.h b/library/cpp/logger/global/rty_formater.h index 3872b22458..6532e1d769 100644 --- a/library/cpp/logger/global/rty_formater.h +++ b/library/cpp/logger/global/rty_formater.h @@ -34,7 +34,7 @@ namespace NLoggingImpl { TInstant Instant; }; - IOutputStream& operator<<(IOutputStream& out, TLocalTimeS localTimeS); + IOutputStream& operator<<(IOutputStream& out, TLocalTimeS localTimeS); inline TLocalTimeS GetLocalTimeS() { return TLocalTimeS(); diff --git a/library/cpp/logger/global/rty_formater_ut.cpp b/library/cpp/logger/global/rty_formater_ut.cpp index 59376b5c3c..551a97c5bf 100644 --- a/library/cpp/logger/global/rty_formater_ut.cpp +++ b/library/cpp/logger/global/rty_formater_ut.cpp @@ -7,23 +7,23 @@ namespace { const TStringBuf SampleRtyLog("2017-07-25 19:26:09.894 +0300"); } -Y_UNIT_TEST_SUITE(NLoggingImplTest) { - Y_UNIT_TEST(TestTLocalTimeSToStream) { +Y_UNIT_TEST_SUITE(NLoggingImplTest) { + Y_UNIT_TEST(TestTLocalTimeSToStream) { NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601)); TStringStream ss; ss << lt; UNIT_ASSERT_EQUAL(ss.Str(), SampleRtyLog); } - Y_UNIT_TEST(TestTLocalTimeSToString) { + Y_UNIT_TEST(TestTLocalTimeSToString) { NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601)); UNIT_ASSERT_EQUAL(TString(lt), SampleRtyLog); } - Y_UNIT_TEST(TestTLocalTimeSAddLeft) { + Y_UNIT_TEST(TestTLocalTimeSAddLeft) { NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601)); TStringBuf suffix("suffix"); UNIT_ASSERT_EQUAL(lt + suffix, TString(SampleRtyLog) + suffix); } - Y_UNIT_TEST(TestTLocalTimeSAddRight) { + Y_UNIT_TEST(TestTLocalTimeSAddRight) { NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601)); TString prefix("prefix"); UNIT_ASSERT_EQUAL(prefix + lt, prefix + SampleRtyLog); diff --git a/library/cpp/logger/log.cpp b/library/cpp/logger/log.cpp index c4419e75e9..e1d70cc3d2 100644 --- a/library/cpp/logger/log.cpp +++ b/library/cpp/logger/log.cpp @@ -27,7 +27,7 @@ THolder<TOwningThreadedLogBackend> CreateOwningThreadedLogBackend(const TString& } class TLog::TImpl: public TAtomicRefCount<TImpl> { - class TPriorityLogStream final: public IOutputStream { + class TPriorityLogStream final: public IOutputStream { public: inline TPriorityLogStream(ELogPriority p, const TImpl* parent) : Priority_(p) @@ -40,13 +40,13 @@ class TLog::TImpl: public TAtomicRefCount<TImpl> { } private: - ELogPriority Priority_ = LOG_DEF_PRIORITY; - const TImpl* Parent_ = nullptr; + ELogPriority Priority_ = LOG_DEF_PRIORITY; + const TImpl* Parent_ = nullptr; }; public: inline TImpl(THolder<TLogBackend> backend) - : Backend_(std::move(backend)) + : Backend_(std::move(backend)) { } @@ -55,7 +55,7 @@ public: return; } - Backend_->ReopenLog(); + Backend_->ReopenLog(); } inline void ReopenLogNoFlush() { @@ -63,7 +63,7 @@ public: return; } - Backend_->ReopenLogNoFlush(); + Backend_->ReopenLogNoFlush(); } inline void AddLog(ELogPriority priority, const char* format, va_list args) const { @@ -77,30 +77,30 @@ public: } inline void ResetBackend(THolder<TLogBackend> backend) noexcept { - Backend_ = std::move(backend); + Backend_ = std::move(backend); } inline THolder<TLogBackend> ReleaseBackend() noexcept { - return std::move(Backend_); + return std::move(Backend_); } inline bool IsNullLog() const noexcept { - return !IsOpen() || (dynamic_cast<TNullLogBackend*>(Backend_.Get()) != nullptr); + return !IsOpen() || (dynamic_cast<TNullLogBackend*>(Backend_.Get()) != nullptr); } inline bool IsOpen() const noexcept { - return nullptr != Backend_.Get(); + return nullptr != Backend_.Get(); } inline void CloseLog() noexcept { - Backend_.Destroy(); + Backend_.Destroy(); Y_ASSERT(!IsOpen()); } inline void WriteData(ELogPriority priority, const char* data, size_t len) const { if (IsOpen()) { - Backend_->WriteData(TLogRecord(priority, data, len)); + Backend_->WriteData(TLogRecord(priority, data, len)); } } @@ -113,38 +113,38 @@ public: } inline ELogPriority FiltrationLevel() const noexcept { - return Backend_->FiltrationLevel(); + return Backend_->FiltrationLevel(); } inline size_t BackEndQueueSize() const { - return Backend_->QueueSize(); + return Backend_->QueueSize(); } private: - THolder<TLogBackend> Backend_; - ELogPriority DefaultPriority_ = LOG_DEF_PRIORITY; + THolder<TLogBackend> Backend_; + ELogPriority DefaultPriority_ = LOG_DEF_PRIORITY; }; TLog::TLog() - : Impl_(MakeIntrusive<TImpl>(nullptr)) + : Impl_(MakeIntrusive<TImpl>(nullptr)) { } -TLog::TLog(const TString& fname, ELogPriority priority) +TLog::TLog(const TString& fname, ELogPriority priority) : TLog(CreateLogBackend(fname, priority, false)) -{ +{ } TLog::TLog(THolder<TLogBackend> backend) - : Impl_(MakeIntrusive<TImpl>(std::move(backend))) + : Impl_(MakeIntrusive<TImpl>(std::move(backend))) { } -TLog::TLog(const TLog&) = default; -TLog::TLog(TLog&&) = default; -TLog::~TLog() = default; -TLog& TLog::operator=(const TLog&) = default; -TLog& TLog::operator=(TLog&&) = default; +TLog::TLog(const TLog&) = default; +TLog::TLog(TLog&&) = default; +TLog::~TLog() = default; +TLog& TLog::operator=(const TLog&) = default; +TLog& TLog::operator=(TLog&&) = default; bool TLog::IsOpen() const noexcept { return Impl_->IsOpen(); @@ -177,13 +177,13 @@ void TLog::AddLogVAList(const char* format, va_list lst) { } void TLog::ReopenLog() { - if (const auto copy = Impl_) { + if (const auto copy = Impl_) { copy->ReopenLog(); } } void TLog::ReopenLogNoFlush() { - if (const auto copy = Impl_) { + if (const auto copy = Impl_) { copy->ReopenLogNoFlush(); } } @@ -227,9 +227,9 @@ THolder<TLogBackend> TLog::ReleaseBackend() noexcept { } void TLog::Write(ELogPriority priority, const char* data, size_t len) const { - if (Formatter_) { - const auto formated = Formatter_(priority, TStringBuf{data, len}); - Impl_->WriteData(priority, formated.data(), formated.size()); + if (Formatter_) { + const auto formated = Formatter_(priority, TStringBuf{data, len}); + Impl_->WriteData(priority, formated.data(), formated.size()); } else { Impl_->WriteData(priority, data, len); } @@ -244,7 +244,7 @@ void TLog::Write(const char* data, size_t len) const { } void TLog::SetFormatter(TLogFormatter formatter) noexcept { - Formatter_ = std::move(formatter); + Formatter_ = std::move(formatter); } size_t TLog::BackEndQueueSize() const { diff --git a/library/cpp/logger/log.h b/library/cpp/logger/log.h index e0d9e8998f..8be984ccc8 100644 --- a/library/cpp/logger/log.h +++ b/library/cpp/logger/log.h @@ -14,81 +14,81 @@ using TLogFormatter = std::function<TString(ELogPriority priority, TStringBuf)>; -// Logging facilities interface. -// -// ```cpp -// TLog base; -// ... -// auto log = base; -// log.SetFormatter([reqId](ELogPriority p, TStringBuf msg) { -// return TStringBuilder() << "reqid=" << reqId << "; " << msg; -// }); -// -// log.Write(TLOG_INFO, "begin"); -// HandleRequest(...); -// log.Write(TLOG_INFO, "end"); -// ``` -// -// Users are encouraged to copy `TLog` instance. +// Logging facilities interface. +// +// ```cpp +// TLog base; +// ... +// auto log = base; +// log.SetFormatter([reqId](ELogPriority p, TStringBuf msg) { +// return TStringBuilder() << "reqid=" << reqId << "; " << msg; +// }); +// +// log.Write(TLOG_INFO, "begin"); +// HandleRequest(...); +// log.Write(TLOG_INFO, "end"); +// ``` +// +// Users are encouraged to copy `TLog` instance. class TLog { public: - // Construct empty logger all writes will be spilled. + // Construct empty logger all writes will be spilled. TLog(); - // Construct file logger. + // Construct file logger. TLog(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY); - // Construct any type of logger + // Construct any type of logger TLog(THolder<TLogBackend> backend); - TLog(const TLog&); - TLog(TLog&&); + TLog(const TLog&); + TLog(TLog&&); ~TLog(); - TLog& operator=(const TLog&); - TLog& operator=(TLog&&); + TLog& operator=(const TLog&); + TLog& operator=(TLog&&); - // Change underlying backend. - // NOTE: not thread safe. + // Change underlying backend. + // NOTE: not thread safe. void ResetBackend(THolder<TLogBackend> backend) noexcept; - // Reset underlying backend, `IsNullLog()` will return `true` after this call. - // NOTE: not thread safe. + // Reset underlying backend, `IsNullLog()` will return `true` after this call. + // NOTE: not thread safe. THolder<TLogBackend> ReleaseBackend() noexcept; - // Check if underlying backend is defined and is not null. - // NOTE: not thread safe with respect to `ResetBackend` and `ReleaseBackend`. + // Check if underlying backend is defined and is not null. + // NOTE: not thread safe with respect to `ResetBackend` and `ReleaseBackend`. bool IsNullLog() const noexcept; - // Write message to the log. - // - // @param[in] priority Message priority to use. - // @param[in] message Message to write. - void Write(ELogPriority priority, TStringBuf message) const; - // Write message to the log using `DefaultPriority()`. + // Write message to the log. + // + // @param[in] priority Message priority to use. + // @param[in] message Message to write. + void Write(ELogPriority priority, TStringBuf message) const; + // Write message to the log using `DefaultPriority()`. void Write(const char* data, size_t len) const; - // Write message to the log, but pass the message in a c-style. + // Write message to the log, but pass the message in a c-style. void Write(ELogPriority priority, const char* data, size_t len) const; - - // Write message to the log in a c-like printf style. - void Y_PRINTF_FORMAT(3, 4) AddLog(ELogPriority priority, const char* format, ...) const; - // Write message to the log in a c-like printf style with `DefaultPriority()` priority. + + // Write message to the log in a c-like printf style. + void Y_PRINTF_FORMAT(3, 4) AddLog(ELogPriority priority, const char* format, ...) const; + // Write message to the log in a c-like printf style with `DefaultPriority()` priority. void Y_PRINTF_FORMAT(2, 3) AddLog(const char* format, ...) const; - - // Call `ReopenLog()` of the underlying backend. + + // Call `ReopenLog()` of the underlying backend. void ReopenLog(); - // Call `ReopenLogNoFlush()` of the underlying backend. + // Call `ReopenLogNoFlush()` of the underlying backend. void ReopenLogNoFlush(); - // Call `QueueSize()` of the underlying backend. + // Call `QueueSize()` of the underlying backend. size_t BackEndQueueSize() const; - // Set log default priority. - // NOTE: not thread safe. + // Set log default priority. + // NOTE: not thread safe. void SetDefaultPriority(ELogPriority priority) noexcept; - // Get default priority + // Get default priority ELogPriority DefaultPriority() const noexcept; - // Call `FiltrationLevel()` of the underlying backend. + // Call `FiltrationLevel()` of the underlying backend. ELogPriority FiltrationLevel() const noexcept; - // Set current log formatter. - void SetFormatter(TLogFormatter formatter) noexcept; - + // Set current log formatter. + void SetFormatter(TLogFormatter formatter) noexcept; + template <class T> inline TLogElement operator<<(const T& t) const { TLogElement ret(this); @@ -96,18 +96,18 @@ public: return ret; } -public: - // These methods are deprecated and present here only for compatibility reasons (for 13 years - // already ...). Do not use them. - bool OpenLog(const char* path, ELogPriority lp = LOG_MAX_PRIORITY); - bool IsOpen() const noexcept; - void AddLogVAList(const char* format, va_list lst); - void CloseLog(); - +public: + // These methods are deprecated and present here only for compatibility reasons (for 13 years + // already ...). Do not use them. + bool OpenLog(const char* path, ELogPriority lp = LOG_MAX_PRIORITY); + bool IsOpen() const noexcept; + void AddLogVAList(const char* format, va_list lst); + void CloseLog(); + private: class TImpl; - TIntrusivePtr<TImpl> Impl_; - TLogFormatter Formatter_; + TIntrusivePtr<TImpl> Impl_; + TLogFormatter Formatter_; }; THolder<TLogBackend> CreateLogBackend(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY, bool threaded = false); diff --git a/library/cpp/logger/stream.cpp b/library/cpp/logger/stream.cpp index a4c7c2e5b5..96787ad94b 100644 --- a/library/cpp/logger/stream.cpp +++ b/library/cpp/logger/stream.cpp @@ -3,7 +3,7 @@ #include <util/stream/output.h> -TStreamLogBackend::TStreamLogBackend(IOutputStream* slave) +TStreamLogBackend::TStreamLogBackend(IOutputStream* slave) : Slave_(slave) { } diff --git a/library/cpp/logger/stream.h b/library/cpp/logger/stream.h index 69a7d3dd12..feb240afcb 100644 --- a/library/cpp/logger/stream.h +++ b/library/cpp/logger/stream.h @@ -2,16 +2,16 @@ #include "backend.h" -class IOutputStream; +class IOutputStream; class TStreamLogBackend: public TLogBackend { public: - TStreamLogBackend(IOutputStream* slave); + TStreamLogBackend(IOutputStream* slave); ~TStreamLogBackend() override; void WriteData(const TLogRecord& rec) override; void ReopenLog() override; private: - IOutputStream* Slave_; + IOutputStream* Slave_; }; diff --git a/library/cpp/logger/system.cpp b/library/cpp/logger/system.cpp index 1b228e3d24..42233f63d2 100644 --- a/library/cpp/logger/system.cpp +++ b/library/cpp/logger/system.cpp @@ -1,5 +1,5 @@ -#include <util/stream/output.h> -#include <util/stream/null.h> +#include <util/stream/output.h> +#include <util/stream/null.h> #include <util/system/compat.h> #include <util/system/yassert.h> #include <util/system/defaults.h> @@ -20,7 +20,7 @@ TSysLogBackend::TSysLogBackend(const char* ident, EFacility facility, int flags) , Flags(flags) { #if defined(_unix_) - Y_ASSERT(TSYSLOG_LOCAL0 <= facility && facility <= TSYSLOG_LOCAL7); + Y_ASSERT(TSYSLOG_LOCAL0 <= facility && facility <= TSYSLOG_LOCAL7); static const int f2sf[] = { LOG_LOCAL0, @@ -56,7 +56,7 @@ void TSysLogBackend::WriteData(const TLogRecord& rec) { #if defined(_unix_) syslog(ELogPriority2SyslogPriority(rec.Priority), "%.*s", (int)rec.Len, rec.Data); #else - Y_UNUSED(rec); + Y_UNUSED(rec); #endif } diff --git a/library/cpp/logger/ya.make b/library/cpp/logger/ya.make index 1cef3f6623..00a5263cba 100644 --- a/library/cpp/logger/ya.make +++ b/library/cpp/logger/ya.make @@ -5,8 +5,8 @@ OWNER( g:base ) -LIBRARY() - +LIBRARY() + GENERATE_ENUM_SERIALIZATION(priority.h) PEERDIR ( @@ -43,5 +43,5 @@ SRCS( ) END() - -RECURSE_FOR_TESTS(ut) + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/lwtrace/kill_action.cpp b/library/cpp/lwtrace/kill_action.cpp index 60d7362d9a..2b74dc4587 100644 --- a/library/cpp/lwtrace/kill_action.cpp +++ b/library/cpp/lwtrace/kill_action.cpp @@ -15,7 +15,7 @@ bool TKillActionExecutor::DoExecute(TOrbit&, const TParams&) { abort(); #else int r = kill(getpid(), SIGABRT); - Y_VERIFY(r == 0, "kill failed"); + Y_VERIFY(r == 0, "kill failed"); return true; #endif } diff --git a/library/cpp/lwtrace/mon/mon_lwtrace.cpp b/library/cpp/lwtrace/mon/mon_lwtrace.cpp index 9a0b02d03f..a61ee9ce22 100644 --- a/library/cpp/lwtrace/mon/mon_lwtrace.cpp +++ b/library/cpp/lwtrace/mon/mon_lwtrace.cpp @@ -846,7 +846,7 @@ public: TraceEvents.emplace(ts, Event(shortId, ts, ph, cat, argsItem, name, id)); } - void Output(IOutputStream& os) + void Output(IOutputStream& os) { os << "{\"traceEvents\":["; bool first = true; @@ -1124,18 +1124,18 @@ template <> TString UrlErase<true>(const TCgiParameters& e, const TString& key, return MakeUrlEraseSub(e, key, value); } -void OutputCommonHeader(IOutputStream& out) +void OutputCommonHeader(IOutputStream& out) { out << NResource::Find("lwtrace/mon/static/header.html") << Endl; } -void OutputCommonFooter(IOutputStream& out) +void OutputCommonFooter(IOutputStream& out) { out << NResource::Find("lwtrace/mon/static/footer.html") << Endl; } struct TScopedHtmlInner { - explicit TScopedHtmlInner(IOutputStream& str) + explicit TScopedHtmlInner(IOutputStream& str) : Str(str) { Str << "<!DOCTYPE html>\n" @@ -1154,7 +1154,7 @@ struct TScopedHtmlInner { inline operator bool () const noexcept { return true; } - IOutputStream &Str; + IOutputStream &Str; }; TString NavbarHeader() @@ -1165,7 +1165,7 @@ TString NavbarHeader() } struct TSelectorsContainer { - TSelectorsContainer(IOutputStream& str) + TSelectorsContainer(IOutputStream& str) : Str(str) { Str << "<nav id=\"selectors-container\" class=\"navbar navbar-default\">" @@ -1192,11 +1192,11 @@ struct TSelectorsContainer { } catch(...) {} } - IOutputStream& Str; + IOutputStream& Str; }; struct TNullContainer { - TNullContainer(IOutputStream&) {} + TNullContainer(IOutputStream&) {} }; class TPageGenBase: public std::exception {}; @@ -1275,7 +1275,7 @@ TString BtnClass() { return "btn"; } -void SelectorTitle(IOutputStream& os, const TString& text) +void SelectorTitle(IOutputStream& os, const TString& text) { if (!text.empty()) { os << text; @@ -1283,7 +1283,7 @@ void SelectorTitle(IOutputStream& os, const TString& text) } template <ui64 flags> -void BtnHref(IOutputStream& os, const TString& text, const TString& href, bool push = false) +void BtnHref(IOutputStream& os, const TString& text, const TString& href, bool push = false) { if (flags & Button) { os << "<button type=\"button\" style=\"display: inline-block;margin:3px\" class=\"" @@ -1299,17 +1299,17 @@ void BtnHref(IOutputStream& os, const TString& text, const TString& href, bool p } } -void DropdownBeginSublist(IOutputStream& os, const TString& text) +void DropdownBeginSublist(IOutputStream& os, const TString& text) { os << "<li>" << text << "<ul class=\"dropdown-menu\">"; } -void DropdownEndSublist(IOutputStream& os) +void DropdownEndSublist(IOutputStream& os) { os << "</ul></li>"; } -void DropdownItem(IOutputStream& os, const TString& text, const TString& href, bool separated = false) +void DropdownItem(IOutputStream& os, const TString& text, const TString& href, bool separated = false) { if (separated) { os << "<li role=\"separator\" class=\"divider\"></li>"; @@ -1341,7 +1341,7 @@ TString GetDescription(const TString& value, const TVariants& variants) } template <ui64 flags, bool sub = false> -void DropdownSelector(IOutputStream& os, const TCgiParameters& e, const TString& param, const TString& value, +void DropdownSelector(IOutputStream& os, const TCgiParameters& e, const TString& param, const TString& value, const TString& text, const TVariants& variants, const TString& realValue = TString()) { HTML(os) { @@ -1567,7 +1567,7 @@ public: row.emplace_back(ToString(probe->GetExecutorsCount())); } - void Output(IOutputStream& os) + void Output(IOutputStream& os) { HTML(os) { TABLE() { @@ -1837,10 +1837,10 @@ public: class TTracesHtmlPrinter { private: - IOutputStream& Os; + IOutputStream& Os; TInstant Now; public: - explicit TTracesHtmlPrinter(IOutputStream& os) + explicit TTracesHtmlPrinter(IOutputStream& os) : Os(os) , Now(TInstant::Now()) {} @@ -2182,11 +2182,11 @@ static TString EscapeJSONString(const TString& s) class TLogJsonPrinter { private: - IOutputStream& Os; + IOutputStream& Os; bool FirstThread; bool FirstItem; public: - explicit TLogJsonPrinter(IOutputStream& os) + explicit TLogJsonPrinter(IOutputStream& os) : Os(os) , FirstThread(true) , FirstItem(true) @@ -2283,7 +2283,7 @@ public: Json }; - void Output(IOutputStream& os) const + void Output(IOutputStream& os) const { OutputItems<Text>(os); OutputDepot<Text>(os); @@ -2365,7 +2365,7 @@ private: } template <EFormat Format> - void OutputItems(IOutputStream& os) const + void OutputItems(IOutputStream& os) const { ui64 idx = 0; ui64 size = Items.size(); @@ -2390,7 +2390,7 @@ private: } template <EFormat Format> - void OutputDepot(IOutputStream& os) const + void OutputDepot(IOutputStream& os) const { ui64 idx = 0; ui64 size = Depot.size(); @@ -3283,7 +3283,7 @@ public: } // Tabular representation of tracks data - void OutputTable(IOutputStream& os, const TCgiParameters& e) + void OutputTable(IOutputStream& os, const TCgiParameters& e) { ui64 tracksTotal = Tree.GetRoot()->TrackCount; @@ -3390,7 +3390,7 @@ public: } // Chromium-compatible trace representation of tracks data - void OutputChromeTrace(IOutputStream& os, const TCgiParameters& e) + void OutputChromeTrace(IOutputStream& os, const TCgiParameters& e) { Y_UNUSED(e); TChromeTrace tr; @@ -3428,7 +3428,7 @@ public: tr.Output(os); } - void OutputSliceCovarianceMatrix(IOutputStream& os, const TCgiParameters& e) + void OutputSliceCovarianceMatrix(IOutputStream& os, const TCgiParameters& e) { Y_UNUSED(e); TPatternNode* node = Tree.GetSelectedNode(); @@ -3495,7 +3495,7 @@ private: return nullptr; } - void OutputPattern(IOutputStream& os, const TCgiParameters& e, TPatternNode* node) + void OutputPattern(IOutputStream& os, const TCgiParameters& e, TPatternNode* node) { // Fill pattern name TString patternName; @@ -3566,7 +3566,7 @@ private: } } - void OutputShare(IOutputStream& os, double share) + void OutputShare(IOutputStream& os, double share) { double lshare = share; double rshare = 100 - lshare; @@ -3610,7 +3610,7 @@ private: return ret; } - void OutputTimeline(IOutputStream& os, const TTimeline& timeline, double maxTime) + void OutputTimeline(IOutputStream& os, const TTimeline& timeline, double maxTime) { static const char *barClass[] = { "progress-bar-info", diff --git a/library/cpp/lwtrace/tests/trace_tests.cpp b/library/cpp/lwtrace/tests/trace_tests.cpp index 8db02cd23f..6762e344a7 100644 --- a/library/cpp/lwtrace/tests/trace_tests.cpp +++ b/library/cpp/lwtrace/tests/trace_tests.cpp @@ -698,7 +698,7 @@ namespace NLWTrace { } template <> -void Out<NLWTrace::NTests::TMeasure>(IOutputStream& os, TTypeTraits<NLWTrace::NTests::TMeasure>::TFuncParam measure) { +void Out<NLWTrace::NTests::TMeasure>(IOutputStream& os, TTypeTraits<NLWTrace::NTests::TMeasure>::TFuncParam measure) { os << Sprintf("\n\t\t%.6lf +- %.6lf us,\tRPS: %30.3lf (%.1fM)", measure.Average, measure.Sigma, 1000000.0 / measure.Average, 1.0 / measure.Average); } diff --git a/library/cpp/lwtrace/trace_ut.cpp b/library/cpp/lwtrace/trace_ut.cpp index 818c6d6535..cb03e4fbde 100644 --- a/library/cpp/lwtrace/trace_ut.cpp +++ b/library/cpp/lwtrace/trace_ut.cpp @@ -35,9 +35,9 @@ LWTRACE_USING(LWTRACE_UT_PROVIDER) using namespace NLWTrace; -Y_UNIT_TEST_SUITE(LWTraceTrace) { +Y_UNIT_TEST_SUITE(LWTraceTrace) { #ifndef LWTRACE_DISABLE - Y_UNIT_TEST(Smoke) { + Y_UNIT_TEST(Smoke) { TManager mngr(*Singleton<TProbeRegistry>(), true); TQuery q; bool parsed = NProtoBuf::TextFormat::ParseFromString(R"END( @@ -549,7 +549,7 @@ Y_UNIT_TEST_SUITE(LWTraceTrace) { UNIT_ASSERT_STRINGS_EQUAL(str, "OT_EQ (0)"); } - Y_UNIT_TEST(Track) { + Y_UNIT_TEST(Track) { TManager mngr(*Singleton<TProbeRegistry>(), true); TQuery q; bool parsed = NProtoBuf::TextFormat::ParseFromString(R"END( diff --git a/library/cpp/malloc/api/helpers/io.cpp b/library/cpp/malloc/api/helpers/io.cpp index 8d87e90d0a..5177969f4d 100644 --- a/library/cpp/malloc/api/helpers/io.cpp +++ b/library/cpp/malloc/api/helpers/io.cpp @@ -1,10 +1,10 @@ #include <library/cpp/malloc/api/malloc.h> -#include <util/stream/output.h> +#include <util/stream/output.h> using namespace NMalloc; template <> -void Out<TMallocInfo>(IOutputStream& out, const TMallocInfo& info) { +void Out<TMallocInfo>(IOutputStream& out, const TMallocInfo& info) { out << "malloc (name = " << info.Name << ")"; } diff --git a/library/cpp/malloc/api/ut/ut.cpp b/library/cpp/malloc/api/ut/ut.cpp index 40f63245e9..7eccd0bf8d 100644 --- a/library/cpp/malloc/api/ut/ut.cpp +++ b/library/cpp/malloc/api/ut/ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/malloc/api/malloc.h> -Y_UNIT_TEST_SUITE(MallocApi) { - Y_UNIT_TEST(ToStream) { +Y_UNIT_TEST_SUITE(MallocApi) { + Y_UNIT_TEST(ToStream) { TStringStream ss; ss << NMalloc::MallocInfo(); } diff --git a/library/cpp/messagebus/acceptor.cpp b/library/cpp/messagebus/acceptor.cpp index 65db22c217..64a38619c2 100644 --- a/library/cpp/messagebus/acceptor.cpp +++ b/library/cpp/messagebus/acceptor.cpp @@ -113,8 +113,8 @@ void TAcceptor::SendStatus(TInstant now) { } void TAcceptor::HandleEvent(SOCKET socket, void* cookie) { - Y_UNUSED(socket); - Y_UNUSED(cookie); + Y_UNUSED(socket); + Y_UNUSED(cookie); GetActor()->Schedule(); } diff --git a/library/cpp/messagebus/acceptor_status.cpp b/library/cpp/messagebus/acceptor_status.cpp index ff0e9d978b..5006ff68ae 100644 --- a/library/cpp/messagebus/acceptor_status.cpp +++ b/library/cpp/messagebus/acceptor_status.cpp @@ -25,8 +25,8 @@ void TAcceptorStatus::ResetIncremental() { } TAcceptorStatus& TAcceptorStatus::operator+=(const TAcceptorStatus& that) { - Y_ASSERT(Summary); - Y_ASSERT(AcceptorId == 0); + Y_ASSERT(Summary); + Y_ASSERT(AcceptorId == 0); AcceptSuccessCount += that.AcceptSuccessCount; LastAcceptSuccessInstant = Max(LastAcceptSuccessInstant, that.LastAcceptSuccessInstant); diff --git a/library/cpp/messagebus/actor/actor_ut.cpp b/library/cpp/messagebus/actor/actor_ut.cpp index 6d46c03a05..b76ab55bfa 100644 --- a/library/cpp/messagebus/actor/actor_ut.cpp +++ b/library/cpp/messagebus/actor/actor_ut.cpp @@ -92,8 +92,8 @@ struct TObjectCountChecker { } }; -Y_UNIT_TEST_SUITE(TActor) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TActor) { + Y_UNIT_TEST(Simple) { TObjectCountChecker objectCountChecker; TExecutor executor(4); @@ -105,7 +105,7 @@ Y_UNIT_TEST_SUITE(TActor) { actor->Acted.WaitFor(1u); } - Y_UNIT_TEST(ScheduleAfterStart) { + Y_UNIT_TEST(ScheduleAfterStart) { TObjectCountChecker objectCountChecker; TExecutor executor(4); @@ -147,11 +147,11 @@ Y_UNIT_TEST_SUITE(TActor) { } } - Y_UNIT_TEST(ComplexContention) { + Y_UNIT_TEST(ComplexContention) { ComplexImpl(4, 6); } - Y_UNIT_TEST(ComplexNoContention) { + Y_UNIT_TEST(ComplexNoContention) { ComplexImpl(6, 4); } } diff --git a/library/cpp/messagebus/actor/executor.cpp b/library/cpp/messagebus/actor/executor.cpp index 925e8e5388..7a2227a458 100644 --- a/library/cpp/messagebus/actor/executor.cpp +++ b/library/cpp/messagebus/actor/executor.cpp @@ -178,7 +178,7 @@ void TExecutor::Init() { AtomicSet(ExitWorkers, 0); - Y_VERIFY(Config.WorkerCount > 0); + Y_VERIFY(Config.WorkerCount > 0); for (size_t i = 0; i < Config.WorkerCount; i++) { WorkerThreads.push_back(new TExecutorWorker(this)); @@ -215,7 +215,7 @@ void TExecutor::EnqueueWork(TArrayRef<IWorkItem* const> wis) { return; if (Y_UNLIKELY(AtomicGet(ExitWorkers) != 0)) { - Y_VERIFY(WorkItems.Empty(), "executor %s: cannot add tasks after queue shutdown", Config.Name); + Y_VERIFY(WorkItems.Empty(), "executor %s: cannot add tasks after queue shutdown", Config.Name); } TWhatThreadDoesPushPop pp("executor: EnqueueWork"); @@ -319,7 +319,7 @@ void TExecutor::ProcessWorkQueueHere() { } void TExecutor::RunWorker() { - Y_VERIFY(!ThreadCurrentExecutor, "state check"); + Y_VERIFY(!ThreadCurrentExecutor, "state check"); ThreadCurrentExecutor = this; SetCurrentThreadName("wrkr"); diff --git a/library/cpp/messagebus/actor/ring_buffer.h b/library/cpp/messagebus/actor/ring_buffer.h index 0cf401bfda..ec5706f7c7 100644 --- a/library/cpp/messagebus/actor/ring_buffer.h +++ b/library/cpp/messagebus/actor/ring_buffer.h @@ -17,12 +17,12 @@ private: TVector<T> Data; void StateCheck() const { - Y_ASSERT(Capacity == Data.size()); - Y_ASSERT(Capacity == (1u << CapacityPow)); - Y_ASSERT((Capacity & CapacityMask) == 0u); - Y_ASSERT(Capacity - CapacityMask == 1u); - Y_ASSERT(WritePos < Capacity); - Y_ASSERT(ReadPos < Capacity); + Y_ASSERT(Capacity == Data.size()); + Y_ASSERT(Capacity == (1u << CapacityPow)); + Y_ASSERT((Capacity & CapacityMask) == 0u); + Y_ASSERT(Capacity - CapacityMask == 1u); + Y_ASSERT(WritePos < Capacity); + Y_ASSERT(ReadPos < Capacity); } size_t Writable() const { diff --git a/library/cpp/messagebus/actor/ring_buffer_ut.cpp b/library/cpp/messagebus/actor/ring_buffer_ut.cpp index 2accea357c..bdb379b3a9 100644 --- a/library/cpp/messagebus/actor/ring_buffer_ut.cpp +++ b/library/cpp/messagebus/actor/ring_buffer_ut.cpp @@ -4,7 +4,7 @@ #include <util/random/random.h> -Y_UNIT_TEST_SUITE(RingBuffer) { +Y_UNIT_TEST_SUITE(RingBuffer) { struct TRingBufferTester { TRingBuffer<unsigned> RingBuffer; @@ -52,7 +52,7 @@ Y_UNIT_TEST_SUITE(RingBuffer) { } } - Y_UNIT_TEST(Random) { + Y_UNIT_TEST(Random) { for (unsigned i = 0; i < 100; ++i) { Iter(); } diff --git a/library/cpp/messagebus/actor/tasks_ut.cpp b/library/cpp/messagebus/actor/tasks_ut.cpp index 270392330f..d80e8451a5 100644 --- a/library/cpp/messagebus/actor/tasks_ut.cpp +++ b/library/cpp/messagebus/actor/tasks_ut.cpp @@ -4,8 +4,8 @@ using namespace NActor; -Y_UNIT_TEST_SUITE(TTasks) { - Y_UNIT_TEST(AddTask_FetchTask_Simple) { +Y_UNIT_TEST_SUITE(TTasks) { + Y_UNIT_TEST(AddTask_FetchTask_Simple) { TTasks tasks; UNIT_ASSERT(tasks.AddTask()); @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TTasks) { UNIT_ASSERT(tasks.AddTask()); } - Y_UNIT_TEST(AddTask_FetchTask_AddTask) { + Y_UNIT_TEST(AddTask_FetchTask_AddTask) { TTasks tasks; UNIT_ASSERT(tasks.AddTask()); diff --git a/library/cpp/messagebus/actor/temp_tls_vector.h b/library/cpp/messagebus/actor/temp_tls_vector.h index 02d7bf8c76..675d92f5b0 100644 --- a/library/cpp/messagebus/actor/temp_tls_vector.h +++ b/library/cpp/messagebus/actor/temp_tls_vector.h @@ -19,7 +19,7 @@ public: TTempTlsVector() { Vector = FastTlsSingletonWithTag<TVectorType<T, std::allocator<T>>, TTagForTls>(); - Y_ASSERT(Vector->empty()); + Y_ASSERT(Vector->empty()); } ~TTempTlsVector() { diff --git a/library/cpp/messagebus/actor/what_thread_does_guard_ut.cpp b/library/cpp/messagebus/actor/what_thread_does_guard_ut.cpp index 96ddeb0f08..e4b218a7ca 100644 --- a/library/cpp/messagebus/actor/what_thread_does_guard_ut.cpp +++ b/library/cpp/messagebus/actor/what_thread_does_guard_ut.cpp @@ -4,8 +4,8 @@ #include <util/system/mutex.h> -Y_UNIT_TEST_SUITE(WhatThreadDoesGuard) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(WhatThreadDoesGuard) { + Y_UNIT_TEST(Simple) { TMutex mutex; TWhatThreadDoesAcquireGuard<TMutex> guard(mutex, "acquiring my mutex"); diff --git a/library/cpp/messagebus/async_result.h b/library/cpp/messagebus/async_result.h index 2c6a42095c..d24dde284a 100644 --- a/library/cpp/messagebus/async_result.h +++ b/library/cpp/messagebus/async_result.h @@ -24,7 +24,7 @@ private: public: void SetResult(const T& result) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(!Result, "cannot set result twice"); + Y_VERIFY(!Result, "cannot set result twice"); Result = result; CondVar.BroadCast(); @@ -47,7 +47,7 @@ public: if (!!Result) { onResult(*Result); } else { - Y_ASSERT(!OnResult); + Y_ASSERT(!OnResult); OnResult = std::function<TOnResult>(onResult); } } diff --git a/library/cpp/messagebus/async_result_ut.cpp b/library/cpp/messagebus/async_result_ut.cpp index 3508b6bd8e..2e96492afd 100644 --- a/library/cpp/messagebus/async_result_ut.cpp +++ b/library/cpp/messagebus/async_result_ut.cpp @@ -10,8 +10,8 @@ namespace { } -Y_UNIT_TEST_SUITE(TAsyncResult) { - Y_UNIT_TEST(AndThen_Here) { +Y_UNIT_TEST_SUITE(TAsyncResult) { + Y_UNIT_TEST(AndThen_Here) { TAsyncResult<int> r; int var = 1; @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TAsyncResult) { UNIT_ASSERT_VALUES_EQUAL(17, var); } - Y_UNIT_TEST(AndThen_Later) { + Y_UNIT_TEST(AndThen_Later) { TAsyncResult<int> r; int var = 1; diff --git a/library/cpp/messagebus/cc_semaphore_ut.cpp b/library/cpp/messagebus/cc_semaphore_ut.cpp index 0b37c7b990..206bb7c96a 100644 --- a/library/cpp/messagebus/cc_semaphore_ut.cpp +++ b/library/cpp/messagebus/cc_semaphore_ut.cpp @@ -29,8 +29,8 @@ namespace { }; } -Y_UNIT_TEST_SUITE(TComplexConditionSemaphore) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TComplexConditionSemaphore) { + Y_UNIT_TEST(Simple) { TTestSemaphore sema; UNIT_ASSERT(!sema.TryWait()); sema.Release(); diff --git a/library/cpp/messagebus/config/netaddr.cpp b/library/cpp/messagebus/config/netaddr.cpp index a83c7d7bf1..962ac538e2 100644 --- a/library/cpp/messagebus/config/netaddr.cpp +++ b/library/cpp/messagebus/config/netaddr.cpp @@ -178,6 +178,6 @@ namespace NBus { } template <> -void Out<NBus::TNetAddr>(IOutputStream& out, const NBus::TNetAddr& addr) { +void Out<NBus::TNetAddr>(IOutputStream& out, const NBus::TNetAddr& addr) { Out<NAddr::IRemoteAddr>(out, addr); } diff --git a/library/cpp/messagebus/config/session_config.cpp b/library/cpp/messagebus/config/session_config.cpp index 5dc6327392..fbbbb106c9 100644 --- a/library/cpp/messagebus/config/session_config.cpp +++ b/library/cpp/messagebus/config/session_config.cpp @@ -29,14 +29,14 @@ static int ParseDurationForMessageBus(const char* option) { static int ParseToSForMessageBus(const char* option) { int tos; TStringBuf str(option); - if (str.StartsWith("0x")) { + if (str.StartsWith("0x")) { str = str.Tail(2); - Y_VERIFY(str.length() == 2, "ToS must be a number between 0x00 and 0xFF"); + Y_VERIFY(str.length() == 2, "ToS must be a number between 0x00 and 0xFF"); tos = String2Byte(str.data()); } else { tos = FromString<int>(option); } - Y_VERIFY(tos >= 0 && tos <= 255, "ToS must be between 0x00 and 0xFF"); + Y_VERIFY(tos >= 0 && tos <= 255, "ToS must be between 0x00 and 0xFF"); return tos; } @@ -44,13 +44,13 @@ template <class T> static T ParseWithKmgSuffixT(const char* option) { TStringBuf str(option); T multiplier = 1; - if (str.EndsWith('k')) { + if (str.EndsWith('k')) { multiplier = 1024; str = str.Head(str.size() - 1); - } else if (str.EndsWith('m')) { + } else if (str.EndsWith('m')) { multiplier = 1024 * 1024; str = str.Head(str.size() - 1); - } else if (str.EndsWith('g')) { + } else if (str.EndsWith('g')) { multiplier = 1024 * 1024 * 1024; str = str.Head(str.size() - 1); } diff --git a/library/cpp/messagebus/coreconn_ut.cpp b/library/cpp/messagebus/coreconn_ut.cpp index 64f760cf13..beb6850f26 100644 --- a/library/cpp/messagebus/coreconn_ut.cpp +++ b/library/cpp/messagebus/coreconn_ut.cpp @@ -4,22 +4,22 @@ #include <util/generic/yexception.h> -Y_UNIT_TEST_SUITE(TMakeIpVersionTest) { +Y_UNIT_TEST_SUITE(TMakeIpVersionTest) { using namespace NBus; - Y_UNIT_TEST(IpV4Allowed) { + Y_UNIT_TEST(IpV4Allowed) { UNIT_ASSERT_EQUAL(MakeIpVersion(true, false), EIP_VERSION_4); } - Y_UNIT_TEST(IpV6Allowed) { + Y_UNIT_TEST(IpV6Allowed) { UNIT_ASSERT_EQUAL(MakeIpVersion(false, true), EIP_VERSION_6); } - Y_UNIT_TEST(AllAllowed) { + Y_UNIT_TEST(AllAllowed) { UNIT_ASSERT_EQUAL(MakeIpVersion(true, true), EIP_VERSION_ANY); } - Y_UNIT_TEST(NothingAllowed) { + Y_UNIT_TEST(NothingAllowed) { UNIT_ASSERT_EXCEPTION(MakeIpVersion(false, false), yexception); } } diff --git a/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp b/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp index dbe325e255..0c74f9ecc3 100644 --- a/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp +++ b/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp @@ -8,7 +8,7 @@ TDebugReceiverProtocol::TDebugReceiverProtocol() } void TDebugReceiverProtocol::Serialize(const NBus::TBusMessage*, TBuffer&) { - Y_FAIL("it is receiver only"); + Y_FAIL("it is receiver only"); } TAutoPtr<NBus::TBusMessage> TDebugReceiverProtocol::Deserialize(ui16, TArrayRef<const char> payload) { diff --git a/library/cpp/messagebus/duration_histogram.cpp b/library/cpp/messagebus/duration_histogram.cpp index 44f6c75283..32a0001d41 100644 --- a/library/cpp/messagebus/duration_histogram.cpp +++ b/library/cpp/messagebus/duration_histogram.cpp @@ -48,7 +48,7 @@ namespace { } TString TDurationHistogram::LabelBefore(unsigned i) { - Y_VERIFY(i < Buckets); + Y_VERIFY(i < Buckets); TDuration d = Singleton<TMarks>()->Marks[i]; @@ -67,8 +67,8 @@ TString TDurationHistogram::LabelBefore(unsigned i) { TString TDurationHistogram::PrintToString() const { TStringStream ss; - for (auto time : Times) { - ss << time << "\n"; + for (auto time : Times) { + ss << time << "\n"; } return ss.Str(); } diff --git a/library/cpp/messagebus/duration_histogram_ut.cpp b/library/cpp/messagebus/duration_histogram_ut.cpp index f2fc1aa8a2..01bcc095e9 100644 --- a/library/cpp/messagebus/duration_histogram_ut.cpp +++ b/library/cpp/messagebus/duration_histogram_ut.cpp @@ -2,8 +2,8 @@ #include "duration_histogram.h" -Y_UNIT_TEST_SUITE(TDurationHistogramTest) { - Y_UNIT_TEST(BucketFor) { +Y_UNIT_TEST_SUITE(TDurationHistogramTest) { + Y_UNIT_TEST(BucketFor) { UNIT_ASSERT_VALUES_EQUAL(0u, TDurationHistogram::BucketFor(TDuration::MicroSeconds(0))); UNIT_ASSERT_VALUES_EQUAL(0u, TDurationHistogram::BucketFor(TDuration::MicroSeconds(1))); UNIT_ASSERT_VALUES_EQUAL(0u, TDurationHistogram::BucketFor(TDuration::MicroSeconds(900))); @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TDurationHistogramTest) { UNIT_ASSERT_VALUES_EQUAL(TDurationHistogram::Buckets - 1, TDurationHistogram::BucketFor(TDuration::Hours(1))); } - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TDurationHistogram h1; h1.AddTime(TDuration::MicroSeconds(1)); UNIT_ASSERT_VALUES_EQUAL(1u, h1.Times.front()); @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TDurationHistogramTest) { UNIT_ASSERT_VALUES_EQUAL(1u, h1.Times.back()); } - Y_UNIT_TEST(LabelFor) { + Y_UNIT_TEST(LabelFor) { for (unsigned i = 0; i < TDurationHistogram::Buckets; ++i) { TDurationHistogram::LabelBefore(i); //Cerr << TDurationHistogram::LabelBefore(i) << "\n"; diff --git a/library/cpp/messagebus/event_loop.cpp b/library/cpp/messagebus/event_loop.cpp index 1dbbec1657..f685135bed 100644 --- a/library/cpp/messagebus/event_loop.cpp +++ b/library/cpp/messagebus/event_loop.cpp @@ -4,11 +4,11 @@ #include "thread_extra.h" #include <util/generic/hash.h> -#include <util/network/pair.h> +#include <util/network/pair.h> #include <util/network/poller.h> #include <util/system/event.h> #include <util/system/mutex.h> -#include <util/system/thread.h> +#include <util/system/thread.h> #include <util/system/yassert.h> #include <util/thread/lfqueue.h> @@ -161,7 +161,7 @@ TChannel::TImpl::TImpl(TEventLoop::TImpl* eventLoop, TSocket socket, TEventHandl } TChannel::TImpl::~TImpl() { - Y_ASSERT(Close); + Y_ASSERT(Close); } void TChannel::TImpl::EnableRead() { @@ -260,7 +260,7 @@ TEventLoop::TImpl::TImpl(const char* name) SOCKET wakeupSockets[2]; if (SocketPair(wakeupSockets) < 0) { - Y_FAIL("failed to create socket pair for wakeup sockets: %s", LastSystemErrorText()); + Y_FAIL("failed to create socket pair for wakeup sockets: %s", LastSystemErrorText()); } TSocketHolder wakeupReadSocket(wakeupSockets[0]); @@ -278,7 +278,7 @@ TEventLoop::TImpl::TImpl(const char* name) void TEventLoop::TImpl::Run() { bool res = AtomicCas(&RunningState, EVENT_LOOP_RUNNING, EVENT_LOOP_CREATED); - Y_VERIFY(res, "Invalid mbus event loop state"); + Y_VERIFY(res, "Invalid mbus event loop state"); if (!!Name) { SetCurrentThreadName(Name); @@ -286,7 +286,7 @@ void TEventLoop::TImpl::Run() { while (AtomicGet(StopSignal) == 0) { void* cookies[1024]; - const size_t count = Poller.WaitI(cookies, Y_ARRAY_SIZE(cookies)); + const size_t count = Poller.WaitI(cookies, Y_ARRAY_SIZE(cookies)); void** end = cookies + count; for (void** c = cookies; c != end; ++c) { @@ -295,7 +295,7 @@ void TEventLoop::TImpl::Run() { if (*c == this) { char buf[0x1000]; if (NBus::NPrivate::SocketRecv(WakeupReadSocket, buf) < 0) { - Y_FAIL("failed to recv from wakeup socket: %s", LastSystemErrorText()); + Y_FAIL("failed to recv from wakeup socket: %s", LastSystemErrorText()); } continue; } @@ -306,14 +306,14 @@ void TEventLoop::TImpl::Run() { SOCKET socket = -1; while (SocketsToRemove.Dequeue(&socket)) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Data.erase(socket) == 1, "must be removed once"); + Y_VERIFY(Data.erase(socket) == 1, "must be removed once"); } } { TGuard<TMutex> guard(Mutex); - for (auto& it : Data) { - it.second->Unregister(); + for (auto& it : Data) { + it.second->Unregister(); } // release file descriptors @@ -322,7 +322,7 @@ void TEventLoop::TImpl::Run() { res = AtomicCas(&RunningState, EVENT_LOOP_STOPPED, EVENT_LOOP_RUNNING); - Y_VERIFY(res); + Y_VERIFY(res); StoppedEvent.Signal(); } @@ -338,13 +338,13 @@ void TEventLoop::TImpl::Stop() { } TChannelPtr TEventLoop::TImpl::Register(TSocket socket, TEventHandlerPtr eventHandler, void* cookie) { - Y_VERIFY(socket != INVALID_SOCKET, "must be a valid socket"); + Y_VERIFY(socket != INVALID_SOCKET, "must be a valid socket"); TChannelPtr channel = new TChannel(new TChannel::TImpl(this, socket, eventHandler, cookie)); TGuard<TMutex> guard(Mutex); - Y_VERIFY(Data.insert(std::make_pair(socket, channel)).second, "must not be already inserted"); + Y_VERIFY(Data.insert(std::make_pair(socket, channel)).second, "must not be already inserted"); return channel; } @@ -352,7 +352,7 @@ TChannelPtr TEventLoop::TImpl::Register(TSocket socket, TEventHandlerPtr eventHa void TEventLoop::TImpl::Wakeup() { if (NBus::NPrivate::SocketSend(WakeupWriteSocket, TArrayRef<const char>("", 1)) < 0) { if (LastSystemError() != EAGAIN) { - Y_FAIL("failed to send to wakeup socket: %s", LastSystemErrorText()); + Y_FAIL("failed to send to wakeup socket: %s", LastSystemErrorText()); } } } @@ -365,6 +365,6 @@ void TEventLoop::TImpl::AddToPoller(SOCKET socket, void* cookie, int flags) { } else if (flags == OP_READ_WRITE) { Poller.WaitReadWriteOneShot(socket, cookie); } else { - Y_FAIL("Wrong flags: %d", int(flags)); + Y_FAIL("Wrong flags: %d", int(flags)); } } diff --git a/library/cpp/messagebus/extra_ref.h b/library/cpp/messagebus/extra_ref.h index 99470152fc..2927123266 100644 --- a/library/cpp/messagebus/extra_ref.h +++ b/library/cpp/messagebus/extra_ref.h @@ -11,7 +11,7 @@ public: { } ~TExtraRef() { - Y_VERIFY(!Holds); + Y_VERIFY(!Holds); } template <typename TThis> diff --git a/library/cpp/messagebus/futex_like.cpp b/library/cpp/messagebus/futex_like.cpp index bf3bee4ef5..7f965126db 100644 --- a/library/cpp/messagebus/futex_like.cpp +++ b/library/cpp/messagebus/futex_like.cpp @@ -25,13 +25,13 @@ namespace { #endif void TFutexLike::Wake(size_t count) { - Y_ASSERT(count > 0); + Y_ASSERT(count > 0); #ifdef _linux_ if (count > unsigned(Max<int>())) { count = Max<int>(); } int r = futex(&Value, FUTEX_WAKE, count, nullptr, nullptr, 0); - Y_VERIFY(r >= 0, "futex_wake failed: %s", strerror(errno)); + Y_VERIFY(r >= 0, "futex_wake failed: %s", strerror(errno)); #else TGuard<TMutex> guard(Mutex); if (count == 1) { @@ -45,7 +45,7 @@ void TFutexLike::Wake(size_t count) { void TFutexLike::Wait(int expected) { #ifdef _linux_ int r = futex(&Value, FUTEX_WAIT, expected, nullptr, nullptr, 0); - Y_VERIFY(r >= 0 || errno == EWOULDBLOCK, "futex_wait failed: %s", strerror(errno)); + Y_VERIFY(r >= 0 || errno == EWOULDBLOCK, "futex_wait failed: %s", strerror(errno)); #else TGuard<TMutex> guard(Mutex); if (expected == Get()) { diff --git a/library/cpp/messagebus/latch_ut.cpp b/library/cpp/messagebus/latch_ut.cpp index 51a0a8baf1..bfab04f527 100644 --- a/library/cpp/messagebus/latch_ut.cpp +++ b/library/cpp/messagebus/latch_ut.cpp @@ -2,8 +2,8 @@ #include "latch.h" -Y_UNIT_TEST_SUITE(TLatch) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TLatch) { + Y_UNIT_TEST(Simple) { TLatch latch; UNIT_ASSERT(latch.TryWait()); latch.Lock(); diff --git a/library/cpp/messagebus/lfqueue_batch_ut.cpp b/library/cpp/messagebus/lfqueue_batch_ut.cpp index 71f854e734..f80434c0d4 100644 --- a/library/cpp/messagebus/lfqueue_batch_ut.cpp +++ b/library/cpp/messagebus/lfqueue_batch_ut.cpp @@ -2,8 +2,8 @@ #include "lfqueue_batch.h" -Y_UNIT_TEST_SUITE(TLockFreeQueueBatch) { - Y_UNIT_TEST(Order1) { +Y_UNIT_TEST_SUITE(TLockFreeQueueBatch) { + Y_UNIT_TEST(Order1) { TLockFreeQueueBatch<unsigned> q; { TAutoPtr<TVector<unsigned>> v(new TVector<unsigned>); @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueBatch) { UNIT_ASSERT_VALUES_EQUAL(0u, r.size()); } - Y_UNIT_TEST(Order2) { + Y_UNIT_TEST(Order2) { TLockFreeQueueBatch<unsigned> q; { TAutoPtr<TVector<unsigned>> v(new TVector<unsigned>); diff --git a/library/cpp/messagebus/local_flags_ut.cpp b/library/cpp/messagebus/local_flags_ut.cpp index afa8ac1a29..189d73eb0f 100644 --- a/library/cpp/messagebus/local_flags_ut.cpp +++ b/library/cpp/messagebus/local_flags_ut.cpp @@ -5,8 +5,8 @@ using namespace NBus; using namespace NBus::NPrivate; -Y_UNIT_TEST_SUITE(EMessageLocalFlags) { - Y_UNIT_TEST(TestLocalFlagSetToString) { +Y_UNIT_TEST_SUITE(EMessageLocalFlags) { + Y_UNIT_TEST(TestLocalFlagSetToString) { UNIT_ASSERT_VALUES_EQUAL("0", LocalFlagSetToString(0)); UNIT_ASSERT_VALUES_EQUAL("MESSAGE_REPLY_INTERNAL", LocalFlagSetToString(MESSAGE_REPLY_INTERNAL)); diff --git a/library/cpp/messagebus/memory_ut.cpp b/library/cpp/messagebus/memory_ut.cpp index 8ceeca5f86..00654f28a1 100644 --- a/library/cpp/messagebus/memory_ut.cpp +++ b/library/cpp/messagebus/memory_ut.cpp @@ -2,8 +2,8 @@ #include "memory.h" -Y_UNIT_TEST_SUITE(MallocAligned) { - Y_UNIT_TEST(Test) { +Y_UNIT_TEST_SUITE(MallocAligned) { + Y_UNIT_TEST(Test) { for (size_t size = 0; size < 1000; ++size) { void* ptr = MallocAligned(size, 128); UNIT_ASSERT(uintptr_t(ptr) % 128 == 0); diff --git a/library/cpp/messagebus/message.cpp b/library/cpp/messagebus/message.cpp index 8e2a5cdd58..bfa7ed8e9b 100644 --- a/library/cpp/messagebus/message.cpp +++ b/library/cpp/messagebus/message.cpp @@ -193,6 +193,6 @@ namespace NBus { } template <> -void Out<TBusIdentity>(IOutputStream& os, TTypeTraits<TBusIdentity>::TFuncParam ident) { +void Out<TBusIdentity>(IOutputStream& os, TTypeTraits<TBusIdentity>::TFuncParam ident) { os << ident.ToString(); } diff --git a/library/cpp/messagebus/message_counter.cpp b/library/cpp/messagebus/message_counter.cpp index 9b7cad9c46..04d9343f6a 100644 --- a/library/cpp/messagebus/message_counter.cpp +++ b/library/cpp/messagebus/message_counter.cpp @@ -25,7 +25,7 @@ TMessageCounter& TMessageCounter::operator+=(const TMessageCounter& that) { TString TMessageCounter::ToString(bool reader) const { if (reader) { - Y_ASSERT(CountCompressionRequests == 0); + Y_ASSERT(CountCompressionRequests == 0); } TStringStream readValue; diff --git a/library/cpp/messagebus/message_status_counter.cpp b/library/cpp/messagebus/message_status_counter.cpp index 8a6ea01460..891c8f5bb2 100644 --- a/library/cpp/messagebus/message_status_counter.cpp +++ b/library/cpp/messagebus/message_status_counter.cpp @@ -28,14 +28,14 @@ TString TMessageStatusCounter::PrintToString() const { bool hasZeros = false; for (size_t i = 0; i < MESSAGE_STATUS_COUNT; ++i) { if (i == MESSAGE_OK) { - Y_VERIFY(Counts[i] == 0); + Y_VERIFY(Counts[i] == 0); continue; } if (Counts[i] != 0) { p.AddRow(EMessageStatus(i), Counts[i]); const char* description = MessageStatusDescription(EMessageStatus(i)); // TODO: add third column - Y_UNUSED(description); + Y_UNUSED(description); hasNonZeros = true; } else { @@ -59,7 +59,7 @@ void TMessageStatusCounter::FillErrorsProtobuf(TConnectionStatusMonRecord* statu status->clear_errorcountbystatus(); for (size_t i = 0; i < MESSAGE_STATUS_COUNT; ++i) { if (i == MESSAGE_OK) { - Y_VERIFY(Counts[i] == 0); + Y_VERIFY(Counts[i] == 0); continue; } if (Counts[i] != 0) { diff --git a/library/cpp/messagebus/message_status_counter_ut.cpp b/library/cpp/messagebus/message_status_counter_ut.cpp index c5b7895490..9598651329 100644 --- a/library/cpp/messagebus/message_status_counter_ut.cpp +++ b/library/cpp/messagebus/message_status_counter_ut.cpp @@ -7,8 +7,8 @@ using namespace NBus; using namespace NBus::NPrivate; -Y_UNIT_TEST_SUITE(MessageStatusCounter) { - Y_UNIT_TEST(MessageStatusConversion) { +Y_UNIT_TEST_SUITE(MessageStatusCounter) { + Y_UNIT_TEST(MessageStatusConversion) { const ::google::protobuf::EnumDescriptor* descriptor = TMessageStatusRecord_EMessageStatus_descriptor(); diff --git a/library/cpp/messagebus/messqueue.cpp b/library/cpp/messagebus/messqueue.cpp index 9b55f9061d..3474d62705 100644 --- a/library/cpp/messagebus/messqueue.cpp +++ b/library/cpp/messagebus/messqueue.cpp @@ -169,7 +169,7 @@ void TBusMessageQueue::Add(TIntrusivePtr<TBusSessionImpl> session) { void TBusMessageQueue::Remove(TBusSession* session) { TGuard<TMutex> scope(Lock); TList<TIntrusivePtr<TBusSessionImpl>>::iterator it = std::find(Sessions.begin(), Sessions.end(), session); - Y_VERIFY(it != Sessions.end(), "do not destroy session twice"); + Y_VERIFY(it != Sessions.end(), "do not destroy session twice"); Sessions.erase(it); } @@ -184,8 +184,8 @@ void TBusMessageQueue::DestroyAllSessions() { sessions = Sessions; } - for (auto& session : sessions) { - Y_VERIFY(session->IsDown(), "Session must be shut down prior to queue shutdown"); + for (auto& session : sessions) { + Y_VERIFY(session->IsDown(), "Session must be shut down prior to queue shutdown"); } } diff --git a/library/cpp/messagebus/misc/test_sync.h b/library/cpp/messagebus/misc/test_sync.h index a74b5d6f3b..be3f4f20b8 100644 --- a/library/cpp/messagebus/misc/test_sync.h +++ b/library/cpp/messagebus/misc/test_sync.h @@ -32,7 +32,7 @@ public: void WaitFor(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current <= n, "too late, waiting for %d, already %d", n, Current); + Y_VERIFY(Current <= n, "too late, waiting for %d, already %d", n, Current); while (n > Current) { CondVar.WaitI(Mutex); @@ -42,7 +42,7 @@ public: void WaitForAndIncrement(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current <= n, "too late, waiting for %d, already %d", n, Current); + Y_VERIFY(Current <= n, "too late, waiting for %d, already %d", n, Current); while (n > Current) { CondVar.WaitI(Mutex); @@ -55,7 +55,7 @@ public: void CheckAndIncrement(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current == n, "must be %d, currently %d", n, Current); + Y_VERIFY(Current == n, "must be %d, currently %d", n, Current); DoInc(); CondVar.BroadCast(); @@ -64,12 +64,12 @@ public: void Check(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current == n, "must be %d, currently %d", n, Current); + Y_VERIFY(Current == n, "must be %d, currently %d", n, Current); } private: void DoInc() { unsigned r = ++Current; - Y_UNUSED(r); + Y_UNUSED(r); } }; diff --git a/library/cpp/messagebus/misc/tokenquota.h b/library/cpp/messagebus/misc/tokenquota.h index 96b5f7c4b9..190547fa54 100644 --- a/library/cpp/messagebus/misc/tokenquota.h +++ b/library/cpp/messagebus/misc/tokenquota.h @@ -22,7 +22,7 @@ namespace NBus { , WakeLev(wake < 1 ? Max<size_t>(1, tokens / 2) : 0) , Tokens_(tokens) { - Y_UNUSED(padd_); + Y_UNUSED(padd_); } bool Acquire(TAtomic level = 1, bool force = false) { @@ -37,7 +37,7 @@ namespace NBus { void Consume(size_t items) { if (Enabled) { - Y_ASSERT(Acquired >= TAtomicBase(items)); + Y_ASSERT(Acquired >= TAtomicBase(items)); Acquired -= items; } diff --git a/library/cpp/messagebus/misc/weak_ptr.h b/library/cpp/messagebus/misc/weak_ptr.h index 20afeafa88..70fdeb0e2a 100644 --- a/library/cpp/messagebus/misc/weak_ptr.h +++ b/library/cpp/messagebus/misc/weak_ptr.h @@ -23,13 +23,13 @@ private: void Release() { TGuard<TMutex> g(Mutex); - Y_ASSERT(!!Outer); + Y_ASSERT(!!Outer); Outer = nullptr; } TIntrusivePtr<TSelf> Get() { TGuard<TMutex> g(Mutex); - Y_ASSERT(!Outer || Outer->RefCount() > 0); + Y_ASSERT(!Outer || Outer->RefCount() > 0); return Outer; } }; diff --git a/library/cpp/messagebus/misc/weak_ptr_ut.cpp b/library/cpp/messagebus/misc/weak_ptr_ut.cpp index b499ca7b1d..5a325278db 100644 --- a/library/cpp/messagebus/misc/weak_ptr_ut.cpp +++ b/library/cpp/messagebus/misc/weak_ptr_ut.cpp @@ -2,7 +2,7 @@ #include "weak_ptr.h" -Y_UNIT_TEST_SUITE(TWeakPtrTest) { +Y_UNIT_TEST_SUITE(TWeakPtrTest) { struct TWeakPtrTester: public TWeakRefCounted<TWeakPtrTester> { int* const CounterPtr; @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TWeakPtrTest) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { int destroyCount = 0; TIntrusivePtr<TWeakPtrTester> p(new TWeakPtrTester(&destroyCount)); diff --git a/library/cpp/messagebus/moved_ut.cpp b/library/cpp/messagebus/moved_ut.cpp index 5345b81947..c1a07cce7e 100644 --- a/library/cpp/messagebus/moved_ut.cpp +++ b/library/cpp/messagebus/moved_ut.cpp @@ -2,8 +2,8 @@ #include "moved.h" -Y_UNIT_TEST_SUITE(TMovedTest) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TMovedTest) { + Y_UNIT_TEST(Simple) { TMoved<THolder<int>> h1(MakeHolder<int>(10)); TMoved<THolder<int>> h2 = h1; UNIT_ASSERT(!*h1); @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TMovedTest) { UNIT_ASSERT_VALUES_EQUAL(11, **h); } - Y_UNIT_TEST(PassToFunction) { + Y_UNIT_TEST(PassToFunction) { THolder<int> h(new int(11)); Foo(h); } diff --git a/library/cpp/messagebus/netaddr_ut.cpp b/library/cpp/messagebus/netaddr_ut.cpp index 63b688e53b..e5c68bf402 100644 --- a/library/cpp/messagebus/netaddr_ut.cpp +++ b/library/cpp/messagebus/netaddr_ut.cpp @@ -5,17 +5,17 @@ using namespace NBus; -Y_UNIT_TEST_SUITE(TNetAddr) { - Y_UNIT_TEST(ResolveIpv4) { +Y_UNIT_TEST_SUITE(TNetAddr) { + Y_UNIT_TEST(ResolveIpv4) { ASSUME_IP_V4_ENABLED; UNIT_ASSERT(TNetAddr("ns1.yandex.ru", 80, EIP_VERSION_4).IsIpv4()); } - Y_UNIT_TEST(ResolveIpv6) { + Y_UNIT_TEST(ResolveIpv6) { UNIT_ASSERT(TNetAddr("ns1.yandex.ru", 80, EIP_VERSION_6).IsIpv6()); } - Y_UNIT_TEST(ResolveAny) { + Y_UNIT_TEST(ResolveAny) { TNetAddr("ns1.yandex.ru", 80, EIP_VERSION_ANY); } } diff --git a/library/cpp/messagebus/network.cpp b/library/cpp/messagebus/network.cpp index 7fe03a9010..304bedae5a 100644 --- a/library/cpp/messagebus/network.cpp +++ b/library/cpp/messagebus/network.cpp @@ -11,7 +11,7 @@ using namespace NBus::NPrivate; namespace { TBindResult BindOnPortProto(int port, int af, bool reusePort) { - Y_VERIFY(af == AF_INET || af == AF_INET6, "wrong af"); + Y_VERIFY(af == AF_INET || af == AF_INET6, "wrong af"); SOCKET fd = ::socket(af, SOCK_STREAM, 0); if (fd == INVALID_SOCKET) { @@ -126,8 +126,8 @@ void NBus::NPrivate::SetSockOptTcpCork(SOCKET s, bool value) { #ifdef _linux_ CheckedSetSockOpt(s, IPPROTO_TCP, TCP_CORK, (int)value, "TCP_CORK"); #else - Y_UNUSED(s); - Y_UNUSED(value); + Y_UNUSED(s); + Y_UNUSED(value); #endif } @@ -138,7 +138,7 @@ ssize_t NBus::NPrivate::SocketSend(SOCKET s, TArrayRef<const char> data) { #endif ssize_t r = ::send(s, data.data(), data.size(), flags); if (r < 0) { - Y_VERIFY(LastSystemError() != EBADF, "bad fd"); + Y_VERIFY(LastSystemError() != EBADF, "bad fd"); } return r; } @@ -150,7 +150,7 @@ ssize_t NBus::NPrivate::SocketRecv(SOCKET s, TArrayRef<char> buffer) { #endif ssize_t r = ::recv(s, buffer.data(), buffer.size(), flags); if (r < 0) { - Y_VERIFY(LastSystemError() != EBADF, "bad fd"); + Y_VERIFY(LastSystemError() != EBADF, "bad fd"); } return r; } diff --git a/library/cpp/messagebus/network_ut.cpp b/library/cpp/messagebus/network_ut.cpp index 05f4cb6354..f1798419db 100644 --- a/library/cpp/messagebus/network_ut.cpp +++ b/library/cpp/messagebus/network_ut.cpp @@ -31,8 +31,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(Network) { - Y_UNIT_TEST(BindOnPortConcrete) { +Y_UNIT_TEST_SUITE(Network) { + Y_UNIT_TEST(BindOnPortConcrete) { if (!IsFixedPortTestAllowed()) { return; } @@ -45,7 +45,7 @@ Y_UNIT_TEST_SUITE(Network) { } } - Y_UNIT_TEST(BindOnPortRandom) { + Y_UNIT_TEST(BindOnPortRandom) { TVector<TBindResult> r = BindOnPort(0, false).second; UNIT_ASSERT_VALUES_EQUAL(size_t(2), r.size()); @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(Network) { UNIT_ASSERT_VALUES_EQUAL(r.at(0).Addr.GetPort(), r.at(1).Addr.GetPort()); } - Y_UNIT_TEST(BindOnBusyPort) { + Y_UNIT_TEST(BindOnBusyPort) { auto r = BindOnPort(0, false); UNIT_ASSERT_EXCEPTION_CONTAINS(BindOnPort(r.first, false), TSystemError, "failed to bind on port " + ToString(r.first)); diff --git a/library/cpp/messagebus/nondestroying_holder.h b/library/cpp/messagebus/nondestroying_holder.h index b7d4efd2b4..f4725d696f 100644 --- a/library/cpp/messagebus/nondestroying_holder.h +++ b/library/cpp/messagebus/nondestroying_holder.h @@ -16,7 +16,7 @@ public: } ~TNonDestroyingHolder() { - Y_VERIFY(!*this, "stored object must be explicitly released"); + Y_VERIFY(!*this, "stored object must be explicitly released"); } }; @@ -34,6 +34,6 @@ public: } inline ~TNonDestroyingAutoPtr() { - Y_VERIFY(!*this, "stored object must be explicitly released"); + Y_VERIFY(!*this, "stored object must be explicitly released"); } }; diff --git a/library/cpp/messagebus/nondestroying_holder_ut.cpp b/library/cpp/messagebus/nondestroying_holder_ut.cpp index 02a417a8fe..208042a2ba 100644 --- a/library/cpp/messagebus/nondestroying_holder_ut.cpp +++ b/library/cpp/messagebus/nondestroying_holder_ut.cpp @@ -2,8 +2,8 @@ #include "nondestroying_holder.h" -Y_UNIT_TEST_SUITE(TNonDestroyingHolder) { - Y_UNIT_TEST(ToAutoPtr) { +Y_UNIT_TEST_SUITE(TNonDestroyingHolder) { + Y_UNIT_TEST(ToAutoPtr) { TNonDestroyingHolder<int> h(new int(11)); TAutoPtr<int> i(h); UNIT_ASSERT_VALUES_EQUAL(11, *i); diff --git a/library/cpp/messagebus/oldmodule/module.cpp b/library/cpp/messagebus/oldmodule/module.cpp index fd08e223e8..24bd778799 100644 --- a/library/cpp/messagebus/oldmodule/module.cpp +++ b/library/cpp/messagebus/oldmodule/module.cpp @@ -774,7 +774,7 @@ void TBusModuleImpl::DestroyJob(TJobRunner* job) { { TWhatThreadDoesAcquireGuard<TMutex> G(Lock, "modules: acquiring lock for DestroyJob"); int jobCount = AtomicDecrement(JobCount); - Y_VERIFY(jobCount >= 0, "decremented too much"); + Y_VERIFY(jobCount >= 0, "decremented too much"); Jobs.erase(job->JobStorageIterator); if (AtomicGet(State) == STOPPED) { @@ -789,7 +789,7 @@ void TBusModuleImpl::DestroyJob(TJobRunner* job) { void TBusModuleImpl::OnMessageReceived(TAutoPtr<TBusMessage> msg0, TOnMessageContext& context) { TBusMessage* msg = !!msg0 ? msg0.Get() : context.GetMessage(); - Y_VERIFY(!!msg); + Y_VERIFY(!!msg); THolder<TJobRunner> jobRunner(new TJobRunner(Module->CreateJobInstance(msg))); jobRunner->Job->MessageHolder.Reset(msg0.Release()); @@ -810,11 +810,11 @@ void TBusModuleImpl::Shutdown() { } AtomicSet(State, TBusModuleImpl::STOPPED); - for (auto& clientSession : ClientSessions) { - clientSession->Shutdown(); + for (auto& clientSession : ClientSessions) { + clientSession->Shutdown(); } - for (auto& serverSession : ServerSessions) { - serverSession->Shutdown(); + for (auto& serverSession : ServerSessions) { + serverSession->Shutdown(); } for (size_t starter = 0; starter < Starters.size(); ++starter) { @@ -823,8 +823,8 @@ void TBusModuleImpl::Shutdown() { { TWhatThreadDoesAcquireGuard<TMutex> guard(Lock, "modules: acquiring lock for Shutdown"); - for (auto& Job : Jobs) { - Job->Schedule(); + for (auto& Job : Jobs) { + Job->Schedule(); } while (!Jobs.empty()) { @@ -834,8 +834,8 @@ void TBusModuleImpl::Shutdown() { } EMessageStatus TBusModule::StartJob(TAutoPtr<TBusMessage> message) { - Y_VERIFY(Impl->State == TBusModuleImpl::RUNNING); - Y_VERIFY(!!Impl->Queue); + Y_VERIFY(Impl->State == TBusModuleImpl::RUNNING); + Y_VERIFY(!!Impl->Queue); if ((unsigned)AtomicGet(Impl->JobCount) >= Impl->ModuleConfig.StarterMaxInFlight) { return MESSAGE_BUSY; @@ -853,16 +853,16 @@ void TModuleServerHandler::OnMessage(TOnMessageContext& msg) { void TModuleClientHandler::OnReply(TAutoPtr<TBusMessage> req, TAutoPtr<TBusMessage> resp) { TJobRunner* job = GetJob(req.Get()); - Y_ASSERT(job); - Y_ASSERT(job->Job->Message != req.Get()); + Y_ASSERT(job); + Y_ASSERT(job->Job->Message != req.Get()); job->EnqueueAndSchedule(TJobResponseMessage(req.Release(), resp.Release(), MESSAGE_OK)); job->UnRef(); } void TModuleClientHandler::OnMessageSentOneWay(TAutoPtr<TBusMessage> req) { TJobRunner* job = GetJob(req.Get()); - Y_ASSERT(job); - Y_ASSERT(job->Job->Message != req.Get()); + Y_ASSERT(job); + Y_ASSERT(job->Job->Message != req.Get()); job->EnqueueAndSchedule(TJobResponseMessage(req.Release(), nullptr, MESSAGE_OK)); job->UnRef(); } @@ -870,7 +870,7 @@ void TModuleClientHandler::OnMessageSentOneWay(TAutoPtr<TBusMessage> req) { void TModuleClientHandler::OnError(TAutoPtr<TBusMessage> msg, EMessageStatus status) { TJobRunner* job = GetJob(msg.Get()); if (job) { - Y_ASSERT(job->Job->Message != msg.Get()); + Y_ASSERT(job->Job->Message != msg.Get()); job->EnqueueAndSchedule(TJobResponseMessage(msg.Release(), nullptr, status)); job->UnRef(); } diff --git a/library/cpp/messagebus/protobuf/ybusbuf.cpp b/library/cpp/messagebus/protobuf/ybusbuf.cpp index ac4b5a9d17..63415b3737 100644 --- a/library/cpp/messagebus/protobuf/ybusbuf.cpp +++ b/library/cpp/messagebus/protobuf/ybusbuf.cpp @@ -12,8 +12,8 @@ TBusBufferProtocol::TBusBufferProtocol(TBusService name, int port) } TBusBufferProtocol::~TBusBufferProtocol() { - for (auto& type : Types) { - delete type; + for (auto& type : Types) { + delete type; } } @@ -47,7 +47,7 @@ void TBusBufferProtocol::Serialize(const TBusMessage* mess, TBuffer& data) { const TBusHeader* header = mess->GetHeader(); if (!IsRegisteredType(header->Type)) { - Y_FAIL("unknown message type: %d", int(header->Type)); + Y_FAIL("unknown message type: %d", int(header->Type)); return; } @@ -58,7 +58,7 @@ void TBusBufferProtocol::Serialize(const TBusMessage* mess, TBuffer& data) { data.Reserve(data.Size() + size); char* after = (char*)bmess->GetRecord()->SerializeWithCachedSizesToArray((ui8*)data.Pos()); - Y_VERIFY(after - data.Pos() == size); + Y_VERIFY(after - data.Pos() == size); data.Advance(size); } @@ -69,7 +69,7 @@ TAutoPtr<TBusMessage> TBusBufferProtocol::Deserialize(ui16 messageType, TArrayRe TBusBufferBase* messageTemplate = FindType(messageType); if (messageTemplate == nullptr) { return nullptr; - //Y_FAIL("unknown message type: %d", unsigned(messageType)); + //Y_FAIL("unknown message type: %d", unsigned(messageType)); } // clone the base diff --git a/library/cpp/messagebus/rain_check/core/coro.cpp b/library/cpp/messagebus/rain_check/core/coro.cpp index c79c6dfc5b..500841dd5b 100644 --- a/library/cpp/messagebus/rain_check/core/coro.cpp +++ b/library/cpp/messagebus/rain_check/core/coro.cpp @@ -23,7 +23,7 @@ TCoroTaskRunner::TCoroTaskRunner(IEnv* env, ISubtaskListener* parent, TAutoPtr<I } TCoroTaskRunner::~TCoroTaskRunner() { - Y_ASSERT(CoroDone); + Y_ASSERT(CoroDone); } Y_POD_STATIC_THREAD(TContMachineContext*) @@ -32,7 +32,7 @@ Y_POD_STATIC_THREAD(TCoroTaskRunner*) Task; bool TCoroTaskRunner::ReplyReceived() { - Y_ASSERT(!CoroDone); + Y_ASSERT(!CoroDone); TContMachineContext me; @@ -43,8 +43,8 @@ bool TCoroTaskRunner::ReplyReceived() { Stack.VerifyNoStackOverflow(); - Y_ASSERT(CallerContext == &me); - Y_ASSERT(Task == this); + Y_ASSERT(CallerContext == &me); + Y_ASSERT(Task == this); return !CoroDone; } diff --git a/library/cpp/messagebus/rain_check/core/coro_stack.cpp b/library/cpp/messagebus/rain_check/core/coro_stack.cpp index e4517393e4..83b984ca6e 100644 --- a/library/cpp/messagebus/rain_check/core/coro_stack.cpp +++ b/library/cpp/messagebus/rain_check/core/coro_stack.cpp @@ -12,8 +12,8 @@ using namespace NRainCheck::NPrivate; TCoroStack::TCoroStack(size_t size) : SizeValue(size) { - Y_VERIFY(size % sizeof(ui32) == 0); - Y_VERIFY(size >= 0x1000); + Y_VERIFY(size % sizeof(ui32) == 0); + Y_VERIFY(size >= 0x1000); DataHolder.Reset(malloc(size)); diff --git a/library/cpp/messagebus/rain_check/core/coro_ut.cpp b/library/cpp/messagebus/rain_check/core/coro_ut.cpp index 7157230da7..61a33584a5 100644 --- a/library/cpp/messagebus/rain_check/core/coro_ut.cpp +++ b/library/cpp/messagebus/rain_check/core/coro_ut.cpp @@ -7,7 +7,7 @@ using namespace NRainCheck; -Y_UNIT_TEST_SUITE(RainCheckCoro) { +Y_UNIT_TEST_SUITE(RainCheckCoro) { struct TSimpleCoroTask : ICoroTask { TTestSync* const TestSync; @@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(RainCheckCoro) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TTestSync testSync; TTestEnv env; @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(RainCheckCoro) { } }; - Y_UNIT_TEST(Sleep) { + Y_UNIT_TEST(Sleep) { TTestSync testSync; TTestEnv env; @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(RainCheckCoro) { } }; - Y_UNIT_TEST(Spawn) { + Y_UNIT_TEST(Spawn) { TTestSync testSync; TTestEnv env; diff --git a/library/cpp/messagebus/rain_check/core/simple.cpp b/library/cpp/messagebus/rain_check/core/simple.cpp index 22e721758e..70182b2f93 100644 --- a/library/cpp/messagebus/rain_check/core/simple.cpp +++ b/library/cpp/messagebus/rain_check/core/simple.cpp @@ -9,7 +9,7 @@ TSimpleTaskRunner::TSimpleTaskRunner(IEnv* env, ISubtaskListener* parentTask, TA } TSimpleTaskRunner::~TSimpleTaskRunner() { - Y_ASSERT(!ContinueFunc); + Y_ASSERT(!ContinueFunc); } bool TSimpleTaskRunner::ReplyReceived() { diff --git a/library/cpp/messagebus/rain_check/core/simple_ut.cpp b/library/cpp/messagebus/rain_check/core/simple_ut.cpp index 2eb5fad8f9..d4545e05aa 100644 --- a/library/cpp/messagebus/rain_check/core/simple_ut.cpp +++ b/library/cpp/messagebus/rain_check/core/simple_ut.cpp @@ -8,7 +8,7 @@ using namespace NRainCheck; -Y_UNIT_TEST_SUITE(RainCheckSimple) { +Y_UNIT_TEST_SUITE(RainCheckSimple) { struct TTaskWithCompletionCallback: public ISimpleTask { TTestEnv* const Env; TTestSync* const TestSync; @@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(RainCheckSimple) { } void SleepCompletionCallback(TSubtaskCompletion* completion) { - Y_VERIFY(completion == &SleepCompletion); + Y_VERIFY(completion == &SleepCompletion); TestSync->CheckAndIncrement(1); Env->SleepService.Sleep(&SleepCompletion, TDuration::MilliSeconds(1)); @@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(RainCheckSimple) { } }; - Y_UNIT_TEST(CompletionCallback) { + Y_UNIT_TEST(CompletionCallback) { TTestEnv env; TTestSync testSync; diff --git a/library/cpp/messagebus/rain_check/core/sleep_ut.cpp b/library/cpp/messagebus/rain_check/core/sleep_ut.cpp index f38daf75d6..2ae85a87b1 100644 --- a/library/cpp/messagebus/rain_check/core/sleep_ut.cpp +++ b/library/cpp/messagebus/rain_check/core/sleep_ut.cpp @@ -7,7 +7,7 @@ using namespace NRainCheck; using namespace NActor; -Y_UNIT_TEST_SUITE(Sleep) { +Y_UNIT_TEST_SUITE(Sleep) { struct TTestTask: public ISimpleTask { TSimpleEnv* const Env; TTestSync* const TestSync; @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(Sleep) { } }; - Y_UNIT_TEST(Test) { + Y_UNIT_TEST(Test) { TTestSync testSync; TSimpleEnv env; diff --git a/library/cpp/messagebus/rain_check/core/spawn_ut.cpp b/library/cpp/messagebus/rain_check/core/spawn_ut.cpp index 3aefde88f7..ba5a5e41cf 100644 --- a/library/cpp/messagebus/rain_check/core/spawn_ut.cpp +++ b/library/cpp/messagebus/rain_check/core/spawn_ut.cpp @@ -12,7 +12,7 @@ using namespace NRainCheck; using namespace NActor; -Y_UNIT_TEST_SUITE(Spawn) { +Y_UNIT_TEST_SUITE(Spawn) { struct TTestTask: public ISimpleTask { TTestSync* const TestSync; @@ -43,7 +43,7 @@ Y_UNIT_TEST_SUITE(Spawn) { } }; - Y_UNIT_TEST(Continuation) { + Y_UNIT_TEST(Continuation) { TTestSync testSync; TSimpleEnv env; @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(Spawn) { } }; - Y_UNIT_TEST(Subtask) { + Y_UNIT_TEST(Subtask) { TTestSync testSync; TTestEnv env; @@ -124,8 +124,8 @@ Y_UNIT_TEST_SUITE(Spawn) { return nullptr; } - for (auto& subtask : Subtasks) { - SpawnSubtask<TNopSimpleTask>(Env, &subtask, ""); + for (auto& subtask : Subtasks) { + SpawnSubtask<TNopSimpleTask>(Env, &subtask, ""); } ++I; @@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(Spawn) { } }; - Y_UNIT_TEST(SubtaskLong) { + Y_UNIT_TEST(SubtaskLong) { TTestSync testSync; TTestEnv env; diff --git a/library/cpp/messagebus/rain_check/core/task.cpp b/library/cpp/messagebus/rain_check/core/task.cpp index 3094890ed5..a098437d53 100644 --- a/library/cpp/messagebus/rain_check/core/task.cpp +++ b/library/cpp/messagebus/rain_check/core/task.cpp @@ -31,7 +31,7 @@ TTaskRunnerBase::TTaskRunnerBase(IEnv* env, ISubtaskListener* parentTask, TAutoP } TTaskRunnerBase::~TTaskRunnerBase() { - Y_ASSERT(Done); + Y_ASSERT(Done); } namespace { @@ -40,19 +40,19 @@ namespace { TRunningInThisThreadGuard(TTaskRunnerBase* task) : Task(task) { - Y_ASSERT(!ThreadCurrentTask); + Y_ASSERT(!ThreadCurrentTask); ThreadCurrentTask = task; } ~TRunningInThisThreadGuard() { - Y_ASSERT(ThreadCurrentTask == Task); + Y_ASSERT(ThreadCurrentTask == Task); ThreadCurrentTask = nullptr; } }; } void NRainCheck::TTaskRunnerBase::Act(NActor::TDefaultTag) { - Y_ASSERT(RefCount() > 0); + Y_ASSERT(RefCount() > 0); TRunningInThisThreadGuard g(this); @@ -63,11 +63,11 @@ void NRainCheck::TTaskRunnerBase::Act(NActor::TDefaultTag) { temp.GetVector()->swap(Pending); - for (auto& pending : *temp.GetVector()) { - if (pending->IsComplete()) { - pending->FireCompletionCallback(GetImplBase()); + for (auto& pending : *temp.GetVector()) { + if (pending->IsComplete()) { + pending->FireCompletionCallback(GetImplBase()); } else { - Pending.push_back(pending); + Pending.push_back(pending); } } @@ -96,11 +96,11 @@ bool TTaskRunnerBase::IsRunningInThisThread() const { TSubtaskCompletion::~TSubtaskCompletion() { ESubtaskState state = State.Get(); - Y_ASSERT(state == CREATED || state == DONE || state == CANCELED); + Y_ASSERT(state == CREATED || state == DONE || state == CANCELED); } void TSubtaskCompletion::FireCompletionCallback(ITaskBase* task) { - Y_ASSERT(IsComplete()); + Y_ASSERT(IsComplete()); if (!!CompletionFunc) { TSubtaskCompletionFunc temp = CompletionFunc; @@ -130,8 +130,8 @@ void NRainCheck::TSubtaskCompletion::Cancel() { } void TSubtaskCompletion::SetRunning(TTaskRunnerBase* parent) { - Y_ASSERT(!TaskRunner); - Y_ASSERT(!!parent); + Y_ASSERT(!TaskRunner); + Y_ASSERT(!!parent); TaskRunner = parent; @@ -142,7 +142,7 @@ void TSubtaskCompletion::SetRunning(TTaskRunnerBase* parent) { for (;;) { ESubtaskState current = State.Get(); if (current != CREATED && current != DONE) { - Y_FAIL("current state should be CREATED or DONE: %s", ToCString(current)); + Y_FAIL("current state should be CREATED or DONE: %s", ToCString(current)); } if (State.CompareAndSet(current, RUNNING)) { return; @@ -151,7 +151,7 @@ void TSubtaskCompletion::SetRunning(TTaskRunnerBase* parent) { } void TSubtaskCompletion::SetDone() { - Y_ASSERT(!!TaskRunner); + Y_ASSERT(!!TaskRunner); TTaskRunnerBase* temp = TaskRunner; TaskRunner = nullptr; @@ -166,7 +166,7 @@ void TSubtaskCompletion::SetDone() { break; } } else { - Y_FAIL("cannot SetDone: unknown state: %s", ToCString(state)); + Y_FAIL("cannot SetDone: unknown state: %s", ToCString(state)); } } @@ -195,11 +195,11 @@ void NRainCheck::TTaskRunnerBase::ReleaseRef() #endif void TTaskRunnerBase::AssertInThisThread() const { - Y_ASSERT(IsRunningInThisThread()); + Y_ASSERT(IsRunningInThisThread()); } TTaskRunnerBase* TTaskRunnerBase::CurrentTask() { - Y_VERIFY(!!ThreadCurrentTask); + Y_VERIFY(!!ThreadCurrentTask); return ThreadCurrentTask; } diff --git a/library/cpp/messagebus/rain_check/core/track.cpp b/library/cpp/messagebus/rain_check/core/track.cpp index d41f6884ba..092a51a214 100644 --- a/library/cpp/messagebus/rain_check/core/track.cpp +++ b/library/cpp/messagebus/rain_check/core/track.cpp @@ -17,7 +17,7 @@ TTaskTracker::TTaskTracker(NActor::TExecutor* executor) } TTaskTracker::~TTaskTracker() { - Y_ASSERT(Tasks.Empty()); + Y_ASSERT(Tasks.Empty()); } void TTaskTracker::Shutdown() { @@ -36,7 +36,7 @@ void TTaskTracker::ProcessItem(NActor::TDefaultTag, NActor::TDefaultTag, ITaskFa } void TTaskTracker::ProcessItem(NActor::TDefaultTag, NActor::TDefaultTag, TTaskTrackerReceipt* receipt) { - Y_ASSERT(!receipt->Empty()); + Y_ASSERT(!receipt->Empty()); receipt->Unlink(); delete receipt; } diff --git a/library/cpp/messagebus/rain_check/core/track_ut.cpp b/library/cpp/messagebus/rain_check/core/track_ut.cpp index 22b9b65fe1..05f7de1319 100644 --- a/library/cpp/messagebus/rain_check/core/track_ut.cpp +++ b/library/cpp/messagebus/rain_check/core/track_ut.cpp @@ -7,7 +7,7 @@ using namespace NRainCheck; -Y_UNIT_TEST_SUITE(TaskTracker) { +Y_UNIT_TEST_SUITE(TaskTracker) { struct TTaskForTracker: public ISimpleTask { TTestSync* const TestSync; @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TaskTracker) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TTestEnv env; TIntrusivePtr<TTaskTracker> tracker(new TTaskTracker(env.GetExecutor())); diff --git a/library/cpp/messagebus/rain_check/http/client_ut.cpp b/library/cpp/messagebus/rain_check/http/client_ut.cpp index 07941acdf5..1628114391 100644 --- a/library/cpp/messagebus/rain_check/http/client_ut.cpp +++ b/library/cpp/messagebus/rain_check/http/client_ut.cpp @@ -141,10 +141,10 @@ namespace { } // anonymous namespace -Y_UNIT_TEST_SUITE(RainCheckHttpClient) { +Y_UNIT_TEST_SUITE(RainCheckHttpClient) { static const TIpPort SERVER_PORT = 4000; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { // TODO: randomize port if (!IsFixedPortTestAllowed()) { return; @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(RainCheckHttpClient) { env.TestSync.WaitForAndIncrement(1); } - Y_UNIT_TEST(SimplePost) { + Y_UNIT_TEST(SimplePost) { // TODO: randomize port if (!IsFixedPortTestAllowed()) { return; @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(RainCheckHttpClient) { env.TestSync.WaitForAndIncrement(1); } - Y_UNIT_TEST(HttpCodeExtraction) { + Y_UNIT_TEST(HttpCodeExtraction) { // Find "request failed(" string, then copy len("HTTP/1.X NNN") chars and try to convert NNN to HTTP code. #define CHECK_VALID_LINE(line, code) \ diff --git a/library/cpp/messagebus/rain_check/messagebus/messagebus_client.cpp b/library/cpp/messagebus/rain_check/messagebus/messagebus_client.cpp index 6a42e74c25..daac8d9a99 100644 --- a/library/cpp/messagebus/rain_check/messagebus/messagebus_client.cpp +++ b/library/cpp/messagebus/rain_check/messagebus/messagebus_client.cpp @@ -66,7 +66,7 @@ void TBusClientService::OnReply( TAutoPtr<TBusMessage> request, TAutoPtr<TBusMessage> response) { TBusFuture* future = (TBusFuture*)request->Data; - Y_ASSERT(future->Request.Get() == request.Get()); + Y_ASSERT(future->Request.Get() == request.Get()); Y_UNUSED(request.Release()); future->SetDoneAndSchedule(MESSAGE_OK, response); } @@ -74,7 +74,7 @@ void TBusClientService::OnReply( void NRainCheck::TBusClientService::OnMessageSentOneWay( TAutoPtr<NBus::TBusMessage> request) { TBusFuture* future = (TBusFuture*)request->Data; - Y_ASSERT(future->Request.Get() == request.Get()); + Y_ASSERT(future->Request.Get() == request.Get()); Y_UNUSED(request.Release()); future->SetDoneAndSchedule(MESSAGE_OK, nullptr); } @@ -86,7 +86,7 @@ void TBusClientService::OnError( } TBusFuture* future = (TBusFuture*)message->Data; - Y_ASSERT(future->Request.Get() == message.Get()); + Y_ASSERT(future->Request.Get() == message.Get()); Y_UNUSED(message.Release()); future->SetDoneAndSchedule(status, nullptr); } diff --git a/library/cpp/messagebus/rain_check/messagebus/messagebus_client.h b/library/cpp/messagebus/rain_check/messagebus/messagebus_client.h index 6b26755083..0a291cdea6 100644 --- a/library/cpp/messagebus/rain_check/messagebus/messagebus_client.h +++ b/library/cpp/messagebus/rain_check/messagebus/messagebus_client.h @@ -31,12 +31,12 @@ namespace NRainCheck { } NBus::TBusMessage* GetResponse() const { - Y_ASSERT(IsDone()); + Y_ASSERT(IsDone()); return Response.Get(); } NBus::EMessageStatus GetStatus() const { - Y_ASSERT(IsDone()); + Y_ASSERT(IsDone()); return Status; } }; diff --git a/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp b/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp index e0883b49b9..1b3618558b 100644 --- a/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp +++ b/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp @@ -32,7 +32,7 @@ struct TMessageBusClientEnv: public TTestEnvTemplate<TMessageBusClientEnv> { } }; -Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { +Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { struct TSimpleTask: public ISimpleTask { TMessageBusClientEnv* const Env; @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { TContinueFunc GotReplies() { for (unsigned i = 0; i < Requests.size(); ++i) { - Y_VERIFY(Requests[i]->GetStatus() == MESSAGE_OK); + Y_VERIFY(Requests[i]->GetStatus() == MESSAGE_OK); VerifyDynamicCast<TExampleResponse*>(Requests[i]->GetResponse()); } Env->TestSync.CheckAndIncrement(0); @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -124,15 +124,15 @@ Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { TContinueFunc GotReplies() { for (unsigned i = 0; i < Requests.size(); ++i) { - Y_VERIFY(Requests[i]->GetStatus() == MESSAGE_OK); - Y_VERIFY(!Requests[i]->GetResponse()); + Y_VERIFY(Requests[i]->GetStatus() == MESSAGE_OK); + Y_VERIFY(!Requests[i]->GetResponse()); } Env->TestSync.WaitForAndIncrement(2); return nullptr; } }; - Y_UNIT_TEST(OneWay) { + Y_UNIT_TEST(OneWay) { TObjectCountCheck objectCountCheck; TMessageBusClientEnv env; diff --git a/library/cpp/messagebus/rain_check/messagebus/messagebus_server_ut.cpp b/library/cpp/messagebus/rain_check/messagebus/messagebus_server_ut.cpp index af2084762f..7c11399f1b 100644 --- a/library/cpp/messagebus/rain_check/messagebus/messagebus_server_ut.cpp +++ b/library/cpp/messagebus/rain_check/messagebus/messagebus_server_ut.cpp @@ -14,7 +14,7 @@ struct TMessageBusServerEnv: public TTestEnvTemplate<TMessageBusServerEnv> { TExampleProtocol Proto; }; -Y_UNIT_TEST_SUITE(RainCheckMessageBusServer) { +Y_UNIT_TEST_SUITE(RainCheckMessageBusServer) { struct TSimpleServerTask: public ISimpleTask { private: TMessageBusServerEnv* const Env; @@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(RainCheckMessageBusServer) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TMessageBusServerEnv env; THolder<TBusTaskStarter> starter(TBusTaskStarter::NewStarter<TSimpleServerTask>(&env)); diff --git a/library/cpp/messagebus/rain_check/test/helper/misc.cpp b/library/cpp/messagebus/rain_check/test/helper/misc.cpp index e0a88a8ab9..c0fcb27252 100644 --- a/library/cpp/messagebus/rain_check/test/helper/misc.cpp +++ b/library/cpp/messagebus/rain_check/test/helper/misc.cpp @@ -5,7 +5,7 @@ using namespace NRainCheck; void TSpawnNopTasksCoroTask::Run() { - Y_VERIFY(Count <= Completion.size()); + Y_VERIFY(Count <= Completion.size()); for (unsigned i = 0; i < Count; ++i) { SpawnSubtask<TNopCoroTask>(Env, &Completion[i], ""); } @@ -14,7 +14,7 @@ void TSpawnNopTasksCoroTask::Run() { } TContinueFunc TSpawnNopTasksSimpleTask::Start() { - Y_VERIFY(Count <= Completion.size()); + Y_VERIFY(Count <= Completion.size()); for (unsigned i = 0; i < Count; ++i) { SpawnSubtask<TNopSimpleTask>(Env, &Completion[i], ""); } diff --git a/library/cpp/messagebus/rain_check/test/perftest/perftest.cpp b/library/cpp/messagebus/rain_check/test/perftest/perftest.cpp index 5a353da5bb..22edbd8c6b 100644 --- a/library/cpp/messagebus/rain_check/test/perftest/perftest.cpp +++ b/library/cpp/messagebus/rain_check/test/perftest/perftest.cpp @@ -137,8 +137,8 @@ struct TReproduceCrashTask: public ISimpleTask { }; int main(int argc, char** argv) { - Y_UNUSED(argc); - Y_UNUSED(argv); + Y_UNUSED(argc); + Y_UNUSED(argv); TRainCheckPerftestEnv env; diff --git a/library/cpp/messagebus/remote_client_connection.cpp b/library/cpp/messagebus/remote_client_connection.cpp index 9e173706f5..8c7a6db3a8 100644 --- a/library/cpp/messagebus/remote_client_connection.cpp +++ b/library/cpp/messagebus/remote_client_connection.cpp @@ -20,7 +20,7 @@ TRemoteClientConnection::TRemoteClientConnection(TRemoteClientSessionPtr session : TRemoteConnection(session.Get(), id, addr) , ClientHandler(GetSession()->ClientHandler) { - Y_VERIFY(addr.GetPort() > 0, "must connect to non-zero port"); + Y_VERIFY(addr.GetPort() > 0, "must connect to non-zero port"); ScheduleWrite(); } @@ -35,7 +35,7 @@ TBusMessage* TRemoteClientConnection::PopAck(TBusKey id) { SOCKET TRemoteClientConnection::CreateSocket(const TNetAddr& addr) { SOCKET handle = socket(addr.Addr()->sa_family, SOCK_STREAM, 0); - Y_VERIFY(handle != INVALID_SOCKET, "failed to create socket: %s", LastSystemErrorText()); + Y_VERIFY(handle != INVALID_SOCKET, "failed to create socket: %s", LastSystemErrorText()); TSocketHolder s(handle); @@ -61,7 +61,7 @@ void TRemoteClientConnection::TryConnect() { if (AtomicGet(WriterData.Down)) { return; } - Y_VERIFY(!WriterData.Status.Connected); + Y_VERIFY(!WriterData.Status.Connected); TInstant now = TInstant::Now(); @@ -119,8 +119,8 @@ void TRemoteClientConnection::TryConnect() { } void TRemoteClientConnection::HandleEvent(SOCKET socket, void* cookie) { - Y_UNUSED(socket); - Y_ASSERT(cookie == WriteCookie || cookie == ReadCookie); + Y_UNUSED(socket); + Y_ASSERT(cookie == WriteCookie || cookie == ReadCookie); if (cookie == ReadCookie) { ScheduleRead(); } else { @@ -181,18 +181,18 @@ void TRemoteClientConnection::ProcessReplyQueue() { workQueueTemp.GetVector()->reserve(replyQueueTemp.GetVector()->size()); } - for (auto& resp : *replyQueueTemp.GetVector()) { - TBusMessage* req = PopAck(resp.Header.Id); + for (auto& resp : *replyQueueTemp.GetVector()) { + TBusMessage* req = PopAck(resp.Header.Id); if (!req) { - WriterErrorMessage(resp.MessagePtr.Release(), MESSAGE_UNKNOWN); + WriterErrorMessage(resp.MessagePtr.Release(), MESSAGE_UNKNOWN); continue; } if (executeInWorkerPool) { - workQueueTemp.GetVector()->push_back(new TInvokeOnReply(GetSession(), req, resp)); + workQueueTemp.GetVector()->push_back(new TInvokeOnReply(GetSession(), req, resp)); } else { - GetSession()->ReleaseInFlightAndCallOnReply(req, resp); + GetSession()->ReleaseInFlightAndCallOnReply(req, resp); } } @@ -252,11 +252,11 @@ void TRemoteClientConnection::ReaderProcessMessageUnknownVersion(TArrayRef<const LWPROBE(Error, ToString(MESSAGE_INVALID_VERSION), ToString(PeerAddr), ""); ReaderData.Status.Incremental.StatusCounter[MESSAGE_INVALID_VERSION] += 1; // TODO: close connection - Y_FAIL("unknown message"); + Y_FAIL("unknown message"); } void TRemoteClientConnection::ClearOutgoingQueue(TMessagesPtrs& result, bool reconnect) { - Y_ASSERT(result.empty()); + Y_ASSERT(result.empty()); TRemoteConnection::ClearOutgoingQueue(result, reconnect); AckMessages.Clear(&result); @@ -266,26 +266,26 @@ void TRemoteClientConnection::ClearOutgoingQueue(TMessagesPtrs& result, bool rec } void TRemoteClientConnection::MessageSent(TArrayRef<TBusMessagePtrAndHeader> messages) { - for (auto& message : messages) { - bool oneWay = message.LocalFlags & MESSAGE_ONE_WAY_INTERNAL; + for (auto& message : messages) { + bool oneWay = message.LocalFlags & MESSAGE_ONE_WAY_INTERNAL; if (oneWay) { - message.MessagePtr->LocalFlags &= ~MESSAGE_ONE_WAY_INTERNAL; + message.MessagePtr->LocalFlags &= ~MESSAGE_ONE_WAY_INTERNAL; - TBusMessage* ackMsg = this->PopAck(message.Header.Id); + TBusMessage* ackMsg = this->PopAck(message.Header.Id); if (!ackMsg) { // TODO: expired? } - if (ackMsg != message.MessagePtr.Get()) { + if (ackMsg != message.MessagePtr.Get()) { // TODO: non-unique id? } GetSession()->ReleaseInFlight({message.MessagePtr.Get()}); - ClientHandler->OnMessageSentOneWay(message.MessagePtr.Release()); + ClientHandler->OnMessageSentOneWay(message.MessagePtr.Release()); } else { - ClientHandler->OnMessageSent(message.MessagePtr.Get()); - AckMessages.Push(message); + ClientHandler->OnMessageSent(message.MessagePtr.Get()); + AckMessages.Push(message); } } } @@ -306,7 +306,7 @@ EMessageStatus TRemoteClientConnection::SendMessageImpl(TBusMessage* msg, bool w } if (wait) { - Y_VERIFY(!Session->Queue->GetExecutor()->IsInExecutorThread()); + Y_VERIFY(!Session->Queue->GetExecutor()->IsInExecutorThread()); GetSession()->ClientRemoteInFlight.Wait(); } else { if (!GetSession()->ClientRemoteInFlight.TryWait()) { diff --git a/library/cpp/messagebus/remote_client_session.cpp b/library/cpp/messagebus/remote_client_session.cpp index 8fcbf6ba2d..3bc421944f 100644 --- a/library/cpp/messagebus/remote_client_session.cpp +++ b/library/cpp/messagebus/remote_client_session.cpp @@ -34,7 +34,7 @@ void TRemoteClientSession::OnMessageReceived(TRemoteConnection* c, TVectorSwaps< } EMessageStatus TRemoteClientSession::SendMessageImpl(TBusMessage* msg, const TNetAddr* addr, bool wait, bool oneWay) { - if (Y_UNLIKELY(IsDown())) { + if (Y_UNLIKELY(IsDown())) { return MESSAGE_SHUTDOWN; } @@ -47,7 +47,7 @@ EMessageStatus TRemoteClientSession::SendMessageImpl(TBusMessage* msg, const TNe msg->ReplyTo = resolvedAddr; TRemoteConnectionPtr c = ((TBusSessionImpl*)this)->GetConnection(resolvedAddr, true); - Y_ASSERT(!!c); + Y_ASSERT(!!c); return CheckedCast<TRemoteClientConnection*>(c.Get())->SendMessageImpl(msg, wait, oneWay); } @@ -72,24 +72,24 @@ void TRemoteClientSession::FillStatus() { } void TRemoteClientSession::AcquireInFlight(TArrayRef<TBusMessage* const> messages) { - for (auto message : messages) { - Y_ASSERT(!(message->LocalFlags & MESSAGE_IN_FLIGHT_ON_CLIENT)); - message->LocalFlags |= MESSAGE_IN_FLIGHT_ON_CLIENT; + for (auto message : messages) { + Y_ASSERT(!(message->LocalFlags & MESSAGE_IN_FLIGHT_ON_CLIENT)); + message->LocalFlags |= MESSAGE_IN_FLIGHT_ON_CLIENT; } ClientRemoteInFlight.IncrementMultiple(messages.size()); } void TRemoteClientSession::ReleaseInFlight(TArrayRef<TBusMessage* const> messages) { - for (auto message : messages) { - Y_ASSERT(message->LocalFlags & MESSAGE_IN_FLIGHT_ON_CLIENT); - message->LocalFlags &= ~MESSAGE_IN_FLIGHT_ON_CLIENT; + for (auto message : messages) { + Y_ASSERT(message->LocalFlags & MESSAGE_IN_FLIGHT_ON_CLIENT); + message->LocalFlags &= ~MESSAGE_IN_FLIGHT_ON_CLIENT; } ClientRemoteInFlight.ReleaseMultiple(messages.size()); } void TRemoteClientSession::ReleaseInFlightAndCallOnReply(TNonDestroyingAutoPtr<TBusMessage> request, TBusMessagePtrAndHeader& response) { ReleaseInFlight({request.Get()}); - if (Y_UNLIKELY(AtomicGet(Down))) { + if (Y_UNLIKELY(AtomicGet(Down))) { InvokeOnError(request, MESSAGE_SHUTDOWN); InvokeOnError(response.MessagePtr.Release(), MESSAGE_SHUTDOWN); diff --git a/library/cpp/messagebus/remote_client_session_semaphore.cpp b/library/cpp/messagebus/remote_client_session_semaphore.cpp index 573ef402c1..f877ed4257 100644 --- a/library/cpp/messagebus/remote_client_session_semaphore.cpp +++ b/library/cpp/messagebus/remote_client_session_semaphore.cpp @@ -12,12 +12,12 @@ TRemoteClientSessionSemaphore::TRemoteClientSessionSemaphore(TAtomicBase limit, , Current(0) , StopSignal(0) { - Y_VERIFY(limit > 0, "limit must be > 0"); - Y_UNUSED(Name); + Y_VERIFY(limit > 0, "limit must be > 0"); + Y_UNUSED(Name); } TRemoteClientSessionSemaphore::~TRemoteClientSessionSemaphore() { - Y_VERIFY(AtomicGet(Current) == 0); + Y_VERIFY(AtomicGet(Current) == 0); } bool TRemoteClientSessionSemaphore::TryAcquire() { @@ -32,7 +32,7 @@ bool TRemoteClientSessionSemaphore::TryAcquire() { bool TRemoteClientSessionSemaphore::TryWait() { if (AtomicGet(Current) < Limit) return true; - if (Y_UNLIKELY(AtomicGet(StopSignal))) + if (Y_UNLIKELY(AtomicGet(StopSignal))) return true; return false; } diff --git a/library/cpp/messagebus/remote_connection_status.cpp b/library/cpp/messagebus/remote_connection_status.cpp index 34d7973df7..2c48b2a287 100644 --- a/library/cpp/messagebus/remote_connection_status.cpp +++ b/library/cpp/messagebus/remote_connection_status.cpp @@ -25,8 +25,8 @@ static void Max(T& thiz, const T& that) { template <typename T> static void AssertZero(T& thiz, const T& that) { - Y_ASSERT(thiz == T()); - Y_UNUSED(that); + Y_ASSERT(thiz == T()); + Y_UNUSED(that); } TDurationCounter::TDurationCounter() diff --git a/library/cpp/messagebus/remote_server_connection.cpp b/library/cpp/messagebus/remote_server_connection.cpp index d98653f06a..74be34ded9 100644 --- a/library/cpp/messagebus/remote_server_connection.cpp +++ b/library/cpp/messagebus/remote_server_connection.cpp @@ -19,7 +19,7 @@ void TRemoteServerConnection::Init(SOCKET socket, TInstant now) { WriterData.Status.ConnectTime = now; WriterData.Status.Connected = true; - Y_VERIFY(socket != INVALID_SOCKET, "must be a valid socket"); + Y_VERIFY(socket != INVALID_SOCKET, "must be a valid socket"); TSocket readSocket(socket); TSocket writeSocket = readSocket; @@ -37,8 +37,8 @@ TRemoteServerSession* TRemoteServerConnection::GetSession() { } void TRemoteServerConnection::HandleEvent(SOCKET socket, void* cookie) { - Y_UNUSED(socket); - Y_ASSERT(cookie == ReadCookie || cookie == WriteCookie); + Y_UNUSED(socket); + Y_ASSERT(cookie == ReadCookie || cookie == WriteCookie); if (cookie == ReadCookie) { GetSession()->ServerOwnedMessages.Wait(); ScheduleRead(); @@ -55,9 +55,9 @@ void TRemoteServerConnection::MessageSent(TArrayRef<TBusMessagePtrAndHeader> mes TInstant now = TInstant::Now(); GetSession()->ReleaseInWorkResponses(messages); - for (auto& message : messages) { - TInstant recvTime = message.MessagePtr->RecvTime; - GetSession()->ServerHandler->OnSent(message.MessagePtr.Release()); + for (auto& message : messages) { + TInstant recvTime = message.MessagePtr->RecvTime; + GetSession()->ServerHandler->OnSent(message.MessagePtr.Release()); TDuration d = now - recvTime; WriterData.Status.DurationCounter.AddDuration(d); WriterData.Status.Incremental.ProcessDurationHistogram.AddTime(d); diff --git a/library/cpp/messagebus/remote_server_session.cpp b/library/cpp/messagebus/remote_server_session.cpp index 12f5408ea9..6abbf88a60 100644 --- a/library/cpp/messagebus/remote_server_session.cpp +++ b/library/cpp/messagebus/remote_server_session.cpp @@ -69,13 +69,13 @@ void TRemoteServerSession::OnMessageReceived(TRemoteConnection* c, TVectorSwaps< workQueueTemp.GetVector()->reserve(messages.size()); } - for (auto& message : messages) { + for (auto& message : messages) { // TODO: incref once TIntrusivePtr<TRemoteServerConnection> connection(CheckedCast<TRemoteServerConnection*>(c)); if (executeInPool) { - workQueueTemp.GetVector()->push_back(new TInvokeOnMessage(this, message, connection)); + workQueueTemp.GetVector()->push_back(new TInvokeOnMessage(this, message, connection)); } else { - InvokeOnMessage(message, connection); + InvokeOnMessage(message, connection); } } @@ -86,7 +86,7 @@ void TRemoteServerSession::OnMessageReceived(TRemoteConnection* c, TVectorSwaps< } void TRemoteServerSession::InvokeOnMessage(TBusMessagePtrAndHeader& request, TIntrusivePtr<TRemoteServerConnection>& conn) { - if (Y_UNLIKELY(AtomicGet(Down))) { + if (Y_UNLIKELY(AtomicGet(Down))) { ReleaseInWorkRequests(*conn.Get(), request.MessagePtr.Get()); InvokeOnError(request.MessagePtr.Release(), MESSAGE_SHUTDOWN); } else { @@ -97,7 +97,7 @@ void TRemoteServerSession::InvokeOnMessage(TBusMessagePtrAndHeader& request, TIn ident.Connection.Swap(conn); request.MessagePtr->GetIdentity(ident); - Y_ASSERT(request.MessagePtr->LocalFlags & MESSAGE_IN_WORK); + Y_ASSERT(request.MessagePtr->LocalFlags & MESSAGE_IN_WORK); DoSwap(request.MessagePtr->LocalFlags, ident.LocalFlags); ident.RecvTime = request.MessagePtr->RecvTime; @@ -146,7 +146,7 @@ void TRemoteServerSession::FillStatus() { void TRemoteServerSession::AcquireInWorkRequests(TArrayRef<const TBusMessagePtrAndHeader> messages) { TAtomicBase size = 0; for (auto message = messages.begin(); message != messages.end(); ++message) { - Y_ASSERT(!(message->MessagePtr->LocalFlags & MESSAGE_IN_WORK)); + Y_ASSERT(!(message->MessagePtr->LocalFlags & MESSAGE_IN_WORK)); message->MessagePtr->LocalFlags |= MESSAGE_IN_WORK; size += message->MessagePtr->GetHeader()->Size; } @@ -157,7 +157,7 @@ void TRemoteServerSession::AcquireInWorkRequests(TArrayRef<const TBusMessagePtrA void TRemoteServerSession::ReleaseInWorkResponses(TArrayRef<const TBusMessagePtrAndHeader> responses) { TAtomicBase size = 0; for (auto response = responses.begin(); response != responses.end(); ++response) { - Y_ASSERT((response->MessagePtr->LocalFlags & MESSAGE_REPLY_IS_BEGING_SENT)); + Y_ASSERT((response->MessagePtr->LocalFlags & MESSAGE_REPLY_IS_BEGING_SENT)); response->MessagePtr->LocalFlags &= ~MESSAGE_REPLY_IS_BEGING_SENT; size += response->MessagePtr->RequestSize; } @@ -166,7 +166,7 @@ void TRemoteServerSession::ReleaseInWorkResponses(TArrayRef<const TBusMessagePtr } void TRemoteServerSession::ReleaseInWorkRequests(TRemoteConnection& con, TBusMessage* request) { - Y_ASSERT((request->LocalFlags & MESSAGE_IN_WORK)); + Y_ASSERT((request->LocalFlags & MESSAGE_IN_WORK)); request->LocalFlags &= ~MESSAGE_IN_WORK; const size_t size = request->GetHeader()->Size; @@ -186,7 +186,7 @@ void TRemoteServerSession::ConvertInWork(TBusIdentity& req, TBusMessage* reply) reply->SetIdentity(req); req.SetInWork(false); - Y_ASSERT(!(reply->LocalFlags & MESSAGE_REPLY_IS_BEGING_SENT)); + Y_ASSERT(!(reply->LocalFlags & MESSAGE_REPLY_IS_BEGING_SENT)); reply->LocalFlags |= MESSAGE_REPLY_IS_BEGING_SENT; reply->RequestSize = req.Size; } @@ -201,6 +201,6 @@ void TRemoteServerSession::PauseInput(bool pause) { } unsigned TRemoteServerSession::GetActualListenPort() { - Y_VERIFY(Config.ListenPort > 0, "state check"); + Y_VERIFY(Config.ListenPort > 0, "state check"); return Config.ListenPort; } diff --git a/library/cpp/messagebus/remote_server_session_semaphore.cpp b/library/cpp/messagebus/remote_server_session_semaphore.cpp index 1d074dbcb7..6094a3586e 100644 --- a/library/cpp/messagebus/remote_server_session_semaphore.cpp +++ b/library/cpp/messagebus/remote_server_session_semaphore.cpp @@ -16,18 +16,18 @@ TRemoteServerSessionSemaphore::TRemoteServerSessionSemaphore( , PausedByUser(0) , StopSignal(0) { - Y_VERIFY(limitCount > 0, "limit must be > 0"); - Y_UNUSED(Name); + Y_VERIFY(limitCount > 0, "limit must be > 0"); + Y_UNUSED(Name); } TRemoteServerSessionSemaphore::~TRemoteServerSessionSemaphore() { - Y_VERIFY(AtomicGet(CurrentCount) == 0); + Y_VERIFY(AtomicGet(CurrentCount) == 0); // TODO: fix spider and enable - //Y_VERIFY(AtomicGet(CurrentSize) == 0); + //Y_VERIFY(AtomicGet(CurrentSize) == 0); } bool TRemoteServerSessionSemaphore::TryWait() { - if (Y_UNLIKELY(AtomicGet(StopSignal))) + if (Y_UNLIKELY(AtomicGet(StopSignal))) return true; if (AtomicGet(PausedByUser)) return false; diff --git a/library/cpp/messagebus/scheduler/scheduler.cpp b/library/cpp/messagebus/scheduler/scheduler.cpp index 506af354e6..5a5fe52894 100644 --- a/library/cpp/messagebus/scheduler/scheduler.cpp +++ b/library/cpp/messagebus/scheduler/scheduler.cpp @@ -23,7 +23,7 @@ TScheduler::TScheduler() } TScheduler::~TScheduler() { - Y_VERIFY(StopThread, "state check"); + Y_VERIFY(StopThread, "state check"); } size_t TScheduler::Size() const { @@ -34,7 +34,7 @@ size_t TScheduler::Size() const { void TScheduler::Stop() { { TGuard<TLock> guard(Lock); - Y_VERIFY(!StopThread, "Scheduler already stopped"); + Y_VERIFY(!StopThread, "Scheduler already stopped"); StopThread = true; CondVar.Signal(); } @@ -44,8 +44,8 @@ void TScheduler::Stop() { NextItem.Destroy(); } - for (auto& item : Items) { - item.Destroy(); + for (auto& item : Items) { + item.Destroy(); } } @@ -98,7 +98,7 @@ void TScheduler::SchedulerThread() { } // signal comes if either scheduler is to be stopped of there's work to do - Y_VERIFY(!!NextItem, "state check"); + Y_VERIFY(!!NextItem, "state check"); if (TInstant::Now() < NextItem->GetScheduleTime()) { // NextItem is updated since WaitD diff --git a/library/cpp/messagebus/scheduler/scheduler_ut.cpp b/library/cpp/messagebus/scheduler/scheduler_ut.cpp index afe89e9263..a5ea641c10 100644 --- a/library/cpp/messagebus/scheduler/scheduler_ut.cpp +++ b/library/cpp/messagebus/scheduler/scheduler_ut.cpp @@ -7,7 +7,7 @@ using namespace NBus; using namespace NBus::NPrivate; -Y_UNIT_TEST_SUITE(TSchedulerTests) { +Y_UNIT_TEST_SUITE(TSchedulerTests) { struct TSimpleScheduleItem: public IScheduleItem { TTestSync* const TestSync; @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TSchedulerTests) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TTestSync testSync; TScheduler scheduler; diff --git a/library/cpp/messagebus/scheduler_actor_ut.cpp b/library/cpp/messagebus/scheduler_actor_ut.cpp index c885e40f59..e81ffd3186 100644 --- a/library/cpp/messagebus/scheduler_actor_ut.cpp +++ b/library/cpp/messagebus/scheduler_actor_ut.cpp @@ -7,7 +7,7 @@ using namespace NBus; using namespace NBus::NPrivate; using namespace NActor; -Y_UNIT_TEST_SUITE(TSchedulerActorTests) { +Y_UNIT_TEST_SUITE(TSchedulerActorTests) { struct TMyActor: public TAtomicRefCount<TMyActor>, public TActor<TMyActor>, public TScheduleActor<TMyActor> { TTestSync TestSync; @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TSchedulerActorTests) { void Act(TDefaultTag) { if (!Alarm.FetchTask()) { - Y_FAIL("must not have no spurious wakeups in test"); + Y_FAIL("must not have no spurious wakeups in test"); } TestSync.WaitForAndIncrement(Iteration++); @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TSchedulerActorTests) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TExecutor executor(1); TScheduler scheduler; diff --git a/library/cpp/messagebus/session_impl.cpp b/library/cpp/messagebus/session_impl.cpp index 1552ee775f..ddf9f360c4 100644 --- a/library/cpp/messagebus/session_impl.cpp +++ b/library/cpp/messagebus/session_impl.cpp @@ -58,28 +58,28 @@ namespace { copy.TotalTimeout = TDuration::Seconds(60).MilliSeconds(); copy.SendTimeout = TDuration::Seconds(15).MilliSeconds(); } else if (copy.TotalTimeout == 0) { - Y_ASSERT(copy.SendTimeout != 0); + Y_ASSERT(copy.SendTimeout != 0); copy.TotalTimeout = config.SendTimeout + TDuration::MilliSeconds(10).MilliSeconds(); } else if (copy.SendTimeout == 0) { - Y_ASSERT(copy.TotalTimeout != 0); + Y_ASSERT(copy.TotalTimeout != 0); if ((ui64)copy.TotalTimeout > (ui64)TDuration::MilliSeconds(10).MilliSeconds()) { copy.SendTimeout = copy.TotalTimeout - TDuration::MilliSeconds(10).MilliSeconds(); } else { copy.SendTimeout = copy.TotalTimeout; } } else { - Y_ASSERT(copy.TotalTimeout != 0); - Y_ASSERT(copy.SendTimeout != 0); + Y_ASSERT(copy.TotalTimeout != 0); + Y_ASSERT(copy.SendTimeout != 0); } if (copy.ConnectTimeout == 0) { copy.ConnectTimeout = copy.SendTimeout; } - Y_VERIFY(copy.SendTimeout > 0, "SendTimeout must be > 0"); - Y_VERIFY(copy.TotalTimeout > 0, "TotalTimeout must be > 0"); - Y_VERIFY(copy.ConnectTimeout > 0, "ConnectTimeout must be > 0"); - Y_VERIFY(copy.TotalTimeout >= copy.SendTimeout, "TotalTimeout must be >= SendTimeout"); + Y_VERIFY(copy.SendTimeout > 0, "SendTimeout must be > 0"); + Y_VERIFY(copy.TotalTimeout > 0, "TotalTimeout must be > 0"); + Y_VERIFY(copy.ConnectTimeout > 0, "ConnectTimeout must be > 0"); + Y_VERIFY(copy.TotalTimeout >= copy.SendTimeout, "TotalTimeout must be >= SendTimeout"); if (!copy.Name) { copy.Name = name; @@ -117,10 +117,10 @@ TBusSessionImpl::TBusSessionImpl(bool isSource, TBusMessageQueue* queue, TBusPro } TBusSessionImpl::~TBusSessionImpl() { - Y_VERIFY(Down); - Y_VERIFY(ShutdownCompleteEvent.WaitT(TDuration::Zero())); - Y_VERIFY(!WriteEventLoop.IsRunning()); - Y_VERIFY(!ReadEventLoop.IsRunning()); + Y_VERIFY(Down); + Y_VERIFY(ShutdownCompleteEvent.WaitT(TDuration::Zero())); + Y_VERIFY(!WriteEventLoop.IsRunning()); + Y_VERIFY(!ReadEventLoop.IsRunning()); } TBusSessionStatus::TBusSessionStatus() @@ -136,7 +136,7 @@ void TBusSessionImpl::Shutdown() { return; } - Y_VERIFY(Queue->IsRunning(), "Session must be shut down prior to queue shutdown"); + Y_VERIFY(Queue->IsRunning(), "Session must be shut down prior to queue shutdown"); TUseAfterFreeCheckerGuard handlerAliveCheckedGuard(ErrorHandler->UseAfterFreeChecker); @@ -161,16 +161,16 @@ void TBusSessionImpl::Shutdown() { Acceptors.clear(); } - for (auto& acceptor : acceptors) { - acceptor->Shutdown(); + for (auto& acceptor : acceptors) { + acceptor->Shutdown(); } // shutdown connections TVector<TRemoteConnectionPtr> cs; GetConnections(&cs); - for (auto& c : cs) { - c->Shutdown(MESSAGE_SHUTDOWN); + for (auto& c : cs) { + c->Shutdown(MESSAGE_SHUTDOWN); } // shutdown connections actor @@ -205,7 +205,7 @@ size_t TBusSessionImpl::GetInFlightImpl(const TNetAddr& addr) const { } void TBusSessionImpl::GetInFlightBulk(TArrayRef<const TNetAddr> addrs, TArrayRef<size_t> results) const { - Y_VERIFY(addrs.size() == results.size(), "input.size != output.size"); + Y_VERIFY(addrs.size() == results.size(), "input.size != output.size"); for (size_t i = 0; i < addrs.size(); ++i) { results[i] = GetInFlightImpl(addrs[i]); } @@ -221,7 +221,7 @@ size_t TBusSessionImpl::GetConnectSyscallsNumForTestImpl(const TNetAddr& addr) c } void TBusSessionImpl::GetConnectSyscallsNumBulkForTest(TArrayRef<const TNetAddr> addrs, TArrayRef<size_t> results) const { - Y_VERIFY(addrs.size() == results.size(), "input.size != output.size"); + Y_VERIFY(addrs.size() == results.size(), "input.size != output.size"); for (size_t i = 0; i < addrs.size(); ++i) { results[i] = GetConnectSyscallsNumForTestImpl(addrs[i]); } @@ -232,7 +232,7 @@ void TBusSessionImpl::FillStatus() { TSessionDumpStatus TBusSessionImpl::GetStatusRecordInternal() { // Probably useless, because it returns cached info now - Y_VERIFY(!Queue->GetExecutor()->IsInExecutorThread(), + Y_VERIFY(!Queue->GetExecutor()->IsInExecutorThread(), "GetStatus must not be called from executor thread"); TGuard<TMutex> guard(StatusData.StatusDumpCachedMutex); @@ -242,13 +242,13 @@ TSessionDumpStatus TBusSessionImpl::GetStatusRecordInternal() { } TString TBusSessionImpl::GetStatus(ui16 flags) { - Y_UNUSED(flags); + Y_UNUSED(flags); return GetStatusRecordInternal().PrintToString(); } TConnectionStatusMonRecord TBusSessionImpl::GetStatusProtobuf() { - Y_VERIFY(!Queue->GetExecutor()->IsInExecutorThread(), + Y_VERIFY(!Queue->GetExecutor()->IsInExecutorThread(), "GetStatus must not be called from executor thread"); TGuard<TMutex> guard(StatusData.StatusDumpCachedMutex); @@ -319,12 +319,12 @@ void TBusSessionImpl::ProcessItem(TConnectionTag, TRemoveTag, TRemoteConnectionP void TBusSessionImpl::ProcessConnectionsAcceptorsShapshotQueueItem(TAtomicSharedPtr<TConnectionsAcceptorsSnapshot> snapshot) { for (TVector<TRemoteConnectionPtr>::const_iterator connection = snapshot->Connections.begin(); connection != snapshot->Connections.end(); ++connection) { - Y_ASSERT((*connection)->ConnectionId <= snapshot->LastConnectionId); + Y_ASSERT((*connection)->ConnectionId <= snapshot->LastConnectionId); } for (TVector<TAcceptorPtr>::const_iterator acceptor = snapshot->Acceptors.begin(); acceptor != snapshot->Acceptors.end(); ++acceptor) { - Y_ASSERT((*acceptor)->AcceptorId <= snapshot->LastAcceptorId); + Y_ASSERT((*acceptor)->AcceptorId <= snapshot->LastAcceptorId); } StatusData.ConnectionsAcceptorsSnapshot = snapshot; @@ -471,8 +471,8 @@ void TBusSessionImpl::Act(TConnectionTag) { EShutdownState shutdownState = ConnectionsData.ShutdownState.State.Get(); if (shutdownState == SS_SHUTDOWN_COMPLETE) { - Y_VERIFY(GetRemoveConnectionQueue()->IsEmpty()); - Y_VERIFY(GetOnAcceptQueue()->IsEmpty()); + Y_VERIFY(GetRemoveConnectionQueue()->IsEmpty()); + Y_VERIFY(GetOnAcceptQueue()->IsEmpty()); } GetRemoveConnectionQueue()->DequeueAllLikelyEmpty(); @@ -488,7 +488,7 @@ void TBusSessionImpl::Listen(int port, TBusMessageQueue* q) { } void TBusSessionImpl::Listen(const TVector<TBindResult>& bindTo, TBusMessageQueue* q) { - Y_ASSERT(q == Queue); + Y_ASSERT(q == Queue); int actualPort = -1; for (const TBindResult& br : bindTo) { @@ -511,7 +511,7 @@ void TBusSessionImpl::Listen(const TVector<TBindResult>& bindTo, TBusMessageQueu } void TBusSessionImpl::SendSnapshotToStatusActor() { - //Y_ASSERT(ConnectionsLock.IsLocked()); + //Y_ASSERT(ConnectionsLock.IsLocked()); TAtomicSharedPtr<TConnectionsAcceptorsSnapshot> snapshot(new TConnectionsAcceptorsSnapshot); GetAcceptorsLockAquired(&snapshot->Acceptors); @@ -523,7 +523,7 @@ void TBusSessionImpl::SendSnapshotToStatusActor() { } void TBusSessionImpl::InsertConnectionLockAcquired(TRemoteConnection* connection) { - //Y_ASSERT(ConnectionsLock.IsLocked()); + //Y_ASSERT(ConnectionsLock.IsLocked()); Connections.insert(std::make_pair(connection->PeerAddrSocketAddr, connection)); // connection for given adds may already exist at this point @@ -531,13 +531,13 @@ void TBusSessionImpl::InsertConnectionLockAcquired(TRemoteConnection* connection // after reconnect, if previous connections wasn't shutdown yet bool inserted2 = ConnectionsById.insert(std::make_pair(connection->ConnectionId, connection)).second; - Y_VERIFY(inserted2, "state check: must be inserted (2)"); + Y_VERIFY(inserted2, "state check: must be inserted (2)"); SendSnapshotToStatusActor(); } void TBusSessionImpl::InsertAcceptorLockAcquired(TAcceptor* acceptor) { - //Y_ASSERT(ConnectionsLock.IsLocked()); + //Y_ASSERT(ConnectionsLock.IsLocked()); Acceptors.push_back(acceptor); @@ -555,22 +555,22 @@ void TBusSessionImpl::GetAcceptors(TVector<TAcceptorPtr>* r) { } void TBusSessionImpl::GetConnectionsLockAquired(TVector<TRemoteConnectionPtr>* r) { - //Y_ASSERT(ConnectionsLock.IsLocked()); + //Y_ASSERT(ConnectionsLock.IsLocked()); r->reserve(Connections.size()); - for (auto& connection : Connections) { - r->push_back(connection.second); + for (auto& connection : Connections) { + r->push_back(connection.second); } } void TBusSessionImpl::GetAcceptorsLockAquired(TVector<TAcceptorPtr>* r) { - //Y_ASSERT(ConnectionsLock.IsLocked()); + //Y_ASSERT(ConnectionsLock.IsLocked()); r->reserve(Acceptors.size()); - for (auto& acceptor : Acceptors) { - r->push_back(acceptor); + for (auto& acceptor : Acceptors) { + r->push_back(acceptor); } } @@ -588,9 +588,9 @@ TRemoteConnectionPtr TBusSessionImpl::GetConnectionById(ui64 id) { TAcceptorPtr TBusSessionImpl::GetAcceptorById(ui64 id) { TGuard<TMutex> guard(ConnectionsLock); - for (const auto& Acceptor : Acceptors) { - if (Acceptor->AcceptorId == id) { - return Acceptor; + for (const auto& Acceptor : Acceptors) { + if (Acceptor->AcceptorId == id) { + return Acceptor; } } @@ -614,7 +614,7 @@ TRemoteConnectionPtr TBusSessionImpl::GetConnection(const TBusSocketAddr& addr, return TRemoteConnectionPtr(); } - Y_VERIFY(IsSource_, "must be source"); + Y_VERIFY(IsSource_, "must be source"); TRemoteConnectionPtr c(new TRemoteClientConnection(VerifyDynamicCast<TRemoteClientSession*>(this), ++LastConnectionId, addr.ToNetAddr())); InsertConnectionLockAcquired(c.Get()); @@ -626,8 +626,8 @@ void TBusSessionImpl::Cron() { TVector<TRemoteConnectionPtr> connections; GetConnections(&connections); - for (const auto& it : connections) { - TRemoteConnection* connection = it.Get(); + for (const auto& it : connections) { + TRemoteConnection* connection = it.Get(); if (IsSource_) { VerifyDynamicCast<TRemoteClientConnection*>(connection)->ScheduleTimeoutMessages(); } else { diff --git a/library/cpp/messagebus/session_job_count.cpp b/library/cpp/messagebus/session_job_count.cpp index 525bb1b1ef..33322b1910 100644 --- a/library/cpp/messagebus/session_job_count.cpp +++ b/library/cpp/messagebus/session_job_count.cpp @@ -11,7 +11,7 @@ TBusSessionJobCount::TBusSessionJobCount() } TBusSessionJobCount::~TBusSessionJobCount() { - Y_VERIFY(JobCount == 0, "must be 0 job count to destroy job"); + Y_VERIFY(JobCount == 0, "must be 0 job count to destroy job"); } void TBusSessionJobCount::WaitForZero() { diff --git a/library/cpp/messagebus/shutdown_state.cpp b/library/cpp/messagebus/shutdown_state.cpp index ce206a9772..a4e2bfa8b2 100644 --- a/library/cpp/messagebus/shutdown_state.cpp +++ b/library/cpp/messagebus/shutdown_state.cpp @@ -3,11 +3,11 @@ #include <util/system/yassert.h> void TAtomicShutdownState::ShutdownCommand() { - Y_VERIFY(State.CompareAndSet(SS_RUNNING, SS_SHUTDOWN_COMMAND)); + Y_VERIFY(State.CompareAndSet(SS_RUNNING, SS_SHUTDOWN_COMMAND)); } void TAtomicShutdownState::CompleteShutdown() { - Y_VERIFY(State.CompareAndSet(SS_SHUTDOWN_COMMAND, SS_SHUTDOWN_COMPLETE)); + Y_VERIFY(State.CompareAndSet(SS_SHUTDOWN_COMMAND, SS_SHUTDOWN_COMPLETE)); ShutdownComplete.Signal(); } @@ -16,5 +16,5 @@ bool TAtomicShutdownState::IsRunning() { } TAtomicShutdownState::~TAtomicShutdownState() { - Y_VERIFY(SS_SHUTDOWN_COMPLETE == State.Get()); + Y_VERIFY(SS_SHUTDOWN_COMPLETE == State.Get()); } diff --git a/library/cpp/messagebus/socket_addr.cpp b/library/cpp/messagebus/socket_addr.cpp index 2e88494920..c1b3a28fbe 100644 --- a/library/cpp/messagebus/socket_addr.cpp +++ b/library/cpp/messagebus/socket_addr.cpp @@ -74,6 +74,6 @@ TNetAddr NBus::NPrivate::TBusSocketAddr::ToNetAddr() const { } template <> -void Out<TBusSocketAddr>(IOutputStream& out, const TBusSocketAddr& addr) { +void Out<TBusSocketAddr>(IOutputStream& out, const TBusSocketAddr& addr) { out << addr.ToNetAddr(); } diff --git a/library/cpp/messagebus/socket_addr_ut.cpp b/library/cpp/messagebus/socket_addr_ut.cpp index 3f90d8d775..783bb62a86 100644 --- a/library/cpp/messagebus/socket_addr_ut.cpp +++ b/library/cpp/messagebus/socket_addr_ut.cpp @@ -8,8 +8,8 @@ using namespace NBus; using namespace NBus::NPrivate; -Y_UNIT_TEST_SUITE(TBusSocketAddr) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TBusSocketAddr) { + Y_UNIT_TEST(Simple) { UNIT_ASSERT_VALUES_EQUAL(TString("127.0.0.1:80"), ToString(TBusSocketAddr("127.0.0.1", 80))); } } diff --git a/library/cpp/messagebus/synchandler.cpp b/library/cpp/messagebus/synchandler.cpp index 5ae9adc39c..8e891d66b3 100644 --- a/library/cpp/messagebus/synchandler.cpp +++ b/library/cpp/messagebus/synchandler.cpp @@ -58,12 +58,12 @@ public: } void OnMessageSent(TBusMessage* pMessage) override { - Y_UNUSED(pMessage); - Y_ASSERT(ExpectReply); + Y_UNUSED(pMessage); + Y_ASSERT(ExpectReply); } void OnMessageSentOneWay(TAutoPtr<TBusMessage> pMessage) override { - Y_ASSERT(!ExpectReply); + Y_ASSERT(!ExpectReply); TBusSyncMessageData* data = static_cast<TBusSyncMessageData*>(pMessage.Release()->Data); SignalResult(data, /*pReply=*/nullptr, MESSAGE_OK); } @@ -76,7 +76,7 @@ public: private: void SignalResult(TBusSyncMessageData* data, TBusMessage* pReply, EMessageStatus status) const { - Y_VERIFY(data, "Message data is set to NULL."); + Y_VERIFY(data, "Message data is set to NULL."); TGuard<TMutex> G(data->ReplyLock); data->Reply = pReply; data->ReplyStatus = status; diff --git a/library/cpp/messagebus/test/example/client/client.cpp b/library/cpp/messagebus/test/example/client/client.cpp index 5e18fd8990..89b5f2c9be 100644 --- a/library/cpp/messagebus/test/example/client/client.cpp +++ b/library/cpp/messagebus/test/example/client/client.cpp @@ -23,7 +23,7 @@ namespace NCalculator { } void OnReply(TAutoPtr<TBusMessage> request, TAutoPtr<TBusMessage> response0) override { - Y_VERIFY(response0->GetHeader()->Type == TResponse::MessageType, "wrong response"); + Y_VERIFY(response0->GetHeader()->Type == TResponse::MessageType, "wrong response"); TResponse* response = VerifyDynamicCast<TResponse*>(response0.Get()); if (request->GetHeader()->Type == TRequestSum::MessageType) { TRequestSum* requestSum = VerifyDynamicCast<TRequestSum*>(request.Get()); @@ -36,7 +36,7 @@ namespace NCalculator { int b = requestMul->Record.GetB(); Cerr << a << " * " << b << " = " << response->Record.GetResult() << "\n"; } else { - Y_FAIL("unknown request"); + Y_FAIL("unknown request"); } } diff --git a/library/cpp/messagebus/test/example/server/server.cpp b/library/cpp/messagebus/test/example/server/server.cpp index 27d427491b..13e52d75f5 100644 --- a/library/cpp/messagebus/test/example/server/server.cpp +++ b/library/cpp/messagebus/test/example/server/server.cpp @@ -39,7 +39,7 @@ namespace NCalculator { response->Record.SetResult(result); request.SendReplyMove(response); } else { - Y_FAIL("unknown request"); + Y_FAIL("unknown request"); } } }; diff --git a/library/cpp/messagebus/test/helper/alloc_counter.h b/library/cpp/messagebus/test/helper/alloc_counter.h index 0f7631166b..ec9041cb15 100644 --- a/library/cpp/messagebus/test/helper/alloc_counter.h +++ b/library/cpp/messagebus/test/helper/alloc_counter.h @@ -16,6 +16,6 @@ public: } ~TAllocCounter() { - Y_VERIFY(AtomicDecrement(*CountPtr) >= 0, "released too many"); + Y_VERIFY(AtomicDecrement(*CountPtr) >= 0, "released too many"); } }; diff --git a/library/cpp/messagebus/test/helper/example.cpp b/library/cpp/messagebus/test/helper/example.cpp index 07b8e47c74..7c6d704042 100644 --- a/library/cpp/messagebus/test/helper/example.cpp +++ b/library/cpp/messagebus/test/helper/example.cpp @@ -68,11 +68,11 @@ TExampleProtocol::~TExampleProtocol() { // so it could be reported in test return; } - Y_VERIFY(0 == AtomicGet(RequestCount), "protocol %s: must be 0 requests allocated, actually %d", GetService(), int(RequestCount)); - Y_VERIFY(0 == AtomicGet(ResponseCount), "protocol %s: must be 0 responses allocated, actually %d", GetService(), int(ResponseCount)); - Y_VERIFY(0 == AtomicGet(RequestCountDeserialized), "protocol %s: must be 0 requests deserialized allocated, actually %d", GetService(), int(RequestCountDeserialized)); - Y_VERIFY(0 == AtomicGet(ResponseCountDeserialized), "protocol %s: must be 0 responses deserialized allocated, actually %d", GetService(), int(ResponseCountDeserialized)); - Y_VERIFY(0 == AtomicGet(StartCount), "protocol %s: must be 0 start objects allocated, actually %d", GetService(), int(StartCount)); + Y_VERIFY(0 == AtomicGet(RequestCount), "protocol %s: must be 0 requests allocated, actually %d", GetService(), int(RequestCount)); + Y_VERIFY(0 == AtomicGet(ResponseCount), "protocol %s: must be 0 responses allocated, actually %d", GetService(), int(ResponseCount)); + Y_VERIFY(0 == AtomicGet(RequestCountDeserialized), "protocol %s: must be 0 requests deserialized allocated, actually %d", GetService(), int(RequestCountDeserialized)); + Y_VERIFY(0 == AtomicGet(ResponseCountDeserialized), "protocol %s: must be 0 responses deserialized allocated, actually %d", GetService(), int(ResponseCountDeserialized)); + Y_VERIFY(0 == AtomicGet(StartCount), "protocol %s: must be 0 start objects allocated, actually %d", GetService(), int(StartCount)); } void TExampleProtocol::Serialize(const TBusMessage* message, TBuffer& buffer) { @@ -83,13 +83,13 @@ void TExampleProtocol::Serialize(const TBusMessage* message, TBuffer& buffer) { } else if (const TExampleResponse* exampleReply = dynamic_cast<const TExampleResponse*>(message)) { buffer.Append(exampleReply->Data.data(), exampleReply->Data.size()); } else { - Y_FAIL("unknown message type"); + Y_FAIL("unknown message type"); } } TAutoPtr<TBusMessage> TExampleProtocol::Deserialize(ui16 messageType, TArrayRef<const char> payload) { // TODO: check data - Y_UNUSED(payload); + Y_UNUSED(payload); if (messageType == 77) { TExampleRequest* exampleMessage = new TExampleRequest(MESSAGE_CREATE_UNINITIALIZED, &RequestCountDeserialized); @@ -194,8 +194,8 @@ void TExampleClient::SendMessagesWaitReplies(size_t count, const TNetAddr& addr) } void TExampleClient::OnReply(TAutoPtr<TBusMessage> mess, TAutoPtr<TBusMessage> reply) { - Y_UNUSED(mess); - Y_UNUSED(reply); + Y_UNUSED(mess); + Y_UNUSED(reply); if (AtomicIncrement(RepliesCount) == MessageCount) { WorkDone.Signal(); @@ -204,10 +204,10 @@ void TExampleClient::OnReply(TAutoPtr<TBusMessage> mess, TAutoPtr<TBusMessage> r void TExampleClient::OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) { if (CrashOnError) { - Y_FAIL("client failed: %s", ToCString(status)); + Y_FAIL("client failed: %s", ToCString(status)); } - Y_UNUSED(mess); + Y_UNUSED(mess); AtomicIncrement(Errors); LastError = status; diff --git a/library/cpp/messagebus/test/helper/message_handler_error.cpp b/library/cpp/messagebus/test/helper/message_handler_error.cpp index 421e0ce397..c09811ec67 100644 --- a/library/cpp/messagebus/test/helper/message_handler_error.cpp +++ b/library/cpp/messagebus/test/helper/message_handler_error.cpp @@ -10,11 +10,11 @@ void TBusClientHandlerError::OnError(TAutoPtr<TBusMessage>, EMessageStatus statu } void TBusClientHandlerError::OnReply(TAutoPtr<TBusMessage>, TAutoPtr<TBusMessage>) { - Y_FAIL("must not be called"); + Y_FAIL("must not be called"); } void TBusClientHandlerError::OnMessageSentOneWay(TAutoPtr<TBusMessage>) { - Y_FAIL("must not be called"); + Y_FAIL("must not be called"); } void TBusServerHandlerError::OnError(TAutoPtr<TBusMessage>, EMessageStatus status) { @@ -22,5 +22,5 @@ void TBusServerHandlerError::OnError(TAutoPtr<TBusMessage>, EMessageStatus statu } void TBusServerHandlerError::OnMessage(TOnMessageContext&) { - Y_FAIL("must not be called"); + Y_FAIL("must not be called"); } diff --git a/library/cpp/messagebus/test/perftest/perftest.cpp b/library/cpp/messagebus/test/perftest/perftest.cpp index de1ee427a2..8489319278 100644 --- a/library/cpp/messagebus/test/perftest/perftest.cpp +++ b/library/cpp/messagebus/test/perftest/perftest.cpp @@ -150,7 +150,7 @@ TAutoPtr<TBusMessage> NewRequest() { void CheckRequest(TPerftestRequest* request) { const TString& data = request->Record.GetData(); for (size_t i = 0; i != data.size(); ++i) { - Y_VERIFY(data.at(i) == '?', "must be question mark"); + Y_VERIFY(data.at(i) == '?', "must be question mark"); } } @@ -164,7 +164,7 @@ TAutoPtr<TPerftestResponse> NewResponse(TPerftestRequest* request) { void CheckResponse(TPerftestResponse* response) { const TString& data = response->Record.GetData(); for (size_t i = 0; i != data.size(); ++i) { - Y_VERIFY(data.at(i) == '.', "must be dot"); + Y_VERIFY(data.at(i) == '.', "must be dot"); } } @@ -279,7 +279,7 @@ public: //delete message; //Sleep(TDuration::MilliSeconds(1)); //continue; - Y_FAIL("unreachable"); + Y_FAIL("unreachable"); } else if (ret == MESSAGE_SHUTDOWN) { delete message; } else { @@ -295,7 +295,7 @@ public: /// actual work is being done here void OnReply(TAutoPtr<TBusMessage> mess, TAutoPtr<TBusMessage> reply) override { - Y_UNUSED(mess); + Y_UNUSED(mess); if (Config.SimpleProtocol) { VerifyDynamicCast<TSimpleMessage*>(reply.Get()); @@ -310,8 +310,8 @@ public: /// message that could not be delivered void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { - Y_UNUSED(mess); - Y_UNUSED(status); + Y_UNUSED(mess); + Y_UNUSED(status); if (TheExit) { return; @@ -319,7 +319,7 @@ public: Stats.IncErrors(); - // Y_ASSERT(TheConfig->Failure > 0.0); + // Y_ASSERT(TheConfig->Failure > 0.0); } }; @@ -368,7 +368,7 @@ public: { /// register destination session Session = TBusServerSession::Create(Proto.Get(), this, Config.ServerSessionConfig, Bus); - Y_ASSERT(Session && "probably somebody is listening on the same port"); + Y_ASSERT(Session && "probably somebody is listening on the same port"); } /// when message comes, send reply @@ -416,8 +416,8 @@ public: : TPerftestServerCommon("server") , TBusModule("fast") { - Y_VERIFY(CreatePrivateSessions(Bus.Get()), "failed to initialize dupdetect module"); - Y_VERIFY(StartInput(), "failed to start input"); + Y_VERIFY(CreatePrivateSessions(Bus.Get()), "failed to initialize dupdetect module"); + Y_VERIFY(StartInput(), "failed to start input"); } ~TPerftestUsingModule() override { @@ -479,7 +479,7 @@ TVector<TNetAddr> ParseNodes(const TString nodes) { for (int i = 0; i < int(numh); i++) { const TNetworkAddress& networkAddress = ParseNetworkAddress(hosts[i].data()); - Y_VERIFY(networkAddress.Begin() != networkAddress.End(), "no addresses"); + Y_VERIFY(networkAddress.Begin() != networkAddress.End(), "no addresses"); r.push_back(TNetAddr(networkAddress, &*networkAddress.Begin())); } @@ -549,9 +549,9 @@ void TTestStats::PeriodicallyPrint() { (unsigned)ServerUsingModule->Bus->GetExecutor()->GetWorkQueueSize(), ServerUsingModule->Session->GetStatusSingleLine().data()); } - for (const auto& client : clients) { + for (const auto& client : clients) { fprintf(stderr, "client: q: %u %s\n", - (unsigned)client->Bus->GetExecutor()->GetWorkQueueSize(), + (unsigned)client->Bus->GetExecutor()->GetWorkQueueSize(), client->Session->GetStatusSingleLine().data()); } @@ -574,13 +574,13 @@ void TTestStats::PeriodicallyPrint() { stats << "server using modules:\n"; stats << IndentText(ServerUsingModule->Bus->GetStatus()); } - for (const auto& client : clients) { + for (const auto& client : clients) { if (!first) { stats << "\n"; } first = false; stats << "client:\n"; - stats << IndentText(client->Bus->GetStatus()); + stats << IndentText(client->Bus->GetStatus()); } TUnbufferedFileOutput("stats").Write(stats.Str()); @@ -693,15 +693,15 @@ int main(int argc, char* argv[]) { if (!clients.empty()) { Cerr << "Stopping clients\n"; - for (auto& client : clients) { - client->Stop(); + for (auto& client : clients) { + client->Stop(); } } wwwServer.Destroy(); - for (const auto& future : futures) { - future->Get(); + for (const auto& future : futures) { + future->Get(); } if (TheConfig->Profile) { diff --git a/library/cpp/messagebus/test/perftest/simple_proto.cpp b/library/cpp/messagebus/test/perftest/simple_proto.cpp index e478bda000..19d6c15b9d 100644 --- a/library/cpp/messagebus/test/perftest/simple_proto.cpp +++ b/library/cpp/messagebus/test/perftest/simple_proto.cpp @@ -7,7 +7,7 @@ using namespace NBus; void TSimpleProtocol::Serialize(const TBusMessage* mess, TBuffer& data) { - Y_VERIFY(typeid(TSimpleMessage) == typeid(*mess)); + Y_VERIFY(typeid(TSimpleMessage) == typeid(*mess)); const TSimpleMessage* typed = static_cast<const TSimpleMessage*>(mess); data.Append((const char*)&typed->Payload, 4); } diff --git a/library/cpp/messagebus/test/ut/messagebus_ut.cpp b/library/cpp/messagebus/test/ut/messagebus_ut.cpp index b333e2fe23..040f9b7702 100644 --- a/library/cpp/messagebus/test/ut/messagebus_ut.cpp +++ b/library/cpp/messagebus/test/ut/messagebus_ut.cpp @@ -31,7 +31,7 @@ namespace { } void OnReply(TAutoPtr<TBusMessage> mess, TAutoPtr<TBusMessage> reply) override { - Y_VERIFY(AtomicGet(SentCompleted), "must be completed"); + Y_VERIFY(AtomicGet(SentCompleted), "must be completed"); TExampleClient::OnReply(mess, reply); @@ -46,7 +46,7 @@ namespace { } -Y_UNIT_TEST_SUITE(TMessageBusTests) { +Y_UNIT_TEST_SUITE(TMessageBusTests) { void TestDestinationTemplate(bool useCompression, bool ackMessageBeforeReply, const TBusServerSessionConfig& sessionConfig) { TObjectCountCheck objectCountCheck; @@ -66,19 +66,19 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { UNIT_ASSERT_EQUAL(client.Session->GetInFlight(), 0); } - Y_UNIT_TEST(TestDestination) { + Y_UNIT_TEST(TestDestination) { TestDestinationTemplate(false, false, TBusServerSessionConfig()); } - Y_UNIT_TEST(TestDestinationUsingAck) { + Y_UNIT_TEST(TestDestinationUsingAck) { TestDestinationTemplate(false, true, TBusServerSessionConfig()); } - Y_UNIT_TEST(TestDestinationWithCompression) { + Y_UNIT_TEST(TestDestinationWithCompression) { TestDestinationTemplate(true, false, TBusServerSessionConfig()); } - Y_UNIT_TEST(TestCork) { + Y_UNIT_TEST(TestCork) { TBusServerSessionConfig config; config.SendThreshold = 1000000000000; config.Cork = TDuration::MilliSeconds(10); @@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { // TODO: test for cork hanging } - Y_UNIT_TEST(TestReconnect) { + Y_UNIT_TEST(TestReconnect) { if (!IsFixedPortTestAllowed()) { return; } @@ -136,7 +136,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } void OnError(TAutoPtr<TBusMessage> message, EMessageStatus status) override { - Y_UNUSED(message); + Y_UNUSED(message); Y_VERIFY(status == MESSAGE_CONNECT_FAILED, "must be MESSAGE_CONNECT_FAILED, got %s", ToString(status).data()); @@ -194,7 +194,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { UNIT_ASSERT_VALUES_EQUAL(client.Session->GetConfig()->MaxInFlight, count); } - Y_UNIT_TEST(TestHangindServer) { + Y_UNIT_TEST(TestHangindServer) { TObjectCountCheck objectCountCheck; THangingServer server(0); @@ -202,13 +202,13 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { HangingServerImpl(server.GetPort()); } - Y_UNIT_TEST(TestNoServer) { + Y_UNIT_TEST(TestNoServer) { TObjectCountCheck objectCountCheck; TestNoServerImpl(17, false); } - Y_UNIT_TEST(PauseInput) { + Y_UNIT_TEST(PauseInput) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -283,15 +283,15 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.ErrorHappened.WaitI(); } - Y_UNIT_TEST(NoServer_SendTimeout_Callback_PeriodLess) { + Y_UNIT_TEST(NoServer_SendTimeout_Callback_PeriodLess) { NoServer_SendTimeout_Callback_Impl(true); } - Y_UNIT_TEST(NoServer_SendTimeout_Callback_TimeoutLess) { + Y_UNIT_TEST(NoServer_SendTimeout_Callback_TimeoutLess) { NoServer_SendTimeout_Callback_Impl(false); } - Y_UNIT_TEST(TestOnReplyCalledAfterOnMessageSent) { + Y_UNIT_TEST(TestOnReplyCalledAfterOnMessageSent) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -327,7 +327,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } void OnMessage(TOnMessageContext& mess) override { - Y_VERIFY(mess.IsConnectionAlive(), "connection should be alive here"); + Y_VERIFY(mess.IsConnectionAlive(), "connection should be alive here"); TAutoPtr<TOnMessageContext> delayedMsg(new TOnMessageContext); delayedMsg->Swap(mess); auto g(Guard(Lock_)); @@ -337,8 +337,8 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { bool CheckClientIsAlive() { auto g(Guard(Lock_)); - for (auto& delayedMessage : DelayedMessages) { - if (!delayedMessage->IsConnectionAlive()) { + for (auto& delayedMessage : DelayedMessages) { + if (!delayedMessage->IsConnectionAlive()) { return false; } } @@ -347,8 +347,8 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { bool CheckClientIsDead() const { auto g(Guard(Lock_)); - for (const auto& delayedMessage : DelayedMessages) { - if (delayedMessage->IsConnectionAlive()) { + for (const auto& delayedMessage : DelayedMessages) { + if (delayedMessage->IsConnectionAlive()) { return false; } } @@ -377,12 +377,12 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { - Y_UNUSED(mess); + Y_UNUSED(mess); Y_VERIFY(status == MESSAGE_SHUTDOWN, "only shutdown allowed, got %s", ToString(status).data()); } }; - Y_UNIT_TEST(TestReplyCalledAfterClientDisconnected) { + Y_UNIT_TEST(TestReplyCalledAfterClientDisconnected) { TObjectCountCheck objectCountCheck; TDelayReplyServer server; @@ -431,12 +431,12 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { - Y_UNUSED(mess); - Y_VERIFY(status == MESSAGE_SHUTDOWN, "only shutdown allowed"); + Y_UNUSED(mess); + Y_VERIFY(status == MESSAGE_SHUTDOWN, "only shutdown allowed"); } }; - Y_UNIT_TEST(PackUnpack) { + Y_UNIT_TEST(PackUnpack) { TObjectCountCheck objectCountCheck; TPackUnpackServer server; @@ -446,7 +446,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client->SendMessagesWaitReplies(1, TNetAddr("localhost", server.Session->GetActualListenPort())); } - Y_UNIT_TEST(ClientRequestTooLarge) { + Y_UNIT_TEST(ClientRequestTooLarge) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -505,11 +505,11 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { void OnError(TAutoPtr<TBusMessage>, EMessageStatus status) override { TestSync.WaitForAndIncrement(1); - Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "status"); + Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "status"); } }; - Y_UNIT_TEST(ServerResponseTooLarge) { + Y_UNIT_TEST(ServerResponseTooLarge) { TObjectCountCheck objectCountCheck; TServerForResponseTooLarge server; @@ -555,12 +555,12 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { TAutoPtr<TExampleResponse> resp(new TExampleResponse(&Proto.ResponseCount, 10)); req.SendReplyMove(resp); } else { - Y_FAIL("wrong"); + Y_FAIL("wrong"); } } }; - Y_UNIT_TEST(ServerRequestTooLarge) { + Y_UNIT_TEST(ServerRequestTooLarge) { TObjectCountCheck objectCountCheck; TServerForRequestTooLarge server; @@ -578,7 +578,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.WaitForError(MESSAGE_DELIVERY_FAILED); } - Y_UNIT_TEST(ClientResponseTooLarge) { + Y_UNIT_TEST(ClientResponseTooLarge) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -598,7 +598,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.WaitForError(MESSAGE_DELIVERY_FAILED); } - Y_UNIT_TEST(ServerUnknownMessage) { + Y_UNIT_TEST(ServerUnknownMessage) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -616,7 +616,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.WaitForError(MESSAGE_DELIVERY_FAILED); } - Y_UNIT_TEST(ServerMessageReservedIds) { + Y_UNIT_TEST(ServerMessageReservedIds) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -641,7 +641,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.WaitForError(MESSAGE_DELIVERY_FAILED); } - Y_UNIT_TEST(TestGetInFlightForDestination) { + Y_UNIT_TEST(TestGetInFlightForDestination) { TObjectCountCheck objectCountCheck; TDelayReplyServer server; @@ -703,7 +703,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(ResetAfterSendOneWayErrorInCallback) { + Y_UNIT_TEST(ResetAfterSendOneWayErrorInCallback) { TObjectCountCheck objectCountCheck; TNetAddr noServerAddr("localhost", 17); @@ -739,7 +739,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(ResetAfterSendMessageOneWayDuringShutdown) { + Y_UNIT_TEST(ResetAfterSendMessageOneWayDuringShutdown) { TObjectCountCheck objectCountCheck; TNetAddr noServerAddr("localhost", 17); @@ -764,7 +764,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { delete message; } - Y_UNIT_TEST(ResetAfterSendOneWayErrorInReturn) { + Y_UNIT_TEST(ResetAfterSendOneWayErrorInReturn) { TObjectCountCheck objectCountCheck; TestNoServerImpl(17, true); @@ -784,7 +784,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(ResetAfterSendOneWaySuccess) { + Y_UNIT_TEST(ResetAfterSendOneWaySuccess) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -800,7 +800,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.TestSync.WaitForAndIncrement(2); } - Y_UNIT_TEST(GetStatus) { + Y_UNIT_TEST(GetStatus) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -818,7 +818,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.Bus->GetStatus(); } - Y_UNIT_TEST(BindOnRandomPort) { + Y_UNIT_TEST(BindOnRandomPort) { TObjectCountCheck objectCountCheck; TBusServerSessionConfig serverConfig; @@ -829,7 +829,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.SendMessagesWaitReplies(3, &addr); } - Y_UNIT_TEST(UnbindOnShutdown) { + Y_UNIT_TEST(UnbindOnShutdown) { TBusMessageQueuePtr queue(CreateMessageQueue()); TExampleProtocol proto; @@ -846,7 +846,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { THangingServer hangingServer(port); } - Y_UNIT_TEST(VersionNegotiation) { + Y_UNIT_TEST(VersionNegotiation) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -928,7 +928,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(OnClientConnectionEvent_Shutdown) { + Y_UNIT_TEST(OnClientConnectionEvent_Shutdown) { TObjectCountCheck objectCountCheck; TOnConnectionEventServer server; @@ -946,7 +946,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.Sync.WaitForAndIncrement(3); } - Y_UNIT_TEST(OnClientConnectionEvent_Disconnect) { + Y_UNIT_TEST(OnClientConnectionEvent_Disconnect) { TObjectCountCheck objectCountCheck; THolder<TOnConnectionEventServer> server(new TOnConnectionEventServer); @@ -1010,7 +1010,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(WakeReaderOnQuota) { + Y_UNIT_TEST(WakeReaderOnQuota) { const size_t test_msg_count = 64; TBusClientSessionConfig clientConfig; @@ -1061,7 +1061,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { server.WaitForOnMessageCount(test_msg_count); }; - Y_UNIT_TEST(TestConnectionAttempts) { + Y_UNIT_TEST(TestConnectionAttempts) { TObjectCountCheck objectCountCheck; TNetAddr noServerAddr("localhost", 17); @@ -1093,7 +1093,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } }; - Y_UNIT_TEST(TestConnectionAttemptsOnNoMessagesAndNotReconnectWhenIdle) { + Y_UNIT_TEST(TestConnectionAttemptsOnNoMessagesAndNotReconnectWhenIdle) { TObjectCountCheck objectCountCheck; TNetAddr noServerAddr("localhost", 17); @@ -1120,7 +1120,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { UNIT_ASSERT_EQUAL(client.Session->GetConnectSyscallsNumForTest(noServerAddr), 2); }; - Y_UNIT_TEST(TestConnectionAttemptsOnNoMessagesAndReconnectWhenIdle) { + Y_UNIT_TEST(TestConnectionAttemptsOnNoMessagesAndReconnectWhenIdle) { TObjectCountCheck objectCountCheck; TNetAddr noServerAddr("localhost", 17); diff --git a/library/cpp/messagebus/test/ut/module_client_one_way_ut.cpp b/library/cpp/messagebus/test/ut/module_client_one_way_ut.cpp index e7f2f5bd11..4083cf3b7b 100644 --- a/library/cpp/messagebus/test/ut/module_client_one_way_ut.cpp +++ b/library/cpp/messagebus/test/ut/module_client_one_way_ut.cpp @@ -9,7 +9,7 @@ using namespace NBus; using namespace NBus::NTest; -Y_UNIT_TEST_SUITE(ModuleClientOneWay) { +Y_UNIT_TEST_SUITE(ModuleClientOneWay) { struct TTestServer: public TBusServerHandlerError { TExampleProtocol Proto; @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(ModuleClientOneWay) { } }; - Y_UNIT_TEST(Simple) { + Y_UNIT_TEST(Simple) { TTestSync testSync; TTestServer server(&testSync); @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(ModuleClientOneWay) { } }; - Y_UNIT_TEST(SendError) { + Y_UNIT_TEST(SendError) { TTestSync testSync; TBusQueueConfig queueConfig; diff --git a/library/cpp/messagebus/test/ut/module_client_ut.cpp b/library/cpp/messagebus/test/ut/module_client_ut.cpp index 16d2f22335..ebfe185cc6 100644 --- a/library/cpp/messagebus/test/ut/module_client_ut.cpp +++ b/library/cpp/messagebus/test/ut/module_client_ut.cpp @@ -50,9 +50,9 @@ public: } }; -Y_UNIT_TEST_SUITE(BusJobTest) { +Y_UNIT_TEST_SUITE(BusJobTest) { #if 0 - Y_UNIT_TEST(TestPending) { + Y_UNIT_TEST(TestPending) { TObjectCountCheck objectCountCheck; TDupDetectModule module; @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { UNIT_ASSERT_EQUAL(msg, pending[0].Message); } - Y_UNIT_TEST(TestCallReplyHandler) { + Y_UNIT_TEST(TestCallReplyHandler) { TObjectCountCheck objectCountCheck; TDupDetectModule module; @@ -112,27 +112,27 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); job->Send(new TExampleRequest(&Proto.RequestCount), Source, TReplyHandler(&TParallelOnReplyModule::ReplyHandler), 0, ServerAddr); return &TParallelOnReplyModule::HandleReplies; } void ReplyHandler(TBusJob*, EMessageStatus status, TBusMessage* mess, TBusMessage* reply) { - Y_UNUSED(mess); - Y_UNUSED(reply); - Y_VERIFY(status == MESSAGE_OK, "failed to get reply: %s", ToCString(status)); + Y_UNUSED(mess); + Y_UNUSED(reply); + Y_VERIFY(status == MESSAGE_OK, "failed to get reply: %s", ToCString(status)); } TJobHandler HandleReplies(TBusJob* job, TBusMessage* mess) { - Y_UNUSED(mess); + Y_UNUSED(mess); RepliesLatch.CountDown(); - Y_VERIFY(RepliesLatch.Await(TDuration::Seconds(10)), "failed to get answers"); + Y_VERIFY(RepliesLatch.Await(TDuration::Seconds(10)), "failed to get answers"); job->Cancel(MESSAGE_UNKNOWN); return nullptr; } }; - Y_UNIT_TEST(TestReplyHandlerCalledInParallel) { + Y_UNIT_TEST(TestReplyHandlerCalledInParallel) { TObjectCountCheck objectCountCheck; TExampleServer server; @@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); TExampleRequest* message = new TExampleRequest(&Proto.RequestCount); job->Send(message, Source, TReplyHandler(&TErrorHandlerCheckerModule::ReplyHandler), 0, ServerAddr); SentMessage = message; @@ -179,13 +179,13 @@ Y_UNIT_TEST_SUITE(BusJobTest) { void ReplyHandler(TBusJob*, EMessageStatus status, TBusMessage* req, TBusMessage* resp) { Y_VERIFY(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "got wrong status: %s", ToString(status).data()); - Y_VERIFY(req == SentMessage, "checking request"); - Y_VERIFY(resp == nullptr, "checking response"); + Y_VERIFY(req == SentMessage, "checking request"); + Y_VERIFY(resp == nullptr, "checking response"); GotReplyLatch.CountDown(); } TJobHandler HandleReplies(TBusJob* job, TBusMessage* mess) { - Y_UNUSED(mess); + Y_UNUSED(mess); job->Cancel(MESSAGE_UNKNOWN); GotReplyLatch.CountDown(); return nullptr; @@ -201,7 +201,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } }; - Y_UNIT_TEST(ErrorHandler) { + Y_UNIT_TEST(ErrorHandler) { TExampleProtocol proto; TBusQueueConfig config; @@ -264,7 +264,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); for (unsigned i = 0; i < 2; ++i) { job->Send( new TExampleRequest(&Proto.RequestCount), @@ -277,9 +277,9 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } void ReplyHandler(TBusJob* job, EMessageStatus status, TBusMessage* mess, TBusMessage* reply) { - Y_UNUSED(mess); - Y_UNUSED(reply); - Y_VERIFY(status == MESSAGE_OK, "failed to get reply"); + Y_UNUSED(mess); + Y_UNUSED(reply); + Y_VERIFY(status == MESSAGE_OK, "failed to get reply"); if (AtomicIncrement(ReplyCount) == 1) { TestSync->WaitForAndIncrement(1); job->SendReply(new TExampleResponse(&Proto.ResponseCount)); @@ -289,7 +289,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } TJobHandler HandleReplies(TBusJob* job, TBusMessage* mess) { - Y_UNUSED(mess); + Y_UNUSED(mess); job->Cancel(MESSAGE_UNKNOWN); return nullptr; } @@ -301,7 +301,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } }; - Y_UNIT_TEST(SendReplyCalledBeforeAllRepliesReceived) { + Y_UNIT_TEST(SendReplyCalledBeforeAllRepliesReceived) { TTestSync testSync; TSlowReplyServer slowReplyServer(&testSync); @@ -338,7 +338,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } void HandleReply(TBusJob*, EMessageStatus status, TBusMessage*, TBusMessage*) { - Y_VERIFY(status == MESSAGE_SHUTDOWN, "got %s", ToCString(status)); + Y_VERIFY(status == MESSAGE_SHUTDOWN, "got %s", ToCString(status)); TestSync.CheckAndIncrement(1); } @@ -349,7 +349,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } }; - Y_UNIT_TEST(ShutdownCalledBeforeReplyReceived) { + Y_UNIT_TEST(ShutdownCalledBeforeReplyReceived) { TExampleServer server; server.ForgetRequest = true; diff --git a/library/cpp/messagebus/test/ut/module_server_ut.cpp b/library/cpp/messagebus/test/ut/module_server_ut.cpp index 4acc9e3f59..88fe1dd9b6 100644 --- a/library/cpp/messagebus/test/ut/module_server_ut.cpp +++ b/library/cpp/messagebus/test/ut/module_server_ut.cpp @@ -15,8 +15,8 @@ using namespace NBus; using namespace NBus::NTest; -Y_UNIT_TEST_SUITE(ModuleServerTests) { - Y_UNIT_TEST(TestModule) { +Y_UNIT_TEST_SUITE(ModuleServerTests) { + Y_UNIT_TEST(TestModule) { TObjectCountCheck objectCountCheck; /// create or get instance of message queue, need one per application @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(ModuleServerTests) { TJobHandler Start(TBusJob* job, TBusMessage* mess) override { WaitTwoRequestsLatch.CountDown(); - Y_VERIFY(WaitTwoRequestsLatch.Await(TDuration::Seconds(5)), "oops"); + Y_VERIFY(WaitTwoRequestsLatch.Await(TDuration::Seconds(5)), "oops"); VerifyDynamicCast<TExampleRequest*>(mess); @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(ModuleServerTests) { } }; - Y_UNIT_TEST(TestOnMessageHandlerCalledInParallel) { + Y_UNIT_TEST(TestOnMessageHandlerCalledInParallel) { TObjectCountCheck objectCountCheck; TBusQueueConfig config; @@ -79,18 +79,18 @@ Y_UNIT_TEST_SUITE(ModuleServerTests) { TSystemEvent ClientDiedEvent; TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); MessageReceivedEvent.Signal(); - Y_VERIFY(ClientDiedEvent.WaitT(TDuration::Seconds(5)), "oops"); + Y_VERIFY(ClientDiedEvent.WaitT(TDuration::Seconds(5)), "oops"); job->SendReply(new TExampleResponse(&Proto.ResponseCount)); return nullptr; } }; - Y_UNIT_TEST(TestReplyCalledAfterClientDisconnected) { + Y_UNIT_TEST(TestReplyCalledAfterClientDisconnected) { TObjectCountCheck objectCountCheck; TBusQueueConfig config; diff --git a/library/cpp/messagebus/test/ut/one_way_ut.cpp b/library/cpp/messagebus/test/ut/one_way_ut.cpp index 7f18da400e..9c21227e2b 100644 --- a/library/cpp/messagebus/test/ut/one_way_ut.cpp +++ b/library/cpp/messagebus/test/ut/one_way_ut.cpp @@ -114,7 +114,7 @@ public: void OnMessage(TOnMessageContext& mess) override { TExampleRequest* fmess = static_cast<TExampleRequest*>(mess.GetMessage()); - Y_ASSERT(fmess->Data == "TADA"); + Y_ASSERT(fmess->Data == "TADA"); /// tell session to forget this message and never expect any reply mess.ForgetRequest(); @@ -124,13 +124,13 @@ public: /// this handler should not be called because this server does not send replies void OnSent(TAutoPtr<TBusMessage> mess) override { - Y_UNUSED(mess); - Y_FAIL("This server does not sent replies"); + Y_UNUSED(mess); + Y_FAIL("This server does not sent replies"); } }; -Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) { + Y_UNIT_TEST(Simple) { TObjectCountCheck objectCountCheck; NullServer server; @@ -166,15 +166,15 @@ Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) { } void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { - Y_UNUSED(mess); + Y_UNUSED(mess); - Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "wrong status: %s", ToCString(status)); + Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "wrong status: %s", ToCString(status)); GotTooLarge.Signal(); } }; - Y_UNIT_TEST(MessageTooLargeOnClient) { + Y_UNIT_TEST(MessageTooLargeOnClient) { TObjectCountCheck objectCountCheck; NullServer server; @@ -209,14 +209,14 @@ Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) { /// message that could not be delivered void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { - Y_UNUSED(mess); - Y_UNUSED(status); // TODO: check status + Y_UNUSED(mess); + Y_UNUSED(status); // TODO: check status GotError.Signal(); } }; - Y_UNIT_TEST(SendTimeout_Callback_NoServer) { + Y_UNIT_TEST(SendTimeout_Callback_NoServer) { TObjectCountCheck objectCountCheck; TCheckTimeoutClient client(TNetAddr("localhost", 17)); @@ -227,7 +227,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) { client.GotError.WaitI(); } - Y_UNIT_TEST(SendTimeout_Callback_HangingServer) { + Y_UNIT_TEST(SendTimeout_Callback_HangingServer) { THangingServer server; TObjectCountCheck objectCountCheck; diff --git a/library/cpp/messagebus/test/ut/starter_ut.cpp b/library/cpp/messagebus/test/ut/starter_ut.cpp index 76d688b62e..dd4d3aaa5e 100644 --- a/library/cpp/messagebus/test/ut/starter_ut.cpp +++ b/library/cpp/messagebus/test/ut/starter_ut.cpp @@ -7,7 +7,7 @@ using namespace NBus; using namespace NBus::NTest; -Y_UNIT_TEST_SUITE(TBusStarterTest) { +Y_UNIT_TEST_SUITE(TBusStarterTest) { struct TStartJobTestModule: public TExampleModule { using TBusModule::CreateDefaultStarter; @@ -19,21 +19,21 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { } TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); AtomicIncrement(StartCount); job->Sleep(10); return &TStartJobTestModule::End; } TJobHandler End(TBusJob* job, TBusMessage* mess) { - Y_UNUSED(mess); + Y_UNUSED(mess); AtomicIncrement(StartCount); job->Cancel(MESSAGE_UNKNOWN); return nullptr; } }; - Y_UNIT_TEST(Test) { + Y_UNIT_TEST(Test) { TObjectCountCheck objectCountCheck; TBusMessageQueuePtr bus(CreateMessageQueue()); @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { bus->Stop(); } - Y_UNIT_TEST(TestModuleStartJob) { + Y_UNIT_TEST(TestModuleStartJob) { TObjectCountCheck objectCountCheck; TExampleProtocol proto; @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { TSystemEvent MessageReceivedEvent; TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); MessageReceivedEvent.Signal(); @@ -89,12 +89,12 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { } TJobHandler Never(TBusJob*, TBusMessage*) { - Y_FAIL("happens"); + Y_FAIL("happens"); throw 1; } }; - Y_UNIT_TEST(StartJobDestroyDuringSleep) { + Y_UNIT_TEST(StartJobDestroyDuringSleep) { TObjectCountCheck objectCountCheck; TExampleProtocol proto; @@ -114,7 +114,7 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { TSystemEvent MessageReceivedEvent; TJobHandler Start(TBusJob* job, TBusMessage* mess) override { - Y_UNUSED(mess); + Y_UNUSED(mess); job->SendReply(new TExampleResponse(&Proto.ResponseCount)); @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TBusStarterTest) { } }; - Y_UNIT_TEST(AllowSendReplyInStarted) { + Y_UNIT_TEST(AllowSendReplyInStarted) { TObjectCountCheck objectCountCheck; TExampleProtocol proto; diff --git a/library/cpp/messagebus/test/ut/sync_client_ut.cpp b/library/cpp/messagebus/test/ut/sync_client_ut.cpp index 735aa06569..400128193f 100644 --- a/library/cpp/messagebus/test/ut/sync_client_ut.cpp +++ b/library/cpp/messagebus/test/ut/sync_client_ut.cpp @@ -50,8 +50,8 @@ namespace NBus { } }; - Y_UNIT_TEST_SUITE(SyncClientTest) { - Y_UNIT_TEST(TestSync) { + Y_UNIT_TEST_SUITE(SyncClientTest) { + Y_UNIT_TEST(TestSync) { TObjectCountCheck objectCountCheck; TExampleServer server; diff --git a/library/cpp/messagebus/use_after_free_checker.cpp b/library/cpp/messagebus/use_after_free_checker.cpp index 5fc62f7b62..4904e7c614 100644 --- a/library/cpp/messagebus/use_after_free_checker.cpp +++ b/library/cpp/messagebus/use_after_free_checker.cpp @@ -13,10 +13,10 @@ TUseAfterFreeChecker::TUseAfterFreeChecker() } TUseAfterFreeChecker::~TUseAfterFreeChecker() { - Y_VERIFY(Magic == VALID, "Corrupted"); + Y_VERIFY(Magic == VALID, "Corrupted"); Magic = INVALID; } void TUseAfterFreeChecker::CheckNotFreed() const { - Y_VERIFY(Magic == VALID, "Freed or corrupted"); + Y_VERIFY(Magic == VALID, "Freed or corrupted"); } diff --git a/library/cpp/messagebus/vector_swaps.h b/library/cpp/messagebus/vector_swaps.h index 2edcd99114..b920bcf03e 100644 --- a/library/cpp/messagebus/vector_swaps.h +++ b/library/cpp/messagebus/vector_swaps.h @@ -15,8 +15,8 @@ private: T* EndOfStorage; void StateCheck() { - Y_ASSERT(Start <= Finish); - Y_ASSERT(Finish <= EndOfStorage); + Y_ASSERT(Start <= Finish); + Y_ASSERT(Finish <= EndOfStorage); } public: @@ -69,12 +69,12 @@ public: } T& operator[](size_t index) { - Y_ASSERT(index < size()); + Y_ASSERT(index < size()); return Start[index]; } const T& operator[](size_t index) const { - Y_ASSERT(index < size()); + Y_ASSERT(index < size()); return Start[index]; } @@ -122,7 +122,7 @@ public: size_t newCapacity = FastClp2(n); TVectorSwaps<T> tmp; tmp.Start = (T*)malloc(sizeof(T) * newCapacity); - Y_VERIFY(!!tmp.Start); + Y_VERIFY(!!tmp.Start); tmp.EndOfStorage = tmp.Start + newCapacity; @@ -146,7 +146,7 @@ public: template <class TIterator> void insert(iterator pos, TIterator b, TIterator e) { - Y_VERIFY(pos == end(), "TODO: only insert at the end is implemented"); + Y_VERIFY(pos == end(), "TODO: only insert at the end is implemented"); size_t count = e - b; diff --git a/library/cpp/messagebus/vector_swaps_ut.cpp b/library/cpp/messagebus/vector_swaps_ut.cpp index 9994cb80b2..693cc6857b 100644 --- a/library/cpp/messagebus/vector_swaps_ut.cpp +++ b/library/cpp/messagebus/vector_swaps_ut.cpp @@ -2,8 +2,8 @@ #include "vector_swaps.h" -Y_UNIT_TEST_SUITE(TVectorSwapsTest) { - Y_UNIT_TEST(Simple) { +Y_UNIT_TEST_SUITE(TVectorSwapsTest) { + Y_UNIT_TEST(Simple) { TVectorSwaps<THolder<unsigned>> v; for (unsigned i = 0; i < 100; ++i) { THolder<unsigned> tmp(new unsigned(i)); diff --git a/library/cpp/messagebus/www/html_output.h b/library/cpp/messagebus/www/html_output.h index 3cbf350c0c..27e77adefa 100644 --- a/library/cpp/messagebus/www/html_output.h +++ b/library/cpp/messagebus/www/html_output.h @@ -7,17 +7,17 @@ #include <library/cpp/html/pcdata/pcdata.h> #include <util/system/tls.h> -extern Y_POD_THREAD(IOutputStream*) HtmlOutputStreamPtr; +extern Y_POD_THREAD(IOutputStream*) HtmlOutputStreamPtr; -static IOutputStream& HtmlOutputStream() { - Y_VERIFY(!!HtmlOutputStreamPtr); +static IOutputStream& HtmlOutputStream() { + Y_VERIFY(!!HtmlOutputStreamPtr); return *HtmlOutputStreamPtr; } struct THtmlOutputStreamPushPop { - IOutputStream* const Prev; + IOutputStream* const Prev; - THtmlOutputStreamPushPop(IOutputStream* outputStream) + THtmlOutputStreamPushPop(IOutputStream* outputStream) : Prev(HtmlOutputStreamPtr) { HtmlOutputStreamPtr = outputStream; diff --git a/library/cpp/messagebus/www/www.cpp b/library/cpp/messagebus/www/www.cpp index b9540681b3..62ec241d85 100644 --- a/library/cpp/messagebus/www/www.cpp +++ b/library/cpp/messagebus/www/www.cpp @@ -38,7 +38,7 @@ namespace { TVector<std::pair<TString, TValuePtr>> Entries; TValuePtr FindByName(TStringBuf name) { - Y_VERIFY(!!name); + Y_VERIFY(!!name); for (unsigned i = 0; i < Entries.size(); ++i) { if (Entries[i].first == name) { @@ -49,7 +49,7 @@ namespace { } TString FindNameByPtr(TValuePtr value) { - Y_VERIFY(!!value); + Y_VERIFY(!!value); for (unsigned i = 0; i < Entries.size(); ++i) { if (Entries[i].second.Get() == value.Get()) { @@ -57,11 +57,11 @@ namespace { } } - Y_FAIL("unregistered"); + Y_FAIL("unregistered"); } void Add(TValuePtr p) { - Y_VERIFY(!!p); + Y_VERIFY(!!p); // Do not add twice for (unsigned i = 0; i < Entries.size(); ++i) { @@ -187,27 +187,27 @@ struct TBusWww::TImpl { TMutex Mutex; void RegisterClientSession(TBusClientSessionPtr s) { - Y_VERIFY(!!s); + Y_VERIFY(!!s); TGuard<TMutex> g(Mutex); ClientSessions.Add(s.Get()); Queues.Add(s->GetQueue()); } void RegisterServerSession(TBusServerSessionPtr s) { - Y_VERIFY(!!s); + Y_VERIFY(!!s); TGuard<TMutex> g(Mutex); ServerSessions.Add(s.Get()); Queues.Add(s->GetQueue()); } void RegisterQueue(TBusMessageQueuePtr q) { - Y_VERIFY(!!q); + Y_VERIFY(!!q); TGuard<TMutex> g(Mutex); Queues.Add(q); } void RegisterModule(TBusModule* module) { - Y_VERIFY(!!module); + Y_VERIFY(!!module); TGuard<TMutex> g(Mutex); { @@ -239,17 +239,17 @@ struct TBusWww::TImpl { serverSession = ServerSessions.FindByName(sessionName); session = serverSession.Get(); } - Y_VERIFY(!!session); + Y_VERIFY(!!session); return Queues.FindNameByPtr(session->GetQueue()); } struct TRequest { TImpl* const Outer; - IOutputStream& Os; + IOutputStream& Os; const TCgiParameters& CgiParams; const TOptionalParams& Params; - TRequest(TImpl* outer, IOutputStream& os, const TCgiParameters& cgiParams, const TOptionalParams& params) + TRequest(TImpl* outer, IOutputStream& os, const TCgiParameters& cgiParams, const TOptionalParams& params) : Outer(outer) , Os(os) , CgiParams(cgiParams) @@ -681,9 +681,9 @@ struct TBusWww::TImpl { } void ServeSolomonJson(const TString& q, const TString& cs, const TString& ss) { - Y_UNUSED(q); - Y_UNUSED(cs); - Y_UNUSED(ss); + Y_UNUSED(q); + Y_UNUSED(cs); + Y_UNUSED(ss); bool all = q == "" && cs == "" && ss == ""; NMonitoring::TDeprecatedJsonWriter sj(&Os); @@ -720,10 +720,10 @@ struct TBusWww::TImpl { sj.CloseDocument(); } - void ServeStatic(IOutputStream& os, TStringBuf path) { - if (path.EndsWith(".js")) { + void ServeStatic(IOutputStream& os, TStringBuf path) { + if (path.EndsWith(".js")) { os << HTTP_OK_JS; - } else if (path.EndsWith(".png")) { + } else if (path.EndsWith(".png")) { os << HTTP_OK_PNG; } else { os << HTTP_OK_BIN; @@ -799,7 +799,7 @@ struct TBusWww::TImpl { } }; - void ServeHttp(IOutputStream& os, const TCgiParameters& queryArgs, const TBusWww::TOptionalParams& params) { + void ServeHttp(IOutputStream& os, const TCgiParameters& queryArgs, const TBusWww::TOptionalParams& params) { TGuard<TMutex> g(Mutex); TRequest request(this, os, queryArgs, params); @@ -832,7 +832,7 @@ void TBusWww::RegisterModule(TBusModule* module) { Impl->RegisterModule(module); } -void TBusWww::ServeHttp(IOutputStream& httpOutputStream, +void TBusWww::ServeHttp(IOutputStream& httpOutputStream, const TCgiParameters& queryArgs, const TBusWww::TOptionalParams& params) { Impl->ServeHttp(httpOutputStream, queryArgs, params); @@ -843,7 +843,7 @@ struct TBusWwwHttpServer::TImpl: public THttpServer::ICallBack { THttpServer HttpServer; static THttpServer::TOptions MakeHttpServerOptions(unsigned port) { - Y_VERIFY(port > 0); + Y_VERIFY(port > 0); THttpServer::TOptions r; r.Port = port; return r; diff --git a/library/cpp/mime/types/mime.cpp b/library/cpp/mime/types/mime.cpp index 4a58562ee9..706d776b24 100644 --- a/library/cpp/mime/types/mime.cpp +++ b/library/cpp/mime/types/mime.cpp @@ -114,7 +114,7 @@ TMimeTypes::TMimeTypes() } void TMimeTypes::SetContentTypes() { - for (int i = 0; i < (int)Y_ARRAY_SIZE(Records); ++i) { + for (int i = 0; i < (int)Y_ARRAY_SIZE(Records); ++i) { const TRecord& record(Records[i]); assert(i == record.Mime || i > MIME_MAX || record.Mime == MIME_UNKNOWN); if (!record.ContentType) @@ -127,7 +127,7 @@ void TMimeTypes::SetContentTypes() { } void TMimeTypes::SetExt() { - for (int i = 0; i < (int)Y_ARRAY_SIZE(Records); ++i) { + for (int i = 0; i < (int)Y_ARRAY_SIZE(Records); ++i) { const TRecord& record(Records[i]); if (!record.Ext) continue; diff --git a/library/cpp/monlib/counters/counters.cpp b/library/cpp/monlib/counters/counters.cpp index bda7f8c404..50dca4c577 100644 --- a/library/cpp/monlib/counters/counters.cpp +++ b/library/cpp/monlib/counters/counters.cpp @@ -27,7 +27,7 @@ namespace NMonitoring { } char* PrettyNum(i64 val, char* buf, size_t size) { - Y_ASSERT(buf); + Y_ASSERT(buf); if (size < 4) { buf[0] = 0; return buf; @@ -37,7 +37,7 @@ namespace NMonitoring { *buf = '\0'; } else { size_t len = 2 + strnlen(buf + 2, size - 4); - Y_ASSERT(len < size); + Y_ASSERT(len < size); buf[0] = ' '; buf[1] = '('; buf[len] = ')'; diff --git a/library/cpp/monlib/counters/counters_ut.cpp b/library/cpp/monlib/counters/counters_ut.cpp index 4d488b3ece..2845efb97b 100644 --- a/library/cpp/monlib/counters/counters_ut.cpp +++ b/library/cpp/monlib/counters/counters_ut.cpp @@ -8,7 +8,7 @@ using namespace NMonitoring; Y_UNIT_TEST_SUITE(TDeprecatedCountersTest) { - Y_UNIT_TEST(CounterGroupsAreThreadSafe) { + Y_UNIT_TEST(CounterGroupsAreThreadSafe) { const static ui32 GROUPS_COUNT = 1000; const static ui32 THREADS_COUNT = 10; diff --git a/library/cpp/monlib/counters/histogram_ut.cpp b/library/cpp/monlib/counters/histogram_ut.cpp index 890063c577..5a0800505a 100644 --- a/library/cpp/monlib/counters/histogram_ut.cpp +++ b/library/cpp/monlib/counters/histogram_ut.cpp @@ -4,8 +4,8 @@ using namespace NMonitoring; -Y_UNIT_TEST_SUITE(THistorgamTest) { - Y_UNIT_TEST(TakeSnapshot) { +Y_UNIT_TEST_SUITE(THistorgamTest) { + Y_UNIT_TEST(TakeSnapshot) { THdrHistogram h(1, 10, 3); UNIT_ASSERT(h.RecordValue(1)); UNIT_ASSERT(h.RecordValue(2)); diff --git a/library/cpp/monlib/counters/meter_ut.cpp b/library/cpp/monlib/counters/meter_ut.cpp index 96ff37e2f5..b507d16fbd 100644 --- a/library/cpp/monlib/counters/meter_ut.cpp +++ b/library/cpp/monlib/counters/meter_ut.cpp @@ -18,8 +18,8 @@ struct TMockClock { using TMockMeter = TMeterImpl<TMockClock>; -Y_UNIT_TEST_SUITE(TMeterTest) { - Y_UNIT_TEST(StartsOutWithNoRatesOrCount) { +Y_UNIT_TEST_SUITE(TMeterTest) { + Y_UNIT_TEST(StartsOutWithNoRatesOrCount) { TMeter meter; UNIT_ASSERT_EQUAL(meter.GetCount(), 0L); UNIT_ASSERT_DOUBLES_EQUAL(meter.GetMeanRate(), 0.0, 0.0001); @@ -28,7 +28,7 @@ Y_UNIT_TEST_SUITE(TMeterTest) { UNIT_ASSERT_DOUBLES_EQUAL(meter.GetFifteenMinutesRate(), 0.0, 0.0001); } - Y_UNIT_TEST(MarksEventsAndUpdatesRatesAndCount) { + Y_UNIT_TEST(MarksEventsAndUpdatesRatesAndCount) { TMockMeter meter; meter.Mark(); meter.Mark(2); diff --git a/library/cpp/monlib/counters/timer_ut.cpp b/library/cpp/monlib/counters/timer_ut.cpp index cdd8bc494d..c5cd07e89d 100644 --- a/library/cpp/monlib/counters/timer_ut.cpp +++ b/library/cpp/monlib/counters/timer_ut.cpp @@ -16,8 +16,8 @@ public: int Value_; }; -Y_UNIT_TEST_SUITE(TTimerTest) { - Y_UNIT_TEST(RecordValue) { +Y_UNIT_TEST_SUITE(TTimerTest) { + Y_UNIT_TEST(RecordValue) { TTimerNs timerNs(1ns, 1s); UNIT_ASSERT(timerNs.RecordValue(10us)); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(TTimerTest) { UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6); } - Y_UNIT_TEST(Measure) { + Y_UNIT_TEST(Measure) { TTimerNs timer(1ns, 1s); timer.Measure([]() { Sleep(TDuration::MilliSeconds(1)); @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TTimerTest) { UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6); } - Y_UNIT_TEST(TimerScope) { + Y_UNIT_TEST(TimerScope) { TTimerUs timer(1us, 1000s); { TTimerScope<TTimerUs> scope(&timer); @@ -63,7 +63,7 @@ Y_UNIT_TEST_SUITE(TTimerTest) { UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6); } - Y_UNIT_TEST(TimerScopeWithCallback) { + Y_UNIT_TEST(TimerScopeWithCallback) { TCallback callback(0); TTimerUs timer(1us, 1000s); { diff --git a/library/cpp/monlib/deprecated/json/writer_ut.cpp b/library/cpp/monlib/deprecated/json/writer_ut.cpp index 39b199d251..1f9fc8f393 100644 --- a/library/cpp/monlib/deprecated/json/writer_ut.cpp +++ b/library/cpp/monlib/deprecated/json/writer_ut.cpp @@ -5,7 +5,7 @@ using namespace NMonitoring; Y_UNIT_TEST_SUITE(JsonWriterTests) { - Y_UNIT_TEST(One) { + Y_UNIT_TEST(One) { TStringStream ss; TDeprecatedJsonWriter w(&ss); w.OpenDocument(); diff --git a/library/cpp/monlib/dynamic_counters/counters.cpp b/library/cpp/monlib/dynamic_counters/counters.cpp index 339b6c3a07..3635d87d0d 100644 --- a/library/cpp/monlib/dynamic_counters/counters.cpp +++ b/library/cpp/monlib/dynamic_counters/counters.cpp @@ -153,7 +153,7 @@ void TDynamicCounters::MergeWithSubgroup(const TString& name, const TString& val auto it = Counters.find({name, value}); Y_VERIFY(it != Counters.end()); TIntrusivePtr<TDynamicCounters> subgroup = AsDynamicCounters(it->second); - Y_VERIFY(subgroup); + Y_VERIFY(subgroup); Counters.erase(it); Counters.merge(subgroup->Resign()); AtomicAdd(ExpiringCount, AtomicSwap(&subgroup->ExpiringCount, 0)); @@ -200,7 +200,7 @@ void TDynamicCounters::EnumerateSubgroups(const std::function<void(const TString } } -void TDynamicCounters::OutputPlainText(IOutputStream& os, const TString& indent) const { +void TDynamicCounters::OutputPlainText(IOutputStream& os, const TString& indent) const { auto snap = ReadSnapshot(); // mark private records in plain text output auto outputVisibilityMarker = [] (EVisibility vis) { diff --git a/library/cpp/monlib/dynamic_counters/counters.h b/library/cpp/monlib/dynamic_counters/counters.h index 1f5fadd32d..dc178cfbe0 100644 --- a/library/cpp/monlib/dynamic_counters/counters.h +++ b/library/cpp/monlib/dynamic_counters/counters.h @@ -343,11 +343,11 @@ namespace NMonitoring { const TString& value, TIntrusivePtr<TDynamicCounters> subgroup); - void OutputHtml(IOutputStream& os) const; + void OutputHtml(IOutputStream& os) const; void EnumerateSubgroups(const std::function<void(const TString& name, const TString& value)>& output) const; // mostly for debugging purposes -- use accept with encoder instead - void OutputPlainText(IOutputStream& os, const TString& indent = "") const; + void OutputPlainText(IOutputStream& os, const TString& indent = "") const; void Accept( const TString& labelName, const TString& labelValue, diff --git a/library/cpp/monlib/dynamic_counters/counters_ut.cpp b/library/cpp/monlib/dynamic_counters/counters_ut.cpp index 8e79949be9..3591037e0a 100644 --- a/library/cpp/monlib/dynamic_counters/counters_ut.cpp +++ b/library/cpp/monlib/dynamic_counters/counters_ut.cpp @@ -6,7 +6,7 @@ using namespace NMonitoring; class TCountersPrinter: public ICountableConsumer { public: - TCountersPrinter(IOutputStream* out) + TCountersPrinter(IOutputStream* out) : Out_(out) , Level_(0) { @@ -41,7 +41,7 @@ private: Indent(Out_, --Level_) << "}\n"; } - static IOutputStream& Indent(IOutputStream* out, int level) { + static IOutputStream& Indent(IOutputStream* out, int level) { for (int i = 0; i < level; i++) { out->Write(" "); } @@ -49,12 +49,12 @@ private: } private: - IOutputStream* Out_; + IOutputStream* Out_; int Level_ = 0; }; -Y_UNIT_TEST_SUITE(TDynamicCountersTest) { - Y_UNIT_TEST(CountersConsumer) { +Y_UNIT_TEST_SUITE(TDynamicCountersTest) { + Y_UNIT_TEST(CountersConsumer) { TDynamicCounterPtr rootGroup(new TDynamicCounters()); auto usersCounter = rootGroup->GetNamedCounter("users", "count"); @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(TDynamicCountersTest) { "}\n"); } - Y_UNIT_TEST(MergeSubgroup) { + Y_UNIT_TEST(MergeSubgroup) { TDynamicCounterPtr rootGroup(new TDynamicCounters()); auto sensor1 = rootGroup->GetNamedCounter("sensor", "1"); @@ -127,7 +127,7 @@ Y_UNIT_TEST_SUITE(TDynamicCountersTest) { "}\n"); } - Y_UNIT_TEST(ResetCounters) { + Y_UNIT_TEST(ResetCounters) { TDynamicCounterPtr rootGroup(new TDynamicCounters()); auto sensor1 = rootGroup->GetNamedCounter("sensor", "1"); @@ -176,7 +176,7 @@ Y_UNIT_TEST_SUITE(TDynamicCountersTest) { "}\n"); } - Y_UNIT_TEST(RemoveCounter) { + Y_UNIT_TEST(RemoveCounter) { TDynamicCounterPtr rootGroup(new TDynamicCounters()); rootGroup->GetNamedCounter("label", "1"); @@ -202,7 +202,7 @@ Y_UNIT_TEST_SUITE(TDynamicCountersTest) { "}\n"); } - Y_UNIT_TEST(RemoveSubgroup) { + Y_UNIT_TEST(RemoveSubgroup) { TDynamicCounterPtr rootGroup(new TDynamicCounters()); rootGroup->GetSubgroup("group", "1"); diff --git a/library/cpp/monlib/dynamic_counters/encode_ut.cpp b/library/cpp/monlib/dynamic_counters/encode_ut.cpp index bc60b2a933..52d77b6b41 100644 --- a/library/cpp/monlib/dynamic_counters/encode_ut.cpp +++ b/library/cpp/monlib/dynamic_counters/encode_ut.cpp @@ -130,10 +130,10 @@ namespace NMonitoring { } } - Y_UNIT_TEST_SUITE(TDynamicCountersEncodeTest) { + Y_UNIT_TEST_SUITE(TDynamicCountersEncodeTest) { TTestData Data; - Y_UNIT_TEST(Json) { + Y_UNIT_TEST(Json) { TString result; { TStringOutput out(result); @@ -150,7 +150,7 @@ namespace NMonitoring { AssertResult(samples); } - Y_UNIT_TEST(Spack) { + Y_UNIT_TEST(Spack) { TBuffer result; { TBufferOutput out(result); diff --git a/library/cpp/monlib/dynamic_counters/golovan_page.cpp b/library/cpp/monlib/dynamic_counters/golovan_page.cpp index 0654519a7e..49cf2d39bb 100644 --- a/library/cpp/monlib/dynamic_counters/golovan_page.cpp +++ b/library/cpp/monlib/dynamic_counters/golovan_page.cpp @@ -59,7 +59,7 @@ public: } private: - IOutputStream& out; + IOutputStream& out; bool FirstCounter; TString prefix; }; diff --git a/library/cpp/monlib/encode/buffered/string_pool_ut.cpp b/library/cpp/monlib/encode/buffered/string_pool_ut.cpp index 1b360f5cdc..9fc3421d0b 100644 --- a/library/cpp/monlib/encode/buffered/string_pool_ut.cpp +++ b/library/cpp/monlib/encode/buffered/string_pool_ut.cpp @@ -4,8 +4,8 @@ using namespace NMonitoring; -Y_UNIT_TEST_SUITE(TStringPoolTest) { - Y_UNIT_TEST(PutIfAbsent) { +Y_UNIT_TEST_SUITE(TStringPoolTest) { + Y_UNIT_TEST(PutIfAbsent) { TStringPoolBuilder strPool; strPool.SetSorted(true); @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TStringPoolTest) { UNIT_ASSERT_VALUES_EQUAL(strPool.Count(), 2); } - Y_UNIT_TEST(SortByFrequency) { + Y_UNIT_TEST(SortByFrequency) { TStringPoolBuilder strPool; strPool.SetSorted(true); @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TStringPoolTest) { UNIT_ASSERT_VALUES_EQUAL(strPool.Count(), 2); } - Y_UNIT_TEST(ForEach) { + Y_UNIT_TEST(ForEach) { TStringPoolBuilder strPool; strPool.SetSorted(true); diff --git a/library/cpp/monlib/encode/format_ut.cpp b/library/cpp/monlib/encode/format_ut.cpp index 516d89cd3f..22a0e30c03 100644 --- a/library/cpp/monlib/encode/format_ut.cpp +++ b/library/cpp/monlib/encode/format_ut.cpp @@ -9,7 +9,7 @@ using namespace NMonitoring; -Y_UNIT_TEST_SUITE(TFormatTest) { +Y_UNIT_TEST_SUITE(TFormatTest) { Y_UNIT_TEST(ContentTypeHeader) { UNIT_ASSERT_EQUAL(FormatFromContentType(""), EFormat::UNKNOWN); UNIT_ASSERT_EQUAL(FormatFromContentType("application/json;some=stuff"), EFormat::JSON); @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TFormatTest) { UNIT_ASSERT_EQUAL(FormatFromContentType(";application/xml"), EFormat::UNKNOWN); } - Y_UNIT_TEST(AcceptHeader) { + Y_UNIT_TEST(AcceptHeader) { UNIT_ASSERT_EQUAL(FormatFromAcceptHeader(""), EFormat::UNKNOWN); UNIT_ASSERT_EQUAL(FormatFromAcceptHeader("*/*"), EFormat::UNKNOWN); @@ -63,7 +63,7 @@ Y_UNIT_TEST_SUITE(TFormatTest) { EFormat::PROMETHEUS); } - Y_UNIT_TEST(FormatToStrFromStr) { + Y_UNIT_TEST(FormatToStrFromStr) { const std::array<EFormat, 6> formats = {{ EFormat::UNKNOWN, EFormat::SPACK, @@ -80,7 +80,7 @@ Y_UNIT_TEST_SUITE(TFormatTest) { } } - Y_UNIT_TEST(AcceptEncodingHeader) { + Y_UNIT_TEST(AcceptEncodingHeader) { UNIT_ASSERT_EQUAL( CompressionFromAcceptEncodingHeader(""), ECompression::UNKNOWN); @@ -118,7 +118,7 @@ Y_UNIT_TEST_SUITE(TFormatTest) { ECompression::LZ4); } - Y_UNIT_TEST(CompressionToStrFromStr) { + Y_UNIT_TEST(CompressionToStrFromStr) { const std::array<ECompression, 5> algs = {{ ECompression::UNKNOWN, ECompression::IDENTITY, diff --git a/library/cpp/monlib/encode/json/json_ut.cpp b/library/cpp/monlib/encode/json/json_ut.cpp index e76e6691f9..09e7909289 100644 --- a/library/cpp/monlib/encode/json/json_ut.cpp +++ b/library/cpp/monlib/encode/json/json_ut.cpp @@ -132,10 +132,10 @@ namespace { } // namespace -Y_UNIT_TEST_SUITE(TJsonTest) { +Y_UNIT_TEST_SUITE(TJsonTest) { const TInstant now = TInstant::ParseIso8601Deprecated("2017-11-05T01:02:03Z"); - Y_UNIT_TEST(Encode) { + Y_UNIT_TEST(Encode) { auto check = [](bool cloud, bool buffered, TStringBuf expectedResourceKey) { TString json; TStringOutput out(json); @@ -353,7 +353,7 @@ Y_UNIT_TEST_SUITE(TJsonTest) { AssertPointEqual(s.GetPoints(0), TInstant::Zero(), ui64(1)); } } - Y_UNIT_TEST(Decode1) { + Y_UNIT_TEST(Decode1) { NProto::TMultiSamplesList samples; { IMetricEncoderPtr e = EncoderProtobuf(&samples); diff --git a/library/cpp/monlib/encode/spack/spack_v1_ut.cpp b/library/cpp/monlib/encode/spack/spack_v1_ut.cpp index ca3843f7e4..fe778eb7e0 100644 --- a/library/cpp/monlib/encode/spack/spack_v1_ut.cpp +++ b/library/cpp/monlib/encode/spack/spack_v1_ut.cpp @@ -48,7 +48,7 @@ void AssertPointEqual(const NProto::TPoint& p, TInstant time, i64 value) { UNIT_ASSERT_VALUES_EQUAL(p.GetInt64(), value); } -Y_UNIT_TEST_SUITE(TSpackTest) { +Y_UNIT_TEST_SUITE(TSpackTest) { ui8 expectedHeader_v1_0[] = { 0x53, 0x50, // magic "SP" (fixed ui16) // minor, major @@ -261,7 +261,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) { return MakeIntrusive<TSummaryDoubleSnapshot>(10.1, -0.45, 0.478, 0.3, 30u); } - Y_UNIT_TEST(Encode) { + Y_UNIT_TEST(Encode) { TBuffer buffer; TBufferOutput out(buffer); auto e = EncoderSpackV1( @@ -669,19 +669,19 @@ Y_UNIT_TEST_SUITE(TSpackTest) { } } - Y_UNIT_TEST(CompressionIdentity) { + Y_UNIT_TEST(CompressionIdentity) { TestCompression(ECompression::IDENTITY); } - Y_UNIT_TEST(CompressionZlib) { + Y_UNIT_TEST(CompressionZlib) { TestCompression(ECompression::ZLIB); } - Y_UNIT_TEST(CompressionZstd) { + Y_UNIT_TEST(CompressionZstd) { TestCompression(ECompression::ZSTD); } - Y_UNIT_TEST(CompressionLz4) { + Y_UNIT_TEST(CompressionLz4) { TestCompression(ECompression::LZ4); } diff --git a/library/cpp/monlib/encode/text/text_encoder_ut.cpp b/library/cpp/monlib/encode/text/text_encoder_ut.cpp index 3ae749dd51..554b6f5fa9 100644 --- a/library/cpp/monlib/encode/text/text_encoder_ut.cpp +++ b/library/cpp/monlib/encode/text/text_encoder_ut.cpp @@ -6,7 +6,7 @@ using namespace NMonitoring; -Y_UNIT_TEST_SUITE(TTextText) { +Y_UNIT_TEST_SUITE(TTextText) { template <typename TFunc> TString EncodeToString(bool humanReadableTs, TFunc fn) { TStringStream ss; @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TTextText) { return ss.Str(); } - Y_UNIT_TEST(Empty) { + Y_UNIT_TEST(Empty) { auto result = EncodeToString(true, [](IMetricEncoder* e) { e->OnStreamBegin(); e->OnStreamEnd(); @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TTextText) { UNIT_ASSERT_STRINGS_EQUAL(result, ""); } - Y_UNIT_TEST(CommonPart) { + Y_UNIT_TEST(CommonPart) { auto result = EncodeToString(true, [](IMetricEncoder* e) { e->OnStreamBegin(); e->OnCommonTime(TInstant::ParseIso8601Deprecated("2017-01-02T03:04:05.006Z")); @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TTextText) { "common labels: {project='solomon', cluster='man', service='stockpile'}\n"); } - Y_UNIT_TEST(Gauges) { + Y_UNIT_TEST(Gauges) { auto result = EncodeToString(true, [](IMetricEncoder* e) { e->OnStreamBegin(); { // no values @@ -157,7 +157,7 @@ Y_UNIT_TEST_SUITE(TTextText) { " IGAUGE bytesRx{host='solomon-sas-01', dc='sas'} [(2017-12-02T12:00:00Z, 2), (2017-12-02T12:00:05Z, 4), (2017-12-02T12:00:10Z, 8)]\n"); } - Y_UNIT_TEST(Counters) { + Y_UNIT_TEST(Counters) { auto doEncode = [](IMetricEncoder* e) { e->OnStreamBegin(); { // no values diff --git a/library/cpp/monlib/metrics/labels_ut.cpp b/library/cpp/monlib/metrics/labels_ut.cpp index 960e326d86..f0e4f532ab 100644 --- a/library/cpp/monlib/metrics/labels_ut.cpp +++ b/library/cpp/monlib/metrics/labels_ut.cpp @@ -4,11 +4,11 @@ using namespace NMonitoring; -Y_UNIT_TEST_SUITE(TLabelsTest) { +Y_UNIT_TEST_SUITE(TLabelsTest) { TLabel pSolomon("project", "solomon"); TLabel pKikimr("project", "kikimr"); - Y_UNIT_TEST(Equals) { + Y_UNIT_TEST(Equals) { UNIT_ASSERT(pSolomon == TLabel("project", "solomon")); UNIT_ASSERT_STRINGS_EQUAL(pSolomon.Name(), "project"); @@ -17,12 +17,12 @@ Y_UNIT_TEST_SUITE(TLabelsTest) { UNIT_ASSERT(pSolomon != pKikimr); } - Y_UNIT_TEST(ToString) { + Y_UNIT_TEST(ToString) { UNIT_ASSERT_STRINGS_EQUAL(pSolomon.ToString(), "project=solomon"); UNIT_ASSERT_STRINGS_EQUAL(pKikimr.ToString(), "project=kikimr"); } - Y_UNIT_TEST(FromString) { + Y_UNIT_TEST(FromString) { auto pYql = TLabel::FromString("project=yql"); UNIT_ASSERT_EQUAL(pYql, TLabel("project", "yql")); @@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TLabelsTest) { "label value cannot be empty"); } - Y_UNIT_TEST(TryFromString) { + Y_UNIT_TEST(TryFromString) { TLabel pYql; UNIT_ASSERT(TLabel::TryFromString("project=yql", pYql)); UNIT_ASSERT_EQUAL(pYql, TLabel("project", "yql")); @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TLabelsTest) { } } - Y_UNIT_TEST(Labels) { + Y_UNIT_TEST(Labels) { TLabels labels; UNIT_ASSERT(labels.Add(TStringBuf("name1"), TStringBuf("value1"))); UNIT_ASSERT(labels.Size() == 1); @@ -135,7 +135,7 @@ Y_UNIT_TEST_SUITE(TLabelsTest) { })); } - Y_UNIT_TEST(Hash) { + Y_UNIT_TEST(Hash) { TLabel label("name", "value"); UNIT_ASSERT_EQUAL(ULL(2378153472115172159), label.Hash()); diff --git a/library/cpp/monlib/metrics/metric_registry_ut.cpp b/library/cpp/monlib/metrics/metric_registry_ut.cpp index 8d030386ad..86d9a52ec0 100644 --- a/library/cpp/monlib/metrics/metric_registry_ut.cpp +++ b/library/cpp/monlib/metrics/metric_registry_ut.cpp @@ -38,7 +38,7 @@ void Out<NMonitoring::NProto::TSingleSample::ValueCase>(IOutputStream& os, NMoni } Y_UNIT_TEST_SUITE(TMetricRegistryTest) { - Y_UNIT_TEST(Gauge) { + Y_UNIT_TEST(Gauge) { TMetricRegistry registry(TLabels{{"common", "label"}}); TGauge* g = registry.Gauge({{"my", "gauge"}}); @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(TMetricRegistryTest) { UNIT_ASSERT_VALUES_EQUAL(g->Get(), val); } - Y_UNIT_TEST(Counter) { + Y_UNIT_TEST(Counter) { TMetricRegistry registry(TLabels{{"common", "label"}}); TCounter* c = registry.Counter({{"my", "counter"}}); @@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(TMetricRegistryTest) { UNIT_ASSERT_VALUES_EQUAL(r->Get(), 42); } - Y_UNIT_TEST(DoubleCounter) { + Y_UNIT_TEST(DoubleCounter) { TMetricRegistry registry(TLabels{{"common", "label"}}); TCounter* c = registry.Counter({{"my", "counter"}}); @@ -166,7 +166,7 @@ Y_UNIT_TEST_SUITE(TMetricRegistryTest) { UNIT_ASSERT_VALUES_EQUAL(c->Get(), 10); } - Y_UNIT_TEST(Sample) { + Y_UNIT_TEST(Sample) { TMetricRegistry registry(TLabels{{"common", "label"}}); TGauge* g = registry.Gauge({{"my", "gauge"}}); diff --git a/library/cpp/monlib/service/mon_service_http_request.h b/library/cpp/monlib/service/mon_service_http_request.h index 26cf39a5e5..b4f2f8f0c5 100644 --- a/library/cpp/monlib/service/mon_service_http_request.h +++ b/library/cpp/monlib/service/mon_service_http_request.h @@ -42,7 +42,7 @@ namespace NMonitoring { TMonService2HttpRequest* const Parent; TMonService2HttpRequest( - IOutputStream* out, const IHttpRequest* httpRequest, + IOutputStream* out, const IHttpRequest* httpRequest, TMonService2* monService, IMonPage* monPage, const TString& pathInfo, TMonService2HttpRequest* parent) diff --git a/library/cpp/monlib/service/monservice.cpp b/library/cpp/monlib/service/monservice.cpp index 25d8922672..d1b9cda1d2 100644 --- a/library/cpp/monlib/service/monservice.cpp +++ b/library/cpp/monlib/service/monservice.cpp @@ -23,7 +23,7 @@ TMonService2::TMonService2(const THttpServerOptions& options, const TString& tit , IndexMonPage(new TIndexMonPage("", Title)) , AuthProvider_{std::move(auth)} { - Y_VERIFY(!!title); + Y_VERIFY(!!title); time_t t = time(nullptr); ctime_r(&t, StartTime); } @@ -79,7 +79,7 @@ void TMonService2::OutputIndexBody(IOutputStream& out) { void TMonService2::ServeRequest(IOutputStream& out, const NMonitoring::IHttpRequest& request) { TString path = request.GetPath(); - Y_VERIFY(path.StartsWith('/')); + Y_VERIFY(path.StartsWith('/')); if (AuthProvider_) { const auto authResult = AuthProvider_->Check(request); diff --git a/library/cpp/monlib/service/pages/index_mon_page.cpp b/library/cpp/monlib/service/pages/index_mon_page.cpp index 1d6227ff03..83ff8b529a 100644 --- a/library/cpp/monlib/service/pages/index_mon_page.cpp +++ b/library/cpp/monlib/service/pages/index_mon_page.cpp @@ -53,8 +53,8 @@ void TIndexMonPage::Output(IMonHttpRequest& request) { void TIndexMonPage::OutputIndex(IOutputStream& out, bool pathEndsWithSlash) { TGuard<TMutex> g(Mtx); - for (auto& Page : Pages) { - IMonPage* page = Page.Get(); + for (auto& Page : Pages) { + IMonPage* page = Page.Get(); if (page->IsInIndex()) { TString pathToDir = ""; if (!pathEndsWithSlash) { @@ -97,7 +97,7 @@ TIndexMonPage* TIndexMonPage::RegisterIndexPage(const TString& path, const TStri IMonPage* TIndexMonPage::FindPage(const TString& relativePath) { TGuard<TMutex> g(Mtx); - Y_VERIFY(!relativePath.StartsWith('/')); + Y_VERIFY(!relativePath.StartsWith('/')); TPagesByPath::iterator i = PagesByPath.find("/" + relativePath); if (i == PagesByPath.end()) { return nullptr; @@ -110,7 +110,7 @@ TIndexMonPage* TIndexMonPage::FindIndexPage(const TString& relativePath) { return VerifyDynamicCast<TIndexMonPage*>(FindPage(relativePath)); } -void TIndexMonPage::OutputCommonJsCss(IOutputStream& out) { +void TIndexMonPage::OutputCommonJsCss(IOutputStream& out) { out << "<link rel='stylesheet' href='https://yastatic.net/bootstrap/3.3.1/css/bootstrap.min.css'>\n"; out << "<script language='javascript' type='text/javascript' src='https://yastatic.net/jquery/2.1.3/jquery.min.js'></script>\n"; out << "<script language='javascript' type='text/javascript' src='https://yastatic.net/bootstrap/3.3.1/js/bootstrap.min.js'></script>\n"; diff --git a/library/cpp/monlib/service/pages/mon_page.cpp b/library/cpp/monlib/service/pages/mon_page.cpp index 4d53beff06..72033b1699 100644 --- a/library/cpp/monlib/service/pages/mon_page.cpp +++ b/library/cpp/monlib/service/pages/mon_page.cpp @@ -6,8 +6,8 @@ IMonPage::IMonPage(const TString& path, const TString& title) : Path(path) , Title(title) { - Y_VERIFY(!Path.StartsWith('/')); - Y_VERIFY(!Path.EndsWith('/')); + Y_VERIFY(!Path.StartsWith('/')); + Y_VERIFY(!Path.EndsWith('/')); } void IMonPage::OutputNavBar(IOutputStream& out) { diff --git a/library/cpp/monlib/service/pages/templates.h b/library/cpp/monlib/service/pages/templates.h index ca98447ac5..b4656f059f 100644 --- a/library/cpp/monlib/service/pages/templates.h +++ b/library/cpp/monlib/service/pages/templates.h @@ -188,12 +188,12 @@ namespace NMonitoring { }; struct TOutputStreamRef { - TOutputStreamRef(IOutputStream& str) + TOutputStreamRef(IOutputStream& str) : Str(str) { } - inline operator IOutputStream&() noexcept { + inline operator IOutputStream&() noexcept { return Str; } @@ -201,7 +201,7 @@ namespace NMonitoring { return true; // just to work with WITH_SCOPED } - IOutputStream& Str; + IOutputStream& Str; }; extern const char HtmlTag[5]; diff --git a/library/cpp/monlib/service/service.cpp b/library/cpp/monlib/service/service.cpp index e486b15dd4..929efbf816 100644 --- a/library/cpp/monlib/service/service.cpp +++ b/library/cpp/monlib/service/service.cpp @@ -8,7 +8,7 @@ #include <util/generic/buffer.h> #include <util/stream/str.h> -#include <util/stream/buffer.h> +#include <util/stream/buffer.h> #include <util/stream/zerocopy.h> #include <util/string/vector.h> @@ -30,7 +30,7 @@ namespace NMonitoring { return; } TString path = GetPath(); - if (!path.StartsWith('/')) { + if (!path.StartsWith('/')) { out << "HTTP/1.1 400 Bad request\r\nConnection: Close\r\n\r\n"; return; } @@ -165,7 +165,7 @@ namespace NMonitoring { throw; // just rethrow } - void TCoHttpServer::ProcessRequest(IOutputStream& out, const IHttpRequest& request) { + void TCoHttpServer::ProcessRequest(IOutputStream& out, const IHttpRequest& request) { try { TNetworkAddress addr(BindAddr, Port); TSocket sock(addr); @@ -257,7 +257,7 @@ namespace NMonitoring { CoServer.Stop(); } - void TMonService::DispatchRequest(IOutputStream& out, const IHttpRequest& request) { + void TMonService::DispatchRequest(IOutputStream& out, const IHttpRequest& request) { if (strcmp(request.GetPath(), "/") == 0) { out << "HTTP/1.1 200 Ok\nConnection: Close\n\n"; MtHandler(out, request); diff --git a/library/cpp/monlib/service/service.h b/library/cpp/monlib/service/service.h index 6aa112902e..2f66dddaf8 100644 --- a/library/cpp/monlib/service/service.h +++ b/library/cpp/monlib/service/service.h @@ -41,7 +41,7 @@ namespace NMonitoring { // by forwarding it to the httpserver // @note this call may be blocking; don't use inside coroutines // @throws may throw in case of connection error, etc - void ProcessRequest(IOutputStream&, const IHttpRequest&); + void ProcessRequest(IOutputStream&, const IHttpRequest&); private: class TConnection; @@ -101,7 +101,7 @@ namespace NMonitoring { void Stop(); protected: - void DispatchRequest(IOutputStream& out, const IHttpRequest&); + void DispatchRequest(IOutputStream& out, const IHttpRequest&); private: TCoHttpServer CoServer; diff --git a/library/cpp/object_factory/object_factory_ut.cpp b/library/cpp/object_factory/object_factory_ut.cpp index be9558d8e9..06fb0739ff 100644 --- a/library/cpp/object_factory/object_factory_ut.cpp +++ b/library/cpp/object_factory/object_factory_ut.cpp @@ -142,8 +142,8 @@ struct TDirectOrderDSCreator: public IFactoryObjectCreator<ICommonInterface, con static TTestFactory::TRegistrator<TDirectOrderDifferentSignature> DirectDs("direct_ds", new TDirectOrderDSCreator); -Y_UNIT_TEST_SUITE(TestObjectFactory) { - Y_UNIT_TEST(TestParametrized) { +Y_UNIT_TEST_SUITE(TestObjectFactory) { + Y_UNIT_TEST(TestParametrized) { TArgument directArg{"Name", nullptr}; TArgument inverseArg{"Fake", nullptr}; THolder<ICommonInterface> direct(TTestFactory::Construct("direct", "prov", 0.42, directArg)); diff --git a/library/cpp/on_disk/chunks/chunked_helpers.cpp b/library/cpp/on_disk/chunks/chunked_helpers.cpp index e0bd21bf7c..b7adba2753 100644 --- a/library/cpp/on_disk/chunks/chunked_helpers.cpp +++ b/library/cpp/on_disk/chunks/chunked_helpers.cpp @@ -37,7 +37,7 @@ TNamedChunkedDataReader::TNamedChunkedDataReader(const TBlob& blob) /*************************** TNamedChunkedDataWriter ***************************/ -TNamedChunkedDataWriter::TNamedChunkedDataWriter(IOutputStream& slave) +TNamedChunkedDataWriter::TNamedChunkedDataWriter(IOutputStream& slave) : TChunkedDataWriter(slave) { } diff --git a/library/cpp/on_disk/chunks/chunked_helpers.h b/library/cpp/on_disk/chunks/chunked_helpers.h index 4b04771c31..5fa96afdca 100644 --- a/library/cpp/on_disk/chunks/chunked_helpers.h +++ b/library/cpp/on_disk/chunks/chunked_helpers.h @@ -8,15 +8,15 @@ #include <util/memory/blob.h> #include <util/stream/buffer.h> #include <util/stream/mem.h> -#include <util/system/unaligned_mem.h> +#include <util/system/unaligned_mem.h> #include <util/ysaveload.h> #include "reader.h" #include "writer.h" #include <cmath> -#include <cstddef> - +#include <cstddef> + template <typename T> class TYVector { private: @@ -25,14 +25,14 @@ private: public: TYVector(const TBlob& blob) - : Size(IntegerCast<ui32>(ReadUnaligned<ui64>(blob.Data()))) + : Size(IntegerCast<ui32>(ReadUnaligned<ui64>(blob.Data()))) , Data((const T*)((const char*)blob.Data() + sizeof(ui64))) { } void Get(size_t idx, T& t) const { assert(idx < (size_t)Size); - t = ReadUnaligned<T>(Data + idx); + t = ReadUnaligned<T>(Data + idx); } const T& At(size_t idx) const { @@ -63,7 +63,7 @@ public: Vector.push_back(value); } - void Save(IOutputStream& out) const { + void Save(IOutputStream& out) const { ui64 uSize = (ui64)Vector.size(); out.Write(&uSize, sizeof(uSize)); out.Write(Vector.data(), Vector.size() * sizeof(T)); @@ -172,16 +172,16 @@ protected: typename TTypeTraits<TValue>::TFuncParam Second() const { return Value; } - - static TKey GetFirst(const void* self) { - static constexpr size_t offset = offsetof(TThis, Key); + + static TKey GetFirst(const void* self) { + static constexpr size_t offset = offsetof(TThis, Key); return ReadUnaligned<TKey>(reinterpret_cast<const char*>(self) + offset); - } - - static TValue GetSecond(const void* self) { - static constexpr size_t offset = offsetof(TThis, Value); + } + + static TValue GetSecond(const void* self) { + static constexpr size_t offset = offsetof(TThis, Value); return ReadUnaligned<TValue>(reinterpret_cast<const char*>(self) + offset); - } + } }; #pragma pack(pop) @@ -221,10 +221,10 @@ protected: template <typename TKey> static ui32 KeyHash(typename TTypeTraits<TKey>::TFuncParam key, ui16 bits) { - Y_ASSERT(bits < 32); + Y_ASSERT(bits < 32); const ui32 res = ui32(key) & ((ui32(1) << bits) - 1); - Y_ASSERT(res < (ui32(1) << bits)); + Y_ASSERT(res < (ui32(1) << bits)); return res; } }; @@ -240,7 +240,7 @@ private: bool IsPlainEnought(ui16 bits) const { TVector<size_t> counts(1LL << bits, 0); for (size_t i = 0; i < Data.size(); ++i) { - size_t& count = counts[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)]; + size_t& count = counts[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)]; ++count; if (count > 2) return false; @@ -253,8 +253,8 @@ public: Data.push_back(TKeyValuePair(key, value)); } - void Save(IOutputStream& out) const { - Y_ASSERT(Data.size() < Max<ui32>()); + void Save(IOutputStream& out) const { + Y_ASSERT(Data.size() < Max<ui32>()); WriteBin<ui16>(&out, VERSION_ID); static const ui32 PAIR_SIZE = sizeof(TKeyValuePair); @@ -274,7 +274,7 @@ public: const ui32 nBuckets = ui32(1) << bits; TData2 data2(nBuckets); for (size_t i = 0; i < Data.size(); ++i) - data2[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)].push_back(Data[i]); + data2[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)].push_back(Data[i]); typedef TVector<TInterval> TIntervals; TIntervals intervals(nBuckets); @@ -288,7 +288,7 @@ public: for (ui32 i = 0; i < nBuckets; ++i) { for (size_t j = 0; j < data2[i].size(); ++j) for (size_t k = j + 1; k < data2[i].size(); ++k) - if (TKeyValuePair::GetFirst(&data2[i][j]) == TKeyValuePair::GetFirst(&data2[i][k])) + if (TKeyValuePair::GetFirst(&data2[i][j]) == TKeyValuePair::GetFirst(&data2[i][k])) ythrow yexception() << "key clash"; } #endif @@ -306,11 +306,11 @@ private: const char* P; ui16 GetBits() const { - return ReadUnaligned<ui16>(P + 6); + return ReadUnaligned<ui16>(P + 6); } ui32 GetSize() const { - return ReadUnaligned<ui32>(P + 8); + return ReadUnaligned<ui32>(P + 8); } const TInterval* GetIntervals() const { @@ -326,11 +326,11 @@ private: static_assert(sizeof(T) == 1, "expect sizeof(T) == 1"); P = reinterpret_cast<const char*>(p); #ifndef NDEBUG - ui16 version = ReadUnaligned<ui16>(p); + ui16 version = ReadUnaligned<ui16>(p); if (version != VERSION_ID) ythrow yexception() << "bad version: " << version; static const ui32 PAIR_SIZE = sizeof(TKeyValuePair); - const ui32 size = ReadUnaligned<ui32>(p + 2); + const ui32 size = ReadUnaligned<ui32>(p + 2); if (size != PAIR_SIZE) ythrow yexception() << "bad size " << size << " instead of " << PAIR_SIZE; #endif @@ -354,8 +354,8 @@ public: const TKeyValuePair* pair = GetData() + TInterval::GetOffset(intervalPtr + hash); const ui32 length = TInterval::GetLength(intervalPtr + hash); for (ui32 i = 0; i < length; ++i, ++pair) { - if (TKeyValuePair::GetFirst(pair) == key) { - *res = TKeyValuePair::GetSecond(pair); + if (TKeyValuePair::GetFirst(pair) == key) { + *res = TKeyValuePair::GetSecond(pair); return true; } } @@ -407,8 +407,8 @@ private: public: TSingleValue(const TBlob& blob) { - Y_ASSERT(blob.Length() >= sizeof(T)); - Y_ASSERT(blob.Length() <= sizeof(T) + 16); + Y_ASSERT(blob.Length() >= sizeof(T)); + Y_ASSERT(blob.Length() <= sizeof(T) + 16); Value = reinterpret_cast<const T*>(blob.Begin()); } @@ -434,7 +434,7 @@ public: Value = value; } - void Save(IOutputStream& out) const { + void Save(IOutputStream& out) const { out.Write(&Value, sizeof(Value)); } }; @@ -528,12 +528,12 @@ private: template <class T> struct TSaveLoadVectorNonPodElement { - static inline void Save(IOutputStream* out, const T& t) { + static inline void Save(IOutputStream* out, const T& t) { TSerializer<T>::Save(out, t); } - static inline void Load(IInputStream* in, T& t, size_t elementSize) { - Y_ASSERT(elementSize > 0); + static inline void Load(IInputStream* in, T& t, size_t elementSize) { + Y_ASSERT(elementSize > 0); TSerializer<T>::Load(in, t); } }; @@ -547,8 +547,8 @@ private: public: TVectorTakingIntoAccountThePodType(const TBlob& blob) { - SizeofOffsets = ReadUnaligned<ui64>(blob.Begin()); - Y_ASSERT(SizeofOffsets > 0); + SizeofOffsets = ReadUnaligned<ui64>(blob.Begin()); + Y_ASSERT(SizeofOffsets > 0); Offsets = reinterpret_cast<const ui64*>(blob.Begin() + sizeof(ui64)); Data = reinterpret_cast<const char*>(blob.Begin() + sizeof(ui64) + SizeofOffsets * sizeof(ui64)); } @@ -560,12 +560,12 @@ public: size_t GetLength(ui64 index) const { if (index + 1 >= SizeofOffsets) ythrow yexception() << "bad offset"; - return IntegerCast<size_t>(ReadUnaligned<ui64>(Offsets + index + 1) - ReadUnaligned<ui64>(Offsets + index)); + return IntegerCast<size_t>(ReadUnaligned<ui64>(Offsets + index + 1) - ReadUnaligned<ui64>(Offsets + index)); } void Get(ui64 index, T& t) const { const size_t len = GetLength(index); - TMemoryInput input(Data + ReadUnaligned<ui64>(Offsets + index), len); + TMemoryInput input(Data + ReadUnaligned<ui64>(Offsets + index), len); TSaveLoadVectorNonPodElement<T>::Load(&input, t, len); } @@ -603,7 +603,7 @@ public: return Offsets.size(); } - void Save(IOutputStream& out) const { + void Save(IOutputStream& out) const { ui64 sizeofOffsets = Offsets.size() + 1; out.Write(&sizeofOffsets, sizeof(sizeofOffsets)); out.Write(Offsets.data(), Offsets.size() * sizeof(Offsets[0])); @@ -656,12 +656,12 @@ struct TGeneralVectorG<TItem, true> { template <> struct TSaveLoadVectorNonPodElement<TString> { - static inline void Save(IOutputStream* out, const TString& s) { + static inline void Save(IOutputStream* out, const TString& s) { out->Write(s.data(), s.size() + 1); } static inline void Load(TMemoryInput* in, TString& s, size_t elementSize) { - Y_ASSERT(elementSize > 0 && in->Avail() >= elementSize); + Y_ASSERT(elementSize > 0 && in->Avail() >= elementSize); s.assign(in->Buf(), elementSize - 1); /// excluding 0 at the end } }; diff --git a/library/cpp/on_disk/chunks/chunks_ut.cpp b/library/cpp/on_disk/chunks/chunks_ut.cpp index 2be71e9108..f727647f7f 100644 --- a/library/cpp/on_disk/chunks/chunks_ut.cpp +++ b/library/cpp/on_disk/chunks/chunks_ut.cpp @@ -20,13 +20,13 @@ struct TPodStruct { template <> struct TSaveLoadVectorNonPodElement<TPodStruct> { typedef TPodStruct TItem; - static inline void Save(IOutputStream* out, const TItem& item) { + static inline void Save(IOutputStream* out, const TItem& item) { TSerializer<int>::Save(out, item.x); TSerializer<float>::Save(out, item.y); } - static inline void Load(IInputStream* in, TItem& item, size_t elementSize) { - Y_ASSERT(elementSize == sizeof(TItem)); + static inline void Load(IInputStream* in, TItem& item, size_t elementSize) { + Y_ASSERT(elementSize == sizeof(TItem)); TSerializer<int>::Load(in, item.x); TSerializer<float>::Load(in, item.y); } diff --git a/library/cpp/on_disk/chunks/reader.cpp b/library/cpp/on_disk/chunks/reader.cpp index c4ba350f11..6e28cbf367 100644 --- a/library/cpp/on_disk/chunks/reader.cpp +++ b/library/cpp/on_disk/chunks/reader.cpp @@ -1,6 +1,6 @@ #include <util/generic/cast.h> #include <util/memory/blob.h> -#include <util/system/unaligned_mem.h> +#include <util/system/unaligned_mem.h> #include "reader.h" @@ -8,7 +8,7 @@ template <typename T> static inline void ReadAux(const char* data, T* aux, T count, TVector<const char*>* result) { result->resize(count); for (size_t i = 0; i < count; ++i) { - (*result)[i] = data + ReadUnaligned<T>(aux + i); + (*result)[i] = data + ReadUnaligned<T>(aux + i); } } @@ -17,7 +17,7 @@ TChunkedDataReader::TChunkedDataReader(const TBlob& blob) { const size_t size = blob.Size(); Y_ENSURE(size >= sizeof(ui32), "Empty file with chunks. "); - ui32 last = ReadUnaligned<ui32>((ui32*)(cdata + size) - 1); + ui32 last = ReadUnaligned<ui32>((ui32*)(cdata + size) - 1); if (last != 0) { // old version file ui32* aux = (ui32*)(cdata + size); @@ -32,10 +32,10 @@ TChunkedDataReader::TChunkedDataReader(const TBlob& blob) { Y_ENSURE(size >= 3 * sizeof(ui64), "Blob size must be >= 3 * sizeof(ui64). "); ui64* aux = (ui64*)(cdata + size); - Version = ReadUnaligned<ui64>(aux - 2); + Version = ReadUnaligned<ui64>(aux - 2); Y_ENSURE(Version > 0, "Invalid chunked array version. "); - ui64 count = ReadUnaligned<ui64>(aux - 3); + ui64 count = ReadUnaligned<ui64>(aux - 3); aux -= (count + 3); ReadAux<ui64>(cdata, aux, count, &Offsets); @@ -43,7 +43,7 @@ TChunkedDataReader::TChunkedDataReader(const TBlob& blob) { aux -= count; Lengths.resize(count); for (size_t i = 0; i < count; ++i) { - Lengths[i] = IntegerCast<size_t>(ReadUnaligned<ui64>(aux + i)); + Lengths[i] = IntegerCast<size_t>(ReadUnaligned<ui64>(aux + i)); } } diff --git a/library/cpp/on_disk/chunks/writer.cpp b/library/cpp/on_disk/chunks/writer.cpp index c605f1e79e..6dc7397f09 100644 --- a/library/cpp/on_disk/chunks/writer.cpp +++ b/library/cpp/on_disk/chunks/writer.cpp @@ -8,7 +8,7 @@ static inline void WriteAux(IOutputStream* out, const TVector<ui64>& data) { /*************************** TBuffersWriter ***************************/ -TChunkedDataWriter::TChunkedDataWriter(IOutputStream& slave) +TChunkedDataWriter::TChunkedDataWriter(IOutputStream& slave) : Slave(slave) , Offset(0) { @@ -36,8 +36,8 @@ void TChunkedDataWriter::WriteFooter() { } size_t TChunkedDataWriter::GetCurrentBlockOffset() const { - Y_ASSERT(!Offsets.empty()); - Y_ASSERT(Offset >= Offsets.back()); + Y_ASSERT(!Offsets.empty()); + Y_ASSERT(Offset >= Offsets.back()); return Offset - Offsets.back(); } diff --git a/library/cpp/on_disk/chunks/writer.h b/library/cpp/on_disk/chunks/writer.h index aace042949..ab14522bdd 100644 --- a/library/cpp/on_disk/chunks/writer.h +++ b/library/cpp/on_disk/chunks/writer.h @@ -4,11 +4,11 @@ #include <util/stream/output.h> template <typename T> -inline void WriteBin(IOutputStream* out, typename TTypeTraits<T>::TFuncParam t) { +inline void WriteBin(IOutputStream* out, typename TTypeTraits<T>::TFuncParam t) { out->Write(&t, sizeof(T)); } -class TChunkedDataWriter: public IOutputStream { +class TChunkedDataWriter: public IOutputStream { public: TChunkedDataWriter(IOutputStream& slave); ~TChunkedDataWriter() override; diff --git a/library/cpp/openssl/io/stream.cpp b/library/cpp/openssl/io/stream.cpp index 1eda85d00f..0b4be38c0e 100644 --- a/library/cpp/openssl/io/stream.cpp +++ b/library/cpp/openssl/io/stream.cpp @@ -122,7 +122,7 @@ namespace { }; struct TSslIO: public TSslInitOnDemand, public TOptions { - inline TSslIO(IInputStream* in, IOutputStream* out, const TOptions& opts) + inline TSslIO(IInputStream* in, IOutputStream* out, const TOptions& opts) : TOptions(opts) , Io(in, out) , Ctx(CreateClientContext()) @@ -240,18 +240,18 @@ namespace { } struct TOpenSslClientIO::TImpl: public TSslIO { - inline TImpl(IInputStream* in, IOutputStream* out, const TOptions& opts) + inline TImpl(IInputStream* in, IOutputStream* out, const TOptions& opts) : TSslIO(in, out, opts) { } }; -TOpenSslClientIO::TOpenSslClientIO(IInputStream* in, IOutputStream* out) +TOpenSslClientIO::TOpenSslClientIO(IInputStream* in, IOutputStream* out) : Impl_(new TImpl(in, out, TOptions())) { } -TOpenSslClientIO::TOpenSslClientIO(IInputStream* in, IOutputStream* out, const TOptions& options) +TOpenSslClientIO::TOpenSslClientIO(IInputStream* in, IOutputStream* out, const TOptions& options) : Impl_(new TImpl(in, out, options)) { } diff --git a/library/cpp/openssl/io/stream.h b/library/cpp/openssl/io/stream.h index 8131f8bd0d..7bca8f80ef 100644 --- a/library/cpp/openssl/io/stream.h +++ b/library/cpp/openssl/io/stream.h @@ -2,10 +2,10 @@ #include <util/generic/maybe.h> #include <util/generic/ptr.h> -#include <util/stream/input.h> -#include <util/stream/output.h> +#include <util/stream/input.h> +#include <util/stream/output.h> -class TOpenSslClientIO: public IInputStream, public IOutputStream { +class TOpenSslClientIO: public IInputStream, public IOutputStream { public: struct TOptions { struct TVerifyCert { @@ -25,8 +25,8 @@ public: // TODO - keys, cyphers, etc }; - TOpenSslClientIO(IInputStream* in, IOutputStream* out); - TOpenSslClientIO(IInputStream* in, IOutputStream* out, const TOptions& options); + TOpenSslClientIO(IInputStream* in, IOutputStream* out); + TOpenSslClientIO(IInputStream* in, IOutputStream* out, const TOptions& options); ~TOpenSslClientIO() override; private: diff --git a/library/cpp/packedtypes/longs.h b/library/cpp/packedtypes/longs.h index 91432bf007..084098d705 100644 --- a/library/cpp/packedtypes/longs.h +++ b/library/cpp/packedtypes/longs.h @@ -2,7 +2,7 @@ #include <util/system/defaults.h> // _BIDSCLASS _EXPCLASS #include <util/system/yassert.h> -#include <util/system/unaligned_mem.h> +#include <util/system/unaligned_mem.h> #define PUT_8(x, buf, shift) WriteUnaligned<ui8>((buf)++, (x) >> (shift)) #define GET_8_OR(x, buf, type, shift) (x) |= (type) * (buf)++ << (shift) @@ -310,9 +310,9 @@ template <typename T, typename C> inline const C* Unpack32(T& x, const C* src) { int pkLen = 0; const char* c = reinterpret_cast<const char*>(src); - Y_UNUSED(pkLen); + Y_UNUSED(pkLen); UNPACK_32(x, c, mem_traits, pkLen); - Y_ASSERT(pkLen); + Y_ASSERT(pkLen); return reinterpret_cast<const C*>(c); } @@ -320,28 +320,28 @@ template <typename T, typename C> inline const C* Unpack64(T& x, const C* src) { int pkLen = 0; const char* c = reinterpret_cast<const char*>(src); - Y_UNUSED(pkLen); + Y_UNUSED(pkLen); UNPACK_64(x, c, mem_traits, pkLen); - Y_ASSERT(pkLen); + Y_ASSERT(pkLen); return reinterpret_cast<const C*>(c); } template <typename T, typename C> inline C* Pack32(const T& x, C* dest) { int pkLen = 0; - Y_UNUSED(pkLen); + Y_UNUSED(pkLen); char* c = reinterpret_cast<char*>(dest); PACK_32(x, c, mem_traits, pkLen); - Y_ASSERT(pkLen); + Y_ASSERT(pkLen); return reinterpret_cast<C*>(c); } template <typename T, typename C> inline C* Pack64(const T& x, C* dest) { int pkLen = 0; - Y_UNUSED(pkLen); + Y_UNUSED(pkLen); char* c = reinterpret_cast<char*>(dest); PACK_64(x, c, mem_traits, pkLen); - Y_ASSERT(pkLen); + Y_ASSERT(pkLen); return reinterpret_cast<C*>(c); } diff --git a/library/cpp/packedtypes/longs_ut.cpp b/library/cpp/packedtypes/longs_ut.cpp index 9ff51d2128..8b06c934d2 100644 --- a/library/cpp/packedtypes/longs_ut.cpp +++ b/library/cpp/packedtypes/longs_ut.cpp @@ -4,11 +4,11 @@ #include <library/cpp/digest/old_crc/crc.h> #include <util/string/util.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/system/hi_lo.h> -Y_UNIT_TEST_SUITE(TLongsTest) { - Y_UNIT_TEST(TestLongs) { +Y_UNIT_TEST_SUITE(TLongsTest) { + Y_UNIT_TEST(TestLongs) { i16 x16 = 40; i64 x64 = 40; i64 y64; @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TLongsTest) { } } - Y_UNIT_TEST(TestCornerCases) { + Y_UNIT_TEST(TestCornerCases) { TestCornerCasesImpl<i32>(31); TestCornerCasesImpl<i64>(63); } diff --git a/library/cpp/packedtypes/packed.h b/library/cpp/packedtypes/packed.h index b741fec77e..88cff26ae2 100644 --- a/library/cpp/packedtypes/packed.h +++ b/library/cpp/packedtypes/packed.h @@ -2,34 +2,34 @@ #include <library/cpp/streams/zc_memory_input/zc_memory_input.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/ysaveload.h> #include "longs.h" struct Stream_traits { template <typename T> - static T get(IInputStream& in) { + static T get(IInputStream& in) { T x; ::Load(&in, x); return x; } - static ui8 get_8(IInputStream& in) { + static ui8 get_8(IInputStream& in) { return get<ui8>(in); } - static ui16 get_16(IInputStream& in) { + static ui16 get_16(IInputStream& in) { return get<ui16>(in); } - static ui32 get_32(IInputStream& in) { + static ui32 get_32(IInputStream& in) { return get<ui32>(in); } - static void put_8(ui8 x, IOutputStream& out) { + static void put_8(ui8 x, IOutputStream& out) { ::Save(&out, x); } - static void put_16(ui16 x, IOutputStream& out) { + static void put_16(ui16 x, IOutputStream& out) { ::Save(&out, x); } - static void put_32(ui32 x, IOutputStream& out) { + static void put_32(ui32 x, IOutputStream& out) { ::Save(&out, x); } static int is_good(IInputStream& /*in*/) { diff --git a/library/cpp/packedtypes/packed_ut.cpp b/library/cpp/packedtypes/packed_ut.cpp index 5d0d11b427..70a22cf9c3 100644 --- a/library/cpp/packedtypes/packed_ut.cpp +++ b/library/cpp/packedtypes/packed_ut.cpp @@ -14,7 +14,7 @@ static ui64 gSeed = 42; template<typename T> static T PseudoRandom(T max = Max<T>()) { - Y_ASSERT(max != 0); + Y_ASSERT(max != 0); // stupid and non-threadsafe, but very predictable chaos generator gSeed += 1; gSeed *= 419; @@ -24,7 +24,7 @@ static T PseudoRandom(T max = Max<T>()) { #endif } -Y_UNIT_TEST_SUITE(TPackedTest) { +Y_UNIT_TEST_SUITE(TPackedTest) { void TestPackUi32Sub(ui32 v, const TVector<char>& p) { TBufferOutput out; PackUI32(out, v); @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TPackedTest) { } } - Y_UNIT_TEST(TestPackUi32) { + Y_UNIT_TEST(TestPackUi32) { ui32 v; TVector<char> pv; @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(TPackedTest) { } #if 0 - Y_UNIT_TEST(ReadWrite32) { + Y_UNIT_TEST(ReadWrite32) { TBuffer buffer(65536); char* writePtr = buffer.Data(); @@ -108,7 +108,7 @@ Y_UNIT_TEST_SUITE(TPackedTest) { } } - Y_UNIT_TEST(ReadWrite64) { + Y_UNIT_TEST(ReadWrite64) { TBuffer buffer(65536); char* writePtr = buffer.Data(); diff --git a/library/cpp/packedtypes/zigzag_ut.cpp b/library/cpp/packedtypes/zigzag_ut.cpp index f7fd1f5710..13b78b7481 100644 --- a/library/cpp/packedtypes/zigzag_ut.cpp +++ b/library/cpp/packedtypes/zigzag_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TZigZagTest) { +Y_UNIT_TEST_SUITE(TZigZagTest) { template <typename T> void TestEncodeDecode(T value) { auto encoded = ZigZagEncode(value); @@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TZigZagTest) { TestEncodeDecode((TSignedInt)-123); } - Y_UNIT_TEST(TestSigned) { + Y_UNIT_TEST(TestSigned) { TestImpl<i16>(); TestImpl<i32>(); TestImpl<i64>(); diff --git a/library/cpp/packers/packers.h b/library/cpp/packers/packers.h index 2e06a0d833..1bde1b59aa 100644 --- a/library/cpp/packers/packers.h +++ b/library/cpp/packers/packers.h @@ -5,7 +5,7 @@ #include <util/generic/set.h> #include <util/generic/list.h> #include <util/generic/vector.h> -#include <util/generic/bitops.h> +#include <util/generic/bitops.h> #include <array> // Data serialization strategy class. @@ -37,11 +37,11 @@ public: memcpy(&t, p, sizeof(T)); } void PackLeaf(char* buffer, const T& data, size_t computedSize) const { - Y_ASSERT(computedSize == sizeof(data)); + Y_ASSERT(computedSize == sizeof(data)); memcpy(buffer, &data, sizeof(T)); } size_t MeasureLeaf(const T& data) const { - Y_UNUSED(data); + Y_UNUSED(data); return sizeof(T); } size_t SkipLeaf(const char*) const { @@ -211,14 +211,14 @@ namespace NPackers { TFloat FromUInt(TUInt u) const { THelper h; - h.U = ReverseBytes(u); + h.U = ReverseBytes(u); return h.F; } TUInt ToUInt(TFloat f) const { THelper h; h.F = f; - return ReverseBytes(h.U); + return ReverseBytes(h.U); } public: @@ -416,7 +416,7 @@ namespace NPackers { TElementPacker().PackLeaf(buffer + curSize, *p, sizeChange); curSize += sizeChange; } - Y_ASSERT(curSize == size); + Y_ASSERT(curSize == size); } template <class C, class EP> @@ -430,7 +430,7 @@ namespace NPackers { // e.g. when curSize is 127 and stays in one byte, but curSize + 1 requires two bytes. extraSize = TIntegralPacker<size_t>().MeasureLeaf(curSize + extraSize); - Y_ASSERT(extraSize == TIntegralPacker<size_t>().MeasureLeaf(curSize + extraSize)); + Y_ASSERT(extraSize == TIntegralPacker<size_t>().MeasureLeaf(curSize + extraSize)); return curSize + extraSize; } @@ -469,7 +469,7 @@ namespace NPackers { TPacker1().PackLeaf(buffer, data.first, size1); size_t size2 = TPacker2().MeasureLeaf(data.second); TPacker2().PackLeaf(buffer + size1, data.second, size2); - Y_ASSERT(size == size1 + size2); + Y_ASSERT(size == size1 + size2); } template <class T1, class T2, class TPacker1, class TPacker2> @@ -600,12 +600,12 @@ namespace NPackers { class TPacker<TSet<T>>: public TContainerPacker<TSet<T>> { }; - template <class T1, class T2> + template <class T1, class T2> class TPacker<std::pair<T1, T2>>: public TPairPacker<T1, T2> { }; - template <class T, size_t N> + template <class T, size_t N> class TPacker<std::array<T, N>>: public TArrayPacker<std::array<T, N>> { - }; + }; } diff --git a/library/cpp/packers/ut/packers_ut.cpp b/library/cpp/packers/ut/packers_ut.cpp index 9318782f80..18ce2150d1 100644 --- a/library/cpp/packers/ut/packers_ut.cpp +++ b/library/cpp/packers/ut/packers_ut.cpp @@ -1,6 +1,6 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <utility> #include <util/charset/wide.h> @@ -75,7 +75,7 @@ void TPackersTest::TestPackers() { TestPacker<TString, NPackers::TPacker<TString>>(test, Y_ARRAY_SIZE(test)); - for (size_t i = 0; i != Y_ARRAY_SIZE(test); ++i) { + for (size_t i = 0; i != Y_ARRAY_SIZE(test); ++i) { TestPacker<TUtf16String, NPackers::TPacker<TUtf16String>>(UTF8ToWide(test[i])); } } diff --git a/library/cpp/packers/ut/proto_packer_ut.cpp b/library/cpp/packers/ut/proto_packer_ut.cpp index a89d6a74a0..e4151ba68c 100644 --- a/library/cpp/packers/ut/proto_packer_ut.cpp +++ b/library/cpp/packers/ut/proto_packer_ut.cpp @@ -45,7 +45,7 @@ bool operator==(const TTestMessage& lhs, const TTestMessage& rhs) { return true; } -Y_UNIT_TEST_SUITE(ProtoPackerTestSuite) { +Y_UNIT_TEST_SUITE(ProtoPackerTestSuite) { TProtoMessagePacker<TTestMessage> Packer; TString Buffer; @@ -61,20 +61,20 @@ Y_UNIT_TEST_SUITE(ProtoPackerTestSuite) { UNIT_ASSERT_EQUAL(msg, checkMsg); } - Y_UNIT_TEST(TestPackUnpackOnlyRequired) { + Y_UNIT_TEST(TestPackUnpackOnlyRequired) { TTestMessage msg; FillRequiredFields(msg); DoPackUnpackTest(msg); } - Y_UNIT_TEST(TestPackUnpackRequiredAndOptional) { + Y_UNIT_TEST(TestPackUnpackRequiredAndOptional) { TTestMessage msg; FillRequiredFields(msg); FillOptionalFields(msg); DoPackUnpackTest(msg); } - Y_UNIT_TEST(TestPackUnpackAll) { + Y_UNIT_TEST(TestPackUnpackAll) { TTestMessage msg; FillRequiredFields(msg); FillOptionalFields(msg); @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(ProtoPackerTestSuite) { DoPackUnpackTest(msg); } - Y_UNIT_TEST(TestSkipLeaf) { + Y_UNIT_TEST(TestSkipLeaf) { TTestMessage msgFirst; FillRequiredFields(msgFirst); TTestMessage msgSecond; diff --git a/library/cpp/packers/ut/region_packer_ut.cpp b/library/cpp/packers/ut/region_packer_ut.cpp index 1d71d40941..0cb08ccf65 100644 --- a/library/cpp/packers/ut/region_packer_ut.cpp +++ b/library/cpp/packers/ut/region_packer_ut.cpp @@ -9,7 +9,7 @@ void TestPacker() { TRegionPacker<TValue> p; using TValues = TArrayRef<TValue>; - TValues valueRegion = TValues(values, Y_ARRAY_SIZE(values)); + TValues valueRegion = TValues(values, Y_ARRAY_SIZE(values)); size_t sz = p.MeasureLeaf(valueRegion); UNIT_ASSERT_VALUES_EQUAL(sz, 1 + sizeof(values)); @@ -23,8 +23,8 @@ void TestPacker() { UNIT_ASSERT_EQUAL(0, memcmp(values, valueRegion.data(), sizeof(values))); } -Y_UNIT_TEST_SUITE(RegionPacker) { - Y_UNIT_TEST(Test0) { +Y_UNIT_TEST_SUITE(RegionPacker) { + Y_UNIT_TEST(Test0) { TestPacker<char>(); TestPacker<signed char>(); TestPacker<unsigned char>(); diff --git a/library/cpp/pop_count/popcount.h b/library/cpp/pop_count/popcount.h index e22b7c0ccf..3d67737ed2 100644 --- a/library/cpp/pop_count/popcount.h +++ b/library/cpp/pop_count/popcount.h @@ -99,7 +99,7 @@ static inline ui32 PopCountImpl(ui64 n) { template <class T> static inline ui32 PopCount(T n) { - using TCvt = TFixedWidthUnsignedInt<T>; + using TCvt = TFixedWidthUnsignedInt<T>; return PopCountImpl((TCvt)n); } diff --git a/library/cpp/pop_count/popcount_ut.cpp b/library/cpp/pop_count/popcount_ut.cpp index 0e0ad6dbcc..5cd6605411 100644 --- a/library/cpp/pop_count/popcount_ut.cpp +++ b/library/cpp/pop_count/popcount_ut.cpp @@ -4,7 +4,7 @@ #include <util/random/random.h> -Y_UNIT_TEST_SUITE(TestPopCount) { +Y_UNIT_TEST_SUITE(TestPopCount) { template <class T> static inline ui32 SlowPopCount(T t) { ui32 ret = 0; @@ -29,23 +29,23 @@ Y_UNIT_TEST_SUITE(TestPopCount) { } } - Y_UNIT_TEST(Test8) { + Y_UNIT_TEST(Test8) { Test<ui8>(); } - Y_UNIT_TEST(Test16) { + Y_UNIT_TEST(Test16) { Test<ui16>(); } - Y_UNIT_TEST(Test32) { + Y_UNIT_TEST(Test32) { Test<ui32>(); } - Y_UNIT_TEST(Test64) { + Y_UNIT_TEST(Test64) { Test<ui64>(); } - Y_UNIT_TEST(TestPopCount) { + Y_UNIT_TEST(TestPopCount) { UNIT_ASSERT_VALUES_EQUAL(PopCount(0), 0); UNIT_ASSERT_VALUES_EQUAL(PopCount(1), 1); UNIT_ASSERT_VALUES_EQUAL(PopCount(1 << 10), 1); diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp index b70c39d3b5..640c10f5a5 100644 --- a/library/cpp/protobuf/json/json2proto.cpp +++ b/library/cpp/protobuf/json/json2proto.cpp @@ -72,7 +72,7 @@ static TString GetFieldName(const google::protobuf::FieldDescriptor& field, NProtobufJson::ToSnakeCaseDense(&name); break; default: - Y_VERIFY_DEBUG(false, "Unknown FieldNameMode."); + Y_VERIFY_DEBUG(false, "Unknown FieldNameMode."); } return name; } @@ -85,7 +85,7 @@ JsonString2Field(const NJson::TJsonValue& json, using namespace google::protobuf; const Reflection* reflection = proto.GetReflection(); - Y_ASSERT(!!reflection); + Y_ASSERT(!!reflection); if (!json.IsString() && !config.CastRobust) { ythrow yexception() << "Invalid type of JSON field '" << field.name() << "': " @@ -94,7 +94,7 @@ JsonString2Field(const NJson::TJsonValue& json, } TString value = json.GetStringRobust(); for (size_t i = 0, endI = config.StringTransforms.size(); i < endI; ++i) { - Y_ASSERT(!!config.StringTransforms[i]); + Y_ASSERT(!!config.StringTransforms[i]); if (!!config.StringTransforms[i]) { if (field.type() == google::protobuf::FieldDescriptor::TYPE_BYTES) { config.StringTransforms[i]->TransformBytes(value); @@ -130,10 +130,10 @@ JsonEnum2Field(const NJson::TJsonValue& json, using namespace google::protobuf; const Reflection* reflection = proto.GetReflection(); - Y_ASSERT(!!reflection); + Y_ASSERT(!!reflection); const EnumDescriptor* enumField = field.enum_type(); - Y_ASSERT(!!enumField); + Y_ASSERT(!!enumField); /// @todo configure name/numerical value const EnumValueDescriptor* enumFieldValue = nullptr; @@ -343,7 +343,7 @@ Json2RepeatedField(const NJson::TJsonValue& json, } const Reflection* reflection = proto.GetReflection(); - Y_ASSERT(!!reflection); + Y_ASSERT(!!reflection); if (isMap) { const THashMap<TString, NJson::TJsonValue> jsonMap = fieldJson.GetMap(); diff --git a/library/cpp/protobuf/json/json_output_create.h b/library/cpp/protobuf/json/json_output_create.h index 42005bad28..ad3889f5e9 100644 --- a/library/cpp/protobuf/json/json_output_create.h +++ b/library/cpp/protobuf/json/json_output_create.h @@ -9,7 +9,7 @@ namespace NJson { struct TJsonWriterConfig; } -class IOutputStream; +class IOutputStream; class TStringStream; namespace NProtobufJson { diff --git a/library/cpp/protobuf/json/proto2json.h b/library/cpp/protobuf/json/proto2json.h index 2f7277be08..89a1781a40 100644 --- a/library/cpp/protobuf/json/proto2json.h +++ b/library/cpp/protobuf/json/proto2json.h @@ -19,7 +19,7 @@ namespace NJson { class TJsonWriter; } -class IOutputStream; +class IOutputStream; class TStringStream; namespace NProtobufJson { diff --git a/library/cpp/protobuf/json/ut/filter_ut.cpp b/library/cpp/protobuf/json/ut/filter_ut.cpp index daa2d98af4..95c227666f 100644 --- a/library/cpp/protobuf/json/ut/filter_ut.cpp +++ b/library/cpp/protobuf/json/ut/filter_ut.cpp @@ -19,8 +19,8 @@ static NProtobufJsonUt::TFilterTest GetTestMsg() { return msg; } -Y_UNIT_TEST_SUITE(TProto2JsonFilterTest){ - Y_UNIT_TEST(TestFilterPrinter){ +Y_UNIT_TEST_SUITE(TProto2JsonFilterTest){ + Y_UNIT_TEST(TestFilterPrinter){ NProtobufJsonUt::TFilterTest msg = GetTestMsg(); { TString expected = R"({"OptFiltered":"1","NotFiltered":"23","RepFiltered":[45,67],)" @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TProto2JsonFilterTest){ } } -Y_UNIT_TEST(NoUnnecessaryCopyFunctor) { +Y_UNIT_TEST(NoUnnecessaryCopyFunctor) { size_t CopyCount = 0; struct TFunctorMock { TFunctorMock(size_t* copyCount) diff --git a/library/cpp/protobuf/json/ut/inline_ut.cpp b/library/cpp/protobuf/json/ut/inline_ut.cpp index 548b6c2960..c29ad32e7d 100644 --- a/library/cpp/protobuf/json/ut/inline_ut.cpp +++ b/library/cpp/protobuf/json/ut/inline_ut.cpp @@ -21,8 +21,8 @@ static NProtobufJsonUt::TInlineTest GetTestMsg() { return msg; } -Y_UNIT_TEST_SUITE(TProto2JsonInlineTest){ - Y_UNIT_TEST(TestNormalPrint){ +Y_UNIT_TEST_SUITE(TProto2JsonInlineTest){ + Y_UNIT_TEST(TestNormalPrint){ NProtobufJsonUt::TInlineTest msg = GetTestMsg(); // normal print should output these fields as just string values TString expRaw = R"({"OptJson":"{\"a\":1,\"b\":\"000\"}","NotJson":"12{}34","RepJson":["{}","[1,2]"],)" @@ -35,7 +35,7 @@ myRaw = PrintInlined(msg, [](const NProtoBuf::Message&, const NProtoBuf::FieldDe UNIT_ASSERT_STRINGS_EQUAL(myRaw, expRaw); // result is the same } -Y_UNIT_TEST(TestInliningPrinter) { +Y_UNIT_TEST(TestInliningPrinter) { NProtobufJsonUt::TInlineTest msg = GetTestMsg(); // inlined print should output these fields as inlined json sub-objects TString expInlined = R"({"OptJson":{"a":1,"b":"000"},"NotJson":"12{}34","RepJson":[{},[1,2]],)" @@ -54,7 +54,7 @@ Y_UNIT_TEST(TestInliningPrinter) { } } -Y_UNIT_TEST(TestNoValues) { +Y_UNIT_TEST(TestNoValues) { // no values - no printing NProtobufJsonUt::TInlineTest msg; msg.MutableInner()->AddNumber(100); @@ -66,7 +66,7 @@ Y_UNIT_TEST(TestNoValues) { UNIT_ASSERT_STRINGS_EQUAL(myInlined, expInlined); } -Y_UNIT_TEST(TestMissingKeyModeNull) { +Y_UNIT_TEST(TestMissingKeyModeNull) { NProtobufJsonUt::TInlineTest msg; msg.MutableInner()->AddNumber(100); msg.MutableInner()->AddNumber(200); @@ -79,7 +79,7 @@ Y_UNIT_TEST(TestMissingKeyModeNull) { UNIT_ASSERT_STRINGS_EQUAL(myInlined, expInlined); } -Y_UNIT_TEST(TestMissingKeyModeDefault) { +Y_UNIT_TEST(TestMissingKeyModeDefault) { NProtobufJsonUt::TInlineTestDefaultValues msg; TString expInlined = R"({"OptJson":{"default":1},"Number":0,"RepJson":[],"Inner":{"OptJson":{"default":2}}})"; @@ -90,7 +90,7 @@ Y_UNIT_TEST(TestMissingKeyModeDefault) { UNIT_ASSERT_STRINGS_EQUAL(myInlined, expInlined); } -Y_UNIT_TEST(NoUnnecessaryCopyFunctor) { +Y_UNIT_TEST(NoUnnecessaryCopyFunctor) { size_t CopyCount = 0; struct TFunctorMock { TFunctorMock(size_t* copyCount) diff --git a/library/cpp/protobuf/json/ut/json2proto_ut.cpp b/library/cpp/protobuf/json/ut/json2proto_ut.cpp index 271db47dc4..0dfe57bc7a 100644 --- a/library/cpp/protobuf/json/ut/json2proto_ut.cpp +++ b/library/cpp/protobuf/json/ut/json2proto_ut.cpp @@ -70,8 +70,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TJson2ProtoTest) { - Y_UNIT_TEST(TestFlatOptional){ +Y_UNIT_TEST_SUITE(TJson2ProtoTest) { + Y_UNIT_TEST(TestFlatOptional){ {const NJson::TJsonValue& json = CreateFlatJson(); TFlatOptional proto; Json2Proto(json, proto); @@ -96,7 +96,7 @@ Y_UNIT_TEST_SUITE(TJson2ProtoTest) { #undef DEFINE_FIELD } // TestFlatOptional -Y_UNIT_TEST(TestFlatRequired){ +Y_UNIT_TEST(TestFlatRequired){ {const NJson::TJsonValue& json = CreateFlatJson(); TFlatRequired proto; Json2Proto(json, proto); @@ -118,7 +118,7 @@ UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); #undef DEFINE_FIELD } // TestFlatRequired -Y_UNIT_TEST(TestNameGenerator) { +Y_UNIT_TEST(TestNameGenerator) { TJson2ProtoConfig cfg; cfg.SetNameGenerator([](const NProtoBuf::FieldDescriptor&) { return "42"; }); @@ -131,7 +131,7 @@ Y_UNIT_TEST(TestNameGenerator) { UNIT_ASSERT_PROTOS_EQUAL(expected, proto); } -Y_UNIT_TEST(TestFlatNoCheckRequired) { +Y_UNIT_TEST(TestFlatNoCheckRequired) { { const NJson::TJsonValue& json = CreateFlatJson(); TFlatRequired proto; @@ -157,7 +157,7 @@ Y_UNIT_TEST(TestFlatNoCheckRequired) { #undef DEFINE_FIELD } // TestFlatNoCheckRequired -Y_UNIT_TEST(TestFlatRepeated){ +Y_UNIT_TEST(TestFlatRepeated){ {const NJson::TJsonValue& json = CreateRepeatedFlatJson(); TFlatRepeated proto; Json2Proto(json, proto); @@ -182,7 +182,7 @@ UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); #undef DEFINE_REPEATED_FIELD } // TestFlatRepeated -Y_UNIT_TEST(TestCompositeOptional){ +Y_UNIT_TEST(TestCompositeOptional){ {const NJson::TJsonValue& json = CreateCompositeJson(); TCompositeOptional proto; Json2Proto(json, proto); @@ -207,7 +207,7 @@ UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); #undef DEFINE_FIELD } // TestCompositeOptional -Y_UNIT_TEST(TestCompositeOptionalStringBuf){ +Y_UNIT_TEST(TestCompositeOptionalStringBuf){ {NJson::TJsonValue json = CreateCompositeJson(); json["Part"]["Double"] = 42.5; TCompositeOptional proto; @@ -240,7 +240,7 @@ UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); #undef DEFINE_FIELD } // TestCompositeOptionalStringBuf -Y_UNIT_TEST(TestCompositeRequired) { +Y_UNIT_TEST(TestCompositeRequired) { { const NJson::TJsonValue& json = CreateCompositeJson(); TCompositeRequired proto; @@ -257,7 +257,7 @@ Y_UNIT_TEST(TestCompositeRequired) { } } // TestCompositeRequired -Y_UNIT_TEST(TestCompositeRepeated) { +Y_UNIT_TEST(TestCompositeRepeated) { { NJson::TJsonValue json; NJson::TJsonValue array; @@ -302,7 +302,7 @@ Y_UNIT_TEST(TestCompositeRepeated) { } } // TestCompositeRepeated -Y_UNIT_TEST(TestInvalidEnum) { +Y_UNIT_TEST(TestInvalidEnum) { { NJson::TJsonValue json; json.InsertValue("Enum", "E_100"); @@ -318,7 +318,7 @@ Y_UNIT_TEST(TestInvalidEnum) { } } -Y_UNIT_TEST(TestFieldNameMode) { +Y_UNIT_TEST(TestFieldNameMode) { // Original case 1 { TString modelStr(R"_({"String":"value"})_"); @@ -514,7 +514,7 @@ public: } }; -Y_UNIT_TEST(TestInvalidJson) { +Y_UNIT_TEST(TestInvalidJson) { NJson::TJsonValue val{"bad value"}; TFlatOptional proto; UNIT_ASSERT_EXCEPTION(Json2Proto(val, proto), yexception); @@ -527,7 +527,7 @@ Y_UNIT_TEST(TestInvalidRepeatedFieldWithMapAsObject) { UNIT_ASSERT_EXCEPTION(Json2Proto(TStringBuf(R"({"Part":{"Boo":{}}})"), proto, config), yexception); } -Y_UNIT_TEST(TestStringTransforms) { +Y_UNIT_TEST(TestStringTransforms) { // Check that strings and bytes are transformed { TString modelStr(R"_({"String":"value_str", "Bytes": "value_bytes"})_"); @@ -585,7 +585,7 @@ Y_UNIT_TEST(TestStringTransforms) { } } // TestStringTransforms -Y_UNIT_TEST(TestCastFromString) { +Y_UNIT_TEST(TestCastFromString) { // single fields { NJson::TJsonValue json; @@ -634,7 +634,7 @@ Y_UNIT_TEST(TestCastFromString) { } } // TestCastFromString -Y_UNIT_TEST(TestMap) { +Y_UNIT_TEST(TestMap) { TMapType modelProto; auto& items = *modelProto.MutableItems(); @@ -651,7 +651,7 @@ Y_UNIT_TEST(TestMap) { UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); } // TestMap -Y_UNIT_TEST(TestCastRobust) { +Y_UNIT_TEST(TestCastRobust) { NJson::TJsonValue json; json["I32"] = "5"; json["Bool"] = 1; @@ -741,7 +741,7 @@ Y_UNIT_TEST(TestValueVectorizer) { } } -Y_UNIT_TEST(TestMapAsObject) { +Y_UNIT_TEST(TestMapAsObject) { TMapType modelProto; auto& items = *modelProto.MutableItems(); @@ -759,7 +759,7 @@ Y_UNIT_TEST(TestMapAsObject) { UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); } // TestMapAsObject -Y_UNIT_TEST(TestComplexMapAsObject_I32) { +Y_UNIT_TEST(TestComplexMapAsObject_I32) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableI32(); @@ -770,7 +770,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_I32) { R"_({"I32":{"1":1,"-2":-2,"3":3}})_"); } // TestComplexMapAsObject_I32 -Y_UNIT_TEST(TestComplexMapAsObject_I64) { +Y_UNIT_TEST(TestComplexMapAsObject_I64) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableI64(); @@ -781,7 +781,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_I64) { R"_({"I64":{"2147483649":2147483649,"-2147483650":-2147483650,"2147483651":2147483651}})_"); } // TestComplexMapAsObject_I64 -Y_UNIT_TEST(TestComplexMapAsObject_UI32) { +Y_UNIT_TEST(TestComplexMapAsObject_UI32) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableUI32(); @@ -792,7 +792,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_UI32) { R"_({"UI32":{"1073741825":1073741825,"1073741826":1073741826,"1073741827":1073741827}})_"); } // TestComplexMapAsObject_UI32 -Y_UNIT_TEST(TestComplexMapAsObject_UI64) { +Y_UNIT_TEST(TestComplexMapAsObject_UI64) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableUI64(); @@ -803,7 +803,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_UI64) { R"_({"UI64":{"9223372036854775809":9223372036854775809,"9223372036854775810":9223372036854775810,"9223372036854775811":9223372036854775811}})_"); } // TestComplexMapAsObject_UI64 -Y_UNIT_TEST(TestComplexMapAsObject_SI32) { +Y_UNIT_TEST(TestComplexMapAsObject_SI32) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableSI32(); @@ -814,7 +814,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_SI32) { R"_({"SI32":{"1":1,"-2":-2,"3":3}})_"); } // TestComplexMapAsObject_SI32 -Y_UNIT_TEST(TestComplexMapAsObject_SI64) { +Y_UNIT_TEST(TestComplexMapAsObject_SI64) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableSI64(); @@ -825,7 +825,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_SI64) { R"_({"SI64":{"2147483649":2147483649,"-2147483650":-2147483650,"2147483651":2147483651}})_"); } // TestComplexMapAsObject_SI64 -Y_UNIT_TEST(TestComplexMapAsObject_FI32) { +Y_UNIT_TEST(TestComplexMapAsObject_FI32) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableFI32(); @@ -836,7 +836,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_FI32) { R"_({"FI32":{"1073741825":1073741825,"1073741826":1073741826,"1073741827":1073741827}})_"); } // TestComplexMapAsObject_FI32 -Y_UNIT_TEST(TestComplexMapAsObject_FI64) { +Y_UNIT_TEST(TestComplexMapAsObject_FI64) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableFI64(); @@ -847,7 +847,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_FI64) { R"_({"FI64":{"9223372036854775809":9223372036854775809,"9223372036854775810":9223372036854775810,"9223372036854775811":9223372036854775811}})_"); } // TestComplexMapAsObject_FI64 -Y_UNIT_TEST(TestComplexMapAsObject_SFI32) { +Y_UNIT_TEST(TestComplexMapAsObject_SFI32) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableSFI32(); @@ -858,7 +858,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_SFI32) { R"_({"SFI32":{"1":1,"-2":-2,"3":3}})_"); } // TestComplexMapAsObject_SFI32 -Y_UNIT_TEST(TestComplexMapAsObject_SFI64) { +Y_UNIT_TEST(TestComplexMapAsObject_SFI64) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableSFI64(); @@ -869,7 +869,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_SFI64) { R"_({"SFI64":{"2147483649":2147483649,"-2147483650":-2147483650,"2147483651":2147483651}})_"); } // TestComplexMapAsObject_SFI64 -Y_UNIT_TEST(TestComplexMapAsObject_Bool) { +Y_UNIT_TEST(TestComplexMapAsObject_Bool) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableBool(); @@ -879,7 +879,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_Bool) { R"_({"Bool":{"true":true,"false":false}})_"); } // TestComplexMapAsObject_Bool -Y_UNIT_TEST(TestComplexMapAsObject_String) { +Y_UNIT_TEST(TestComplexMapAsObject_String) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableString(); @@ -891,7 +891,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_String) { R"_({"String":{"key1":"value1","key2":"value2","key3":"value3","":"value4"}})_"); } // TestComplexMapAsObject_String -Y_UNIT_TEST(TestComplexMapAsObject_Enum) { +Y_UNIT_TEST(TestComplexMapAsObject_Enum) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableEnum(); @@ -943,7 +943,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_EnumStringSnakeCaseInsensitive) { ); } // TestComplexMapAsObject_EnumStringCaseInsensetive -Y_UNIT_TEST(TestComplexMapAsObject_Float) { +Y_UNIT_TEST(TestComplexMapAsObject_Float) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableFloat(); @@ -954,7 +954,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_Float) { R"_({"Float":{"key1":0.1,"key2":0.2,"key3":0.3}})_"); } // TestComplexMapAsObject_Float -Y_UNIT_TEST(TestComplexMapAsObject_Double) { +Y_UNIT_TEST(TestComplexMapAsObject_Double) { TestComplexMapAsObject( [](TComplexMapType& proto) { auto& items = *proto.MutableDouble(); @@ -965,7 +965,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_Double) { R"_({"Double":{"key1":0.1,"key2":0.2,"key3":0.3}})_"); } // TestComplexMapAsObject_Double -Y_UNIT_TEST(TestComplexMapAsObject_Nested) { +Y_UNIT_TEST(TestComplexMapAsObject_Nested) { TestComplexMapAsObject( [](TComplexMapType& proto) { TComplexMapType inner; @@ -979,7 +979,7 @@ Y_UNIT_TEST(TestComplexMapAsObject_Nested) { R"_({"Nested":{"key1":{"String":{"key":"value"}},"key2":{"String":{"key":"value"}},"key3":{"String":{"key":"value"}}}})_"); } // TestComplexMapAsObject_Nested -Y_UNIT_TEST(TestMapAsObjectConfigNotSet) { +Y_UNIT_TEST(TestMapAsObjectConfigNotSet) { TString modelStr(R"_({"Items":{"key":"value"}})_"); TJson2ProtoConfig config; diff --git a/library/cpp/protobuf/json/ut/proto2json_ut.cpp b/library/cpp/protobuf/json/ut/proto2json_ut.cpp index 0a56cc2a8c..07e52d7f2f 100644 --- a/library/cpp/protobuf/json/ut/proto2json_ut.cpp +++ b/library/cpp/protobuf/json/ut/proto2json_ut.cpp @@ -25,8 +25,8 @@ using namespace NProtobufJson; using namespace NProtobufJsonTest; -Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { - Y_UNIT_TEST(TestFlatDefault) { +Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { + Y_UNIT_TEST(TestFlatDefault) { using namespace ::google::protobuf; TFlatDefault proto; NJson::TJsonValue json; @@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { #undef DEFINE_FIELD } - Y_UNIT_TEST(TestNameGenerator) { + Y_UNIT_TEST(TestNameGenerator) { TNameGeneratorType proto; proto.SetField(42); @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { UNIT_ASSERT_STRINGS_EQUAL(R"({"42":42})", str.Str()); } - Y_UNIT_TEST(TestEnumValueGenerator) { + Y_UNIT_TEST(TestEnumValueGenerator) { TEnumValueGeneratorType proto; proto.SetEnum(TEnumValueGeneratorType::ENUM_42); @@ -100,7 +100,7 @@ Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { UNIT_ASSERT_STRINGS_EQUAL(R"({"Enum":"42"})", str.Str()); } - Y_UNIT_TEST(TestFlatOptional){ + Y_UNIT_TEST(TestFlatOptional){ {TFlatOptional proto; FillFlatProto(&proto); const NJson::TJsonValue& modelJson = CreateFlatJson(); @@ -141,7 +141,7 @@ Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) { #undef DEFINE_FIELD } // TestFlatOptional -Y_UNIT_TEST(TestFlatRequired){ +Y_UNIT_TEST(TestFlatRequired){ {TFlatRequired proto; FillFlatProto(&proto); const NJson::TJsonValue& modelJson = CreateFlatJson(); @@ -182,7 +182,7 @@ const NJson::TJsonValue& modelJson = CreateFlatJson(); #undef DEFINE_FIELD } // TestFlatRequired -Y_UNIT_TEST(TestFlatRepeated) { +Y_UNIT_TEST(TestFlatRepeated) { { TFlatRepeated proto; FillRepeatedProto(&proto); @@ -227,7 +227,7 @@ Y_UNIT_TEST(TestFlatRepeated) { #undef DEFINE_REPEATED_FIELD } // TestFlatRepeated -Y_UNIT_TEST(TestCompositeOptional){ +Y_UNIT_TEST(TestCompositeOptional){ {TCompositeOptional proto; FillCompositeProto(&proto); const NJson::TJsonValue& modelJson = CreateCompositeJson(); @@ -268,7 +268,7 @@ const NJson::TJsonValue& modelJson = CreateCompositeJson(); #undef DEFINE_FIELD } // TestCompositeOptional -Y_UNIT_TEST(TestCompositeRequired){ +Y_UNIT_TEST(TestCompositeRequired){ {TCompositeRequired proto; FillCompositeProto(&proto); const NJson::TJsonValue& modelJson = CreateCompositeJson(); @@ -309,7 +309,7 @@ const NJson::TJsonValue& modelJson = CreateCompositeJson(); #undef DEFINE_FIELD } // TestCompositeRequired -Y_UNIT_TEST(TestCompositeRepeated) { +Y_UNIT_TEST(TestCompositeRepeated) { { TFlatOptional partProto; FillFlatProto(&partProto); @@ -371,7 +371,7 @@ Y_UNIT_TEST(TestCompositeRepeated) { } } // TestCompositeRepeated -Y_UNIT_TEST(TestEnumConfig) { +Y_UNIT_TEST(TestEnumConfig) { { TFlatOptional proto; proto.SetEnum(E_1); @@ -438,7 +438,7 @@ Y_UNIT_TEST(TestEnumConfig) { } } // TestEnumConfig -Y_UNIT_TEST(TestMissingSingleKeyConfig) { +Y_UNIT_TEST(TestMissingSingleKeyConfig) { { TFlatOptional proto; NJson::TJsonValue modelJson(NJson::JSON_MAP); @@ -513,7 +513,7 @@ Y_UNIT_TEST(TestMissingSingleKeyConfig) { } } // TestMissingSingleKeyConfig -Y_UNIT_TEST(TestMissingRepeatedKeyNoConfig) { +Y_UNIT_TEST(TestMissingRepeatedKeyNoConfig) { { TFlatRepeated proto; NJson::TJsonValue modelJson(NJson::JSON_MAP); @@ -524,7 +524,7 @@ Y_UNIT_TEST(TestMissingRepeatedKeyNoConfig) { } } // TestMissingRepeatedKeyNoConfig -Y_UNIT_TEST(TestMissingRepeatedKeyConfig) { +Y_UNIT_TEST(TestMissingRepeatedKeyConfig) { { TFlatRepeated proto; NJson::TJsonValue modelJson(NJson::JSON_MAP); @@ -564,7 +564,7 @@ Y_UNIT_TEST(TestMissingRepeatedKeyConfig) { } } // TestMissingRepeatedKeyConfig -Y_UNIT_TEST(TestEscaping) { +Y_UNIT_TEST(TestEscaping) { // No escape { TString modelStr(R"_({"String":"value\""})_"); @@ -632,7 +632,7 @@ public: } }; -Y_UNIT_TEST(TestBytesTransform) { +Y_UNIT_TEST(TestBytesTransform) { // Test that string field is not changed { TString modelStr(R"_({"String":"value"})_"); @@ -662,7 +662,7 @@ Y_UNIT_TEST(TestBytesTransform) { } } -Y_UNIT_TEST(TestFieldNameMode) { +Y_UNIT_TEST(TestFieldNameMode) { // Original case 1 { TString modelStr(R"_({"String":"value"})_"); @@ -888,21 +888,21 @@ Y_UNIT_TEST(TestFieldNameMode) { /// TODO: test missing keys } // TestFieldNameMode -Y_UNIT_TEST(TestNan) { +Y_UNIT_TEST(TestNan) { TFlatOptional proto; proto.SetDouble(std::numeric_limits<double>::quiet_NaN()); UNIT_ASSERT_EXCEPTION(Proto2Json(proto, TProto2JsonConfig()), yexception); } // TestNan -Y_UNIT_TEST(TestInf) { +Y_UNIT_TEST(TestInf) { TFlatOptional proto; proto.SetFloat(std::numeric_limits<float>::infinity()); UNIT_ASSERT_EXCEPTION(Proto2Json(proto, TProto2JsonConfig()), yexception); } // TestInf -Y_UNIT_TEST(TestMap) { +Y_UNIT_TEST(TestMap) { TMapType proto; auto& items = *proto.MutableItems(); @@ -931,7 +931,7 @@ Y_UNIT_TEST(TestMap) { UNIT_ASSERT_EQUAL(jsonItems, modelItems); } // TestMap -Y_UNIT_TEST(TestMapAsObject) { +Y_UNIT_TEST(TestMapAsObject) { TMapType proto; auto& items = *proto.MutableItems(); @@ -949,7 +949,7 @@ Y_UNIT_TEST(TestMapAsObject) { UNIT_ASSERT_JSON_STRINGS_EQUAL(jsonStr.Str(), modelStr); } // TestMapAsObject -Y_UNIT_TEST(TestMapWTF) { +Y_UNIT_TEST(TestMapWTF) { TMapType proto; auto& items = *proto.MutableItems(); @@ -965,7 +965,7 @@ Y_UNIT_TEST(TestMapWTF) { UNIT_ASSERT_JSON_STRINGS_EQUAL(jsonStr.Str(), modelStr); } // TestMapWTF -Y_UNIT_TEST(TestStringifyLongNumbers) { +Y_UNIT_TEST(TestStringifyLongNumbers) { #define TEST_SINGLE(flag, value, expectString) \ do { \ TFlatOptional proto; \ diff --git a/library/cpp/protobuf/json/ut/string_transform_ut.cpp b/library/cpp/protobuf/json/ut/string_transform_ut.cpp index 7b0595e6cb..a31dabcb0f 100644 --- a/library/cpp/protobuf/json/ut/string_transform_ut.cpp +++ b/library/cpp/protobuf/json/ut/string_transform_ut.cpp @@ -3,8 +3,8 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/protobuf/json/proto2json.h> -Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { - Y_UNIT_TEST(TestEmptyString) { +Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { + Y_UNIT_TEST(TestEmptyString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; s = ""; @@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { UNIT_ASSERT_EQUAL(s, ""); } - Y_UNIT_TEST(TestAlphabeticString) { + Y_UNIT_TEST(TestAlphabeticString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; s = "abacaba"; @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { UNIT_ASSERT_EQUAL(s, "abacaba"); } - Y_UNIT_TEST(TestRussianSymbols) { + Y_UNIT_TEST(TestRussianSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; s = "тест"; @@ -28,7 +28,7 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { UNIT_ASSERT_EQUAL(s, "\\\\321\\\\202\\\\320\\\\265\\\\321\\\\201\\\\321\\\\202"); } - Y_UNIT_TEST(TestEscapeSpecialSymbols) { + Y_UNIT_TEST(TestEscapeSpecialSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; s = "aba\\ca\"ba"; @@ -38,8 +38,8 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { } } -Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { - Y_UNIT_TEST(TestEmptyString) { +Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { + Y_UNIT_TEST(TestEmptyString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; s = ""; @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { UNIT_ASSERT_EQUAL("", s); } - Y_UNIT_TEST(TestAlphabeticString) { + Y_UNIT_TEST(TestAlphabeticString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; s = "abacaba"; @@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { UNIT_ASSERT_EQUAL("abacaba", s); } - Y_UNIT_TEST(TestRussianSymbols) { + Y_UNIT_TEST(TestRussianSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; s = "\\\\321\\\\202\\\\320\\\\265\\\\321\\\\201\\\\321\\\\202"; @@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { UNIT_ASSERT_EQUAL("тест", s); } - Y_UNIT_TEST(TestEscapeSpecialSymbols) { + Y_UNIT_TEST(TestEscapeSpecialSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; s = "aba\\\\\\\\ca\\\\\\\"ba"; @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { UNIT_ASSERT_EQUAL("aba\\ca\"ba", s); } - Y_UNIT_TEST(TestEscapeSpecialSymbolsDifficultCases) { + Y_UNIT_TEST(TestEscapeSpecialSymbolsDifficultCases) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; s = "\\\\\\\\\\\\\\\\"; diff --git a/library/cpp/protobuf/util/is_equal.h b/library/cpp/protobuf/util/is_equal.h index d47cb37cb7..13c0aae63d 100644 --- a/library/cpp/protobuf/util/is_equal.h +++ b/library/cpp/protobuf/util/is_equal.h @@ -1,22 +1,22 @@ #pragma once -#include <util/generic/fwd.h> +#include <util/generic/fwd.h> -namespace google { - namespace protobuf { - class Message; +namespace google { + namespace protobuf { + class Message; class FieldDescriptor; - } -} + } +} namespace NProtoBuf { using ::google::protobuf::FieldDescriptor; using ::google::protobuf::Message; -} +} -namespace NProtoBuf { +namespace NProtoBuf { // Reflection-based equality check for arbitrary protobuf messages - + // Strict comparison: optional field without value is NOT equal to // a field with explicitly set default value. bool IsEqual(const Message& m1, const Message& m2); diff --git a/library/cpp/protobuf/util/is_equal_ut.cpp b/library/cpp/protobuf/util/is_equal_ut.cpp index 96e77c95c6..3ca4c90dd5 100644 --- a/library/cpp/protobuf/util/is_equal_ut.cpp +++ b/library/cpp/protobuf/util/is_equal_ut.cpp @@ -5,19 +5,19 @@ #include <google/protobuf/descriptor.h> -Y_UNIT_TEST_SUITE(ProtobufIsEqual) { +Y_UNIT_TEST_SUITE(ProtobufIsEqual) { const ::google::protobuf::Descriptor* Descr = TSampleForIsEqual::descriptor(); const ::google::protobuf::FieldDescriptor* NameDescr = Descr->field(0); const ::google::protobuf::FieldDescriptor* InnerDescr = Descr->field(1); - Y_UNIT_TEST(CheckDescriptors) { + Y_UNIT_TEST(CheckDescriptors) { UNIT_ASSERT(Descr); UNIT_ASSERT(NameDescr); UNIT_ASSERT_VALUES_EQUAL(NameDescr->name(), "Name"); UNIT_ASSERT_VALUES_EQUAL(InnerDescr->name(), "Inner"); } - Y_UNIT_TEST(IsEqual1) { + Y_UNIT_TEST(IsEqual1) { TSampleForIsEqual a; TSampleForIsEqual b; @@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); } - Y_UNIT_TEST(IsEqual2) { + Y_UNIT_TEST(IsEqual2) { TSampleForIsEqual a; TSampleForIsEqual b; @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { UNIT_ASSERT(!equalField); } - Y_UNIT_TEST(IsEqual3) { + Y_UNIT_TEST(IsEqual3) { TSampleForIsEqual a; TSampleForIsEqual b; @@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); } - Y_UNIT_TEST(IsEqualDefault) { + Y_UNIT_TEST(IsEqualDefault) { TSampleForIsEqual a; TSampleForIsEqual b; diff --git a/library/cpp/protobuf/util/iterators_ut.cpp b/library/cpp/protobuf/util/iterators_ut.cpp index 7a255f0188..9ebcff2963 100644 --- a/library/cpp/protobuf/util/iterators_ut.cpp +++ b/library/cpp/protobuf/util/iterators_ut.cpp @@ -9,8 +9,8 @@ using NProtoBuf::TFieldsIterator; using NProtoBuf::TConstField; -Y_UNIT_TEST_SUITE(Iterators) { - Y_UNIT_TEST(Count) { +Y_UNIT_TEST_SUITE(Iterators) { + Y_UNIT_TEST(Count) { const NProtobufUtilUt::TWalkTest proto; const NProtoBuf::Descriptor* d = proto.GetDescriptor(); TFieldsIterator dbegin(d), dend(d, d->field_count()); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(Iterators) { UNIT_ASSERT_VALUES_EQUAL(values, 1); } - Y_UNIT_TEST(AnyOf) { + Y_UNIT_TEST(AnyOf) { NProtobufUtilUt::TWalkTest proto; const NProtoBuf::Descriptor* d = proto.GetDescriptor(); TFieldsIterator begin(d), end(d, d->field_count()); diff --git a/library/cpp/protobuf/util/merge.cpp b/library/cpp/protobuf/util/merge.cpp index 19e1e6bafc..dc2b9cc806 100644 --- a/library/cpp/protobuf/util/merge.cpp +++ b/library/cpp/protobuf/util/merge.cpp @@ -1,8 +1,8 @@ #include "merge.h" -#include "simple_reflection.h" - +#include "simple_reflection.h" + #include <google/protobuf/message.h> - + #include <library/cpp/protobuf/util/proto/merge.pb.h> namespace NProtoBuf { diff --git a/library/cpp/protobuf/util/merge.h b/library/cpp/protobuf/util/merge.h index 4acea08697..924975f141 100644 --- a/library/cpp/protobuf/util/merge.h +++ b/library/cpp/protobuf/util/merge.h @@ -1,14 +1,14 @@ #pragma once -namespace google { - namespace protobuf { - class Message; - } -} +namespace google { + namespace protobuf { + class Message; + } +} -namespace NProtoBuf { - using Message = ::google::protobuf::Message; -} +namespace NProtoBuf { + using Message = ::google::protobuf::Message; +} namespace NProtoBuf { // Similiar to Message::MergeFrom, overwrites existing repeated fields diff --git a/library/cpp/protobuf/util/merge_ut.cpp b/library/cpp/protobuf/util/merge_ut.cpp index 01bf3d1a48..22217db183 100644 --- a/library/cpp/protobuf/util/merge_ut.cpp +++ b/library/cpp/protobuf/util/merge_ut.cpp @@ -5,7 +5,7 @@ using namespace NProtoBuf; -Y_UNIT_TEST_SUITE(ProtobufMerge) { +Y_UNIT_TEST_SUITE(ProtobufMerge) { static void InitProto(NProtobufUtilUt::TMergeTest & p, bool isSrc) { size_t start = isSrc ? 0 : 100; @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(ProtobufMerge) { mm3->AddB(start + 13); } - Y_UNIT_TEST(CustomMerge) { + Y_UNIT_TEST(CustomMerge) { NProtobufUtilUt::TMergeTest src, dst; InitProto(src, true); InitProto(dst, false); diff --git a/library/cpp/protobuf/util/pb_io.cpp b/library/cpp/protobuf/util/pb_io.cpp index ab808fd6f4..6270ee0624 100644 --- a/library/cpp/protobuf/util/pb_io.cpp +++ b/library/cpp/protobuf/util/pb_io.cpp @@ -8,11 +8,11 @@ #include <google/protobuf/text_format.h> #include <util/generic/string.h> -#include <util/stream/file.h> -#include <util/stream/str.h> +#include <util/stream/file.h> +#include <util/stream/str.h> #include <util/string/cast.h> -namespace NProtoBuf { +namespace NProtoBuf { class TEnumIdValuePrinter : public google::protobuf::TextFormat::FastFieldValuePrinter { public: @@ -34,7 +34,7 @@ namespace NProtoBuf { } catch (const std::exception&) { return false; } - } + } void SerializeToBase64String(const Message& m, TString& dataBase64) { TString rawData; @@ -58,8 +58,8 @@ namespace NProtoBuf { } catch (const std::exception&) { return false; } - } - + } + const TString ShortUtf8DebugString(const Message& message) { TextFormat::Printer printer; printer.SetSingleLineMode(true); @@ -93,21 +93,21 @@ int operator&(NProtoBuf::Message& m, IBinSaver& f) { return 0; } -void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out) { - NProtoBuf::io::TCopyingOutputStreamAdaptor adaptor(&out); +void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out) { + NProtoBuf::io::TCopyingOutputStreamAdaptor adaptor(&out); - if (!NProtoBuf::TextFormat::Print(m, &adaptor)) { + if (!NProtoBuf::TextFormat::Print(m, &adaptor)) { ythrow yexception() << "SerializeToTextFormat failed on Print"; - } + } } void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName) { /* TUnbufferedFileOutput is unbuffered, but TCopyingOutputStreamAdaptor adds - * a buffer on top of it. */ + * a buffer on top of it. */ TUnbufferedFileOutput stream(fileName); - SerializeToTextFormat(m, stream); -} - + SerializeToTextFormat(m, stream); +} + void SerializeToTextFormatWithEnumId(const NProtoBuf::Message& m, IOutputStream& out) { google::protobuf::TextFormat::Printer printer; printer.SetDefaultFieldValuePrinter(new NProtoBuf::TEnumIdValuePrinter()); @@ -130,20 +130,20 @@ void SerializeToTextFormatPretty(const NProtoBuf::Message& m, IOutputStream& out } } -static void ConfigureParser(const EParseFromTextFormatOptions options, - NProtoBuf::TextFormat::Parser& p) { - if (options & EParseFromTextFormatOption::AllowUnknownField) { - p.AllowUnknownField(true); - } -} - -void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - NProtoBuf::io::TCopyingInputStreamAdaptor adaptor(&in); - NProtoBuf::TextFormat::Parser p; - ConfigureParser(options, p); - - if (!p.Parse(&adaptor, &m)) { +static void ConfigureParser(const EParseFromTextFormatOptions options, + NProtoBuf::TextFormat::Parser& p) { + if (options & EParseFromTextFormatOption::AllowUnknownField) { + p.AllowUnknownField(true); + } +} + +void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { + NProtoBuf::io::TCopyingInputStreamAdaptor adaptor(&in); + NProtoBuf::TextFormat::Parser p; + ConfigureParser(options, p); + + if (!p.Parse(&adaptor, &m)) { // remove everything that may have been read m.Clear(); ythrow yexception() << "ParseFromTextFormat failed on Parse for " << m.GetTypeName(); @@ -151,71 +151,71 @@ void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, } void ParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { + const EParseFromTextFormatOptions options) { /* TUnbufferedFileInput is unbuffered, but TCopyingInputStreamAdaptor adds - * a buffer on top of it. */ + * a buffer on top of it. */ TUnbufferedFileInput stream(fileName); - ParseFromTextFormat(stream, m, options); -} - + ParseFromTextFormat(stream, m, options); +} + bool TryParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - try { - ParseFromTextFormat(fileName, m, options); - } catch (std::exception&) { - return false; - } - - return true; + const EParseFromTextFormatOptions options) { + try { + ParseFromTextFormat(fileName, m, options); + } catch (std::exception&) { + return false; + } + + return true; } -bool TryParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - try { - ParseFromTextFormat(in, m, options); - } catch (std::exception&) { - return false; - } - - return true; -} - -void MergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - NProtoBuf::io::TCopyingInputStreamAdaptor adaptor(&in); - NProtoBuf::TextFormat::Parser p; - ConfigureParser(options, p); - if (!p.Merge(&adaptor, &m)) { - ythrow yexception() << "MergeFromTextFormat failed on Merge for " << m.GetTypeName(); - } -} - -void MergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { +bool TryParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { + try { + ParseFromTextFormat(in, m, options); + } catch (std::exception&) { + return false; + } + + return true; +} + +void MergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { + NProtoBuf::io::TCopyingInputStreamAdaptor adaptor(&in); + NProtoBuf::TextFormat::Parser p; + ConfigureParser(options, p); + if (!p.Merge(&adaptor, &m)) { + ythrow yexception() << "MergeFromTextFormat failed on Merge for " << m.GetTypeName(); + } +} + +void MergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { /* TUnbufferedFileInput is unbuffered, but TCopyingInputStreamAdaptor adds - * a buffer on top of it. */ + * a buffer on top of it. */ TUnbufferedFileInput stream(fileName); - MergeFromTextFormat(stream, m, options); -} - -bool TryMergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - try { - MergeFromTextFormat(fileName, m, options); - } catch (std::exception&) { - return false; - } - - return true; -} - -bool TryMergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options) { - try { - MergeFromTextFormat(in, m, options); - } catch (std::exception&) { - return false; - } - - return true; -} + MergeFromTextFormat(stream, m, options); +} + +bool TryMergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { + try { + MergeFromTextFormat(fileName, m, options); + } catch (std::exception&) { + return false; + } + + return true; +} + +bool TryMergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options) { + try { + MergeFromTextFormat(in, m, options); + } catch (std::exception&) { + return false; + } + + return true; +} diff --git a/library/cpp/protobuf/util/pb_io.h b/library/cpp/protobuf/util/pb_io.h index a431b4200b..493c84cb5f 100644 --- a/library/cpp/protobuf/util/pb_io.h +++ b/library/cpp/protobuf/util/pb_io.h @@ -1,37 +1,37 @@ #pragma once -#include <util/generic/fwd.h> -#include <util/generic/flags.h> +#include <util/generic/fwd.h> +#include <util/generic/flags.h> -struct IBinSaver; +struct IBinSaver; -namespace google { - namespace protobuf { +namespace google { + namespace protobuf { class Message; - } -} - -namespace NProtoBuf { - using Message = ::google::protobuf::Message; -} - -class IInputStream; -class IOutputStream; - -namespace NProtoBuf { - /* Parse base64 URL encoded serialized message from string. - */ + } +} + +namespace NProtoBuf { + using Message = ::google::protobuf::Message; +} + +class IInputStream; +class IOutputStream; + +namespace NProtoBuf { + /* Parse base64 URL encoded serialized message from string. + */ void ParseFromBase64String(const TStringBuf dataBase64, Message& m, bool allowUneven = false); bool TryParseFromBase64String(const TStringBuf dataBase64, Message& m, bool allowUneven = false); - template <typename T> + template <typename T> static T ParseFromBase64String(const TStringBuf& dataBase64, bool allowUneven = false) { - T m; + T m; ParseFromBase64String(dataBase64, m, allowUneven); - return m; - } + return m; + } - /* Serialize message into string and apply base64 URL encoding. - */ + /* Serialize message into string and apply base64 URL encoding. + */ TString SerializeToBase64String(const Message& m); void SerializeToBase64String(const Message& m, TString& dataBase64); bool TrySerializeToBase64String(const Message& m, TString& dataBase64); @@ -44,10 +44,10 @@ namespace NProtoBuf { int operator&(NProtoBuf::Message& m, IBinSaver& f); -// Write a textual representation of the given message to the given file. +// Write a textual representation of the given message to the given file. void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName); -void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out); - +void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out); + // Write a textual representation of the given message to the given output stream // with flags UseShortRepeatedPrimitives and UseUtf8StringEscaping set to true. void SerializeToTextFormatPretty(const NProtoBuf::Message& m, IOutputStream& out); @@ -56,83 +56,83 @@ void SerializeToTextFormatPretty(const NProtoBuf::Message& m, IOutputStream& out // use enum id instead of enum name for all enum fields. void SerializeToTextFormatWithEnumId(const NProtoBuf::Message& m, IOutputStream& out); -enum class EParseFromTextFormatOption : ui64 { - // Unknown fields will be ignored by the parser - AllowUnknownField = 1 -}; - -Y_DECLARE_FLAGS(EParseFromTextFormatOptions, EParseFromTextFormatOption); - -// Parse a text-format protocol message from the given file into message object. +enum class EParseFromTextFormatOption : ui64 { + // Unknown fields will be ignored by the parser + AllowUnknownField = 1 +}; + +Y_DECLARE_FLAGS(EParseFromTextFormatOptions, EParseFromTextFormatOption); + +// Parse a text-format protocol message from the given file into message object. void ParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); -// NOTE: will read `in` till the end. -void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); - -/* @return `true` if parsing was successfull and `false` otherwise. - * - * @see `ParseFromTextFormat` - */ + const EParseFromTextFormatOptions options = {}); +// NOTE: will read `in` till the end. +void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); + +/* @return `true` if parsing was successfull and `false` otherwise. + * + * @see `ParseFromTextFormat` + */ bool TryParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); -// NOTE: will read `in` till the end. -bool TryParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); - -// @see `ParseFromTextFormat` -template <typename T> + const EParseFromTextFormatOptions options = {}); +// NOTE: will read `in` till the end. +bool TryParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); + +// @see `ParseFromTextFormat` +template <typename T> static T ParseFromTextFormat(const TString& fileName, - const EParseFromTextFormatOptions options = {}) { - T message; - ParseFromTextFormat(fileName, message, options); - return message; -} - -// @see `ParseFromTextFormat` -// NOTE: will read `in` till the end. -template <typename T> -static T ParseFromTextFormat(IInputStream& in, - const EParseFromTextFormatOptions options = {}) { - T message; - ParseFromTextFormat(in, message, options); - return message; -} - -// Merge a text-format protocol message from the given file into message object. -// -// NOTE: Even when parsing failed and exception was thrown `m` may be different from its original -// value. User must implement transactional logic around `MergeFromTextFormat` by himself. -void MergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); -// NOTE: will read `in` till the end. -void MergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); -/* @return `true` if parsing was successfull and `false` otherwise. - * - * @see `MergeFromTextFormat` - */ -bool TryMergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); -// NOTE: will read `in` till the end. -bool TryMergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, - const EParseFromTextFormatOptions options = {}); - -// @see `MergeFromTextFormat` -template <typename T> -static T MergeFromTextFormat(const TString& fileName, - const EParseFromTextFormatOptions options = {}) { - T message; - MergeFromTextFormat(fileName, message, options); - return message; -} - -// @see `MergeFromTextFormat` -// NOTE: will read `in` till the end. -template <typename T> -static T MergeFromTextFormat(IInputStream& in, - const EParseFromTextFormatOptions options = {}) { - T message; - MergeFromTextFormat(in, message, options); - return message; -} + const EParseFromTextFormatOptions options = {}) { + T message; + ParseFromTextFormat(fileName, message, options); + return message; +} + +// @see `ParseFromTextFormat` +// NOTE: will read `in` till the end. +template <typename T> +static T ParseFromTextFormat(IInputStream& in, + const EParseFromTextFormatOptions options = {}) { + T message; + ParseFromTextFormat(in, message, options); + return message; +} + +// Merge a text-format protocol message from the given file into message object. +// +// NOTE: Even when parsing failed and exception was thrown `m` may be different from its original +// value. User must implement transactional logic around `MergeFromTextFormat` by himself. +void MergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); +// NOTE: will read `in` till the end. +void MergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); +/* @return `true` if parsing was successfull and `false` otherwise. + * + * @see `MergeFromTextFormat` + */ +bool TryMergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); +// NOTE: will read `in` till the end. +bool TryMergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, + const EParseFromTextFormatOptions options = {}); + +// @see `MergeFromTextFormat` +template <typename T> +static T MergeFromTextFormat(const TString& fileName, + const EParseFromTextFormatOptions options = {}) { + T message; + MergeFromTextFormat(fileName, message, options); + return message; +} + +// @see `MergeFromTextFormat` +// NOTE: will read `in` till the end. +template <typename T> +static T MergeFromTextFormat(IInputStream& in, + const EParseFromTextFormatOptions options = {}) { + T message; + MergeFromTextFormat(in, message, options); + return message; +} diff --git a/library/cpp/protobuf/util/pb_io_ut.cpp b/library/cpp/protobuf/util/pb_io_ut.cpp index 32bba7bc40..875d6dc602 100644 --- a/library/cpp/protobuf/util/pb_io_ut.cpp +++ b/library/cpp/protobuf/util/pb_io_ut.cpp @@ -1,22 +1,22 @@ -#include "pb_io.h" - -#include "is_equal.h" - +#include "pb_io.h" + +#include "is_equal.h" + #include <library/cpp/protobuf/util/ut/common_ut.pb.h> - + #include <library/cpp/testing/unittest/registar.h> - -#include <util/folder/path.h> -#include <util/folder/tempdir.h> -#include <util/stream/file.h> -#include <util/stream/str.h> - -static NProtobufUtilUt::TTextTest GetCorrectMessage() { - NProtobufUtilUt::TTextTest m; - m.SetFoo(42); - return m; -} - + +#include <util/folder/path.h> +#include <util/folder/tempdir.h> +#include <util/stream/file.h> +#include <util/stream/str.h> + +static NProtobufUtilUt::TTextTest GetCorrectMessage() { + NProtobufUtilUt::TTextTest m; + m.SetFoo(42); + return m; +} + static NProtobufUtilUt::TTextEnumTest GetCorrectEnumMessage() { NProtobufUtilUt::TTextEnumTest m; m.SetSlot(NProtobufUtilUt::TTextEnumTest::EET_SLOT_1); @@ -25,41 +25,41 @@ static NProtobufUtilUt::TTextEnumTest GetCorrectEnumMessage() { static const TString CORRECT_MESSAGE = R"(Foo: 42 -)"; +)"; static const TString CORRECT_ENUM_NAME_MESSAGE = R"(Slot: EET_SLOT_1 )"; static const TString CORRECT_ENUM_ID_MESSAGE = R"(Slot: 1 )"; - + static const TString INCORRECT_MESSAGE = R"(Bar: 1 -)"; +)"; static const TString INCORRECT_ENUM_NAME_MESSAGE = R"(Slot: EET_SLOT_3 )"; static const TString INCORRECT_ENUM_ID_MESSAGE = R"(Slot: 3 )"; - + static const TString CORRECT_BASE64_MESSAGE = "CCo,"; static const TString CORRECT_UNEVEN_BASE64_MESSAGE = "CCo"; static const TString INCORRECT_BASE64_MESSAGE = "CC"; -Y_UNIT_TEST_SUITE(TTestProtoBufIO) { - Y_UNIT_TEST(TestBase64) { - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(NProtoBuf::TryParseFromBase64String(CORRECT_BASE64_MESSAGE, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(!NProtoBuf::TryParseFromBase64String(INCORRECT_BASE64_MESSAGE, message)); - } - { +Y_UNIT_TEST_SUITE(TTestProtoBufIO) { + Y_UNIT_TEST(TestBase64) { + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(NProtoBuf::TryParseFromBase64String(CORRECT_BASE64_MESSAGE, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(!NProtoBuf::TryParseFromBase64String(INCORRECT_BASE64_MESSAGE, message)); + } + { NProtobufUtilUt::TTextTest message; UNIT_ASSERT(NProtoBuf::TryParseFromBase64String(CORRECT_UNEVEN_BASE64_MESSAGE , message, true)); } @@ -68,134 +68,134 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { UNIT_ASSERT(!NProtoBuf::TryParseFromBase64String(CORRECT_UNEVEN_BASE64_MESSAGE , message, false)); } { - UNIT_ASSERT_VALUES_EQUAL(CORRECT_BASE64_MESSAGE, NProtoBuf::SerializeToBase64String(GetCorrectMessage())); - } - { - const auto m = NProtoBuf::ParseFromBase64String<NProtobufUtilUt::TTextTest>(CORRECT_BASE64_MESSAGE); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - } - - Y_UNIT_TEST(TestParseFromTextFormat) { - TTempDir tempDir; - const TFsPath correctFileName = TFsPath{tempDir()} / "correct.pb.txt"; - const TFsPath incorrectFileName = TFsPath{tempDir()} / "incorrect.pb.txt"; - + UNIT_ASSERT_VALUES_EQUAL(CORRECT_BASE64_MESSAGE, NProtoBuf::SerializeToBase64String(GetCorrectMessage())); + } + { + const auto m = NProtoBuf::ParseFromBase64String<NProtobufUtilUt::TTextTest>(CORRECT_BASE64_MESSAGE); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + } + + Y_UNIT_TEST(TestParseFromTextFormat) { + TTempDir tempDir; + const TFsPath correctFileName = TFsPath{tempDir()} / "correct.pb.txt"; + const TFsPath incorrectFileName = TFsPath{tempDir()} / "incorrect.pb.txt"; + TFileOutput{correctFileName}.Write(CORRECT_MESSAGE); TFileOutput{incorrectFileName}.Write(INCORRECT_MESSAGE); - - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(TryParseFromTextFormat(correctFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(!TryParseFromTextFormat(incorrectFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{CORRECT_MESSAGE}; - UNIT_ASSERT(TryParseFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT(!TryParseFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(TryParseFromTextFormat(incorrectFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(!TryParseFromTextFormat("this_file_doesnt_exists", message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(TryParseFromTextFormat("this_file_doesnt_exists", message)); - } - { - NProtobufUtilUt::TTextTest message; + + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(TryParseFromTextFormat(correctFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(!TryParseFromTextFormat(incorrectFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{CORRECT_MESSAGE}; + UNIT_ASSERT(TryParseFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT(!TryParseFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(TryParseFromTextFormat(incorrectFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(!TryParseFromTextFormat("this_file_doesnt_exists", message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(TryParseFromTextFormat("this_file_doesnt_exists", message)); + } + { + NProtobufUtilUt::TTextTest message; UNIT_ASSERT_EXCEPTION(ParseFromTextFormat("this_file_doesnt_exists", message), TFileError); } { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(ParseFromTextFormat(correctFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_EXCEPTION(ParseFromTextFormat(incorrectFileName, message), yexception); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{CORRECT_MESSAGE}; - UNIT_ASSERT_NO_EXCEPTION(ParseFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT_EXCEPTION(ParseFromTextFormat(in, message), yexception); - } - { - NProtobufUtilUt::TTextTest m; + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(ParseFromTextFormat(correctFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_EXCEPTION(ParseFromTextFormat(incorrectFileName, message), yexception); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{CORRECT_MESSAGE}; + UNIT_ASSERT_NO_EXCEPTION(ParseFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT_EXCEPTION(ParseFromTextFormat(in, message), yexception); + } + { + NProtobufUtilUt::TTextTest m; const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>(correctFileName); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - UNIT_ASSERT_EXCEPTION(ParseFromTextFormat<NProtobufUtilUt::TTextTest>(incorrectFileName), yexception); - } - { - NProtobufUtilUt::TTextTest m; - TStringInput in{CORRECT_MESSAGE}; + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + UNIT_ASSERT_EXCEPTION(ParseFromTextFormat<NProtobufUtilUt::TTextTest>(incorrectFileName), yexception); + } + { + NProtobufUtilUt::TTextTest m; + TStringInput in{CORRECT_MESSAGE}; const auto f = [&in](NProtobufUtilUt::TTextTest& mm) { mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>(in); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT_EXCEPTION(ParseFromTextFormat<NProtobufUtilUt::TTextTest>(in), yexception); - } - { + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT_EXCEPTION(ParseFromTextFormat<NProtobufUtilUt::TTextTest>(in), yexception); + } + { const TFsPath correctFileName2 = TFsPath{tempDir()} / "serialized.pb.txt"; - const auto original = GetCorrectMessage(); + const auto original = GetCorrectMessage(); UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, correctFileName2)); const auto serializedStr = TUnbufferedFileInput{correctFileName2}.ReadAll(); - UNIT_ASSERT_VALUES_EQUAL(serializedStr, CORRECT_MESSAGE); - } - { - const auto original = GetCorrectMessage(); - TStringStream out; - UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, out)); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), CORRECT_MESSAGE); - } - { - NProtobufUtilUt::TTextTest m; + UNIT_ASSERT_VALUES_EQUAL(serializedStr, CORRECT_MESSAGE); + } + { + const auto original = GetCorrectMessage(); + TStringStream out; + UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, out)); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), CORRECT_MESSAGE); + } + { + NProtobufUtilUt::TTextTest m; const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>( correctFileName, EParseFromTextFormatOption::AllowUnknownField); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - const NProtobufUtilUt::TTextTest empty; - NProtobufUtilUt::TTextTest m; + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + const NProtobufUtilUt::TTextTest empty; + NProtobufUtilUt::TTextTest m; const auto f = [&incorrectFileName](NProtobufUtilUt::TTextTest& mm) { mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>( incorrectFileName, EParseFromTextFormatOption::AllowUnknownField); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(empty, m)); - } - } - + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(empty, m)); + } + } + Y_UNIT_TEST(TestSerializeToTextFormatWithEnumId) { TTempDir tempDir; const TFsPath correctNameFileName = TFsPath{tempDir()} / "correct_name.pb.txt"; @@ -250,139 +250,139 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { } } - Y_UNIT_TEST(TestMergeFromTextFormat) { - // - // Tests cases below are identical to `Parse` tests - // - TTempDir tempDir; - const TFsPath correctFileName = TFsPath{tempDir()} / "correct.pb.txt"; - const TFsPath incorrectFileName = TFsPath{tempDir()} / "incorrect.pb.txt"; - + Y_UNIT_TEST(TestMergeFromTextFormat) { + // + // Tests cases below are identical to `Parse` tests + // + TTempDir tempDir; + const TFsPath correctFileName = TFsPath{tempDir()} / "correct.pb.txt"; + const TFsPath incorrectFileName = TFsPath{tempDir()} / "incorrect.pb.txt"; + TFileOutput{correctFileName}.Write(CORRECT_MESSAGE); TFileOutput{incorrectFileName}.Write(INCORRECT_MESSAGE); - - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(TryMergeFromTextFormat(correctFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(!TryMergeFromTextFormat(incorrectFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{CORRECT_MESSAGE}; - UNIT_ASSERT(TryMergeFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT(!TryMergeFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(TryMergeFromTextFormat(incorrectFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT(!TryMergeFromTextFormat("this_file_doesnt_exists", message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(TryMergeFromTextFormat("this_file_doesnt_exists", message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_EXCEPTION(MergeFromTextFormat("this_file_doesnt_exists", message), TFileError); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_NO_EXCEPTION(MergeFromTextFormat(correctFileName, message)); - } - { - NProtobufUtilUt::TTextTest message; - UNIT_ASSERT_EXCEPTION(MergeFromTextFormat(incorrectFileName, message), yexception); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{CORRECT_MESSAGE}; - UNIT_ASSERT_NO_EXCEPTION(MergeFromTextFormat(in, message)); - } - { - NProtobufUtilUt::TTextTest message; - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT_EXCEPTION(MergeFromTextFormat(in, message), yexception); - } - { - NProtobufUtilUt::TTextTest m; - const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { - mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>(correctFileName); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - UNIT_ASSERT_EXCEPTION(MergeFromTextFormat<NProtobufUtilUt::TTextTest>(incorrectFileName), yexception); - } - { - NProtobufUtilUt::TTextTest m; - TStringInput in{CORRECT_MESSAGE}; - const auto f = [&in](NProtobufUtilUt::TTextTest& mm) { - mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>(in); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - TStringInput in{INCORRECT_MESSAGE}; - UNIT_ASSERT_EXCEPTION(MergeFromTextFormat<NProtobufUtilUt::TTextTest>(in), yexception); - } - { - const TFsPath correctFileName2 = TFsPath{tempDir()} / "serialized.pb.txt"; - const auto original = GetCorrectMessage(); - UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, correctFileName2)); + + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(TryMergeFromTextFormat(correctFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(!TryMergeFromTextFormat(incorrectFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{CORRECT_MESSAGE}; + UNIT_ASSERT(TryMergeFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT(!TryMergeFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(TryMergeFromTextFormat(incorrectFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT(!TryMergeFromTextFormat("this_file_doesnt_exists", message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(TryMergeFromTextFormat("this_file_doesnt_exists", message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_EXCEPTION(MergeFromTextFormat("this_file_doesnt_exists", message), TFileError); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_NO_EXCEPTION(MergeFromTextFormat(correctFileName, message)); + } + { + NProtobufUtilUt::TTextTest message; + UNIT_ASSERT_EXCEPTION(MergeFromTextFormat(incorrectFileName, message), yexception); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{CORRECT_MESSAGE}; + UNIT_ASSERT_NO_EXCEPTION(MergeFromTextFormat(in, message)); + } + { + NProtobufUtilUt::TTextTest message; + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT_EXCEPTION(MergeFromTextFormat(in, message), yexception); + } + { + NProtobufUtilUt::TTextTest m; + const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { + mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>(correctFileName); + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + UNIT_ASSERT_EXCEPTION(MergeFromTextFormat<NProtobufUtilUt::TTextTest>(incorrectFileName), yexception); + } + { + NProtobufUtilUt::TTextTest m; + TStringInput in{CORRECT_MESSAGE}; + const auto f = [&in](NProtobufUtilUt::TTextTest& mm) { + mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>(in); + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + TStringInput in{INCORRECT_MESSAGE}; + UNIT_ASSERT_EXCEPTION(MergeFromTextFormat<NProtobufUtilUt::TTextTest>(in), yexception); + } + { + const TFsPath correctFileName2 = TFsPath{tempDir()} / "serialized.pb.txt"; + const auto original = GetCorrectMessage(); + UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, correctFileName2)); const auto serializedStr = TUnbufferedFileInput{correctFileName2}.ReadAll(); - UNIT_ASSERT_VALUES_EQUAL(serializedStr, CORRECT_MESSAGE); - } - { - const auto original = GetCorrectMessage(); - TStringStream out; - UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, out)); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), CORRECT_MESSAGE); - } - { - NProtobufUtilUt::TTextTest m; - const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { - mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>( + UNIT_ASSERT_VALUES_EQUAL(serializedStr, CORRECT_MESSAGE); + } + { + const auto original = GetCorrectMessage(); + TStringStream out; + UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, out)); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), CORRECT_MESSAGE); + } + { + NProtobufUtilUt::TTextTest m; + const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { + mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>( correctFileName, EParseFromTextFormatOption::AllowUnknownField); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); - } - { - const NProtobufUtilUt::TTextTest empty; - NProtobufUtilUt::TTextTest m; - const auto f = [&incorrectFileName](NProtobufUtilUt::TTextTest& mm) { - mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>( + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); + } + { + const NProtobufUtilUt::TTextTest empty; + NProtobufUtilUt::TTextTest m; + const auto f = [&incorrectFileName](NProtobufUtilUt::TTextTest& mm) { + mm = MergeFromTextFormat<NProtobufUtilUt::TTextTest>( incorrectFileName, EParseFromTextFormatOption::AllowUnknownField); - }; - UNIT_ASSERT_NO_EXCEPTION(f(m)); - UNIT_ASSERT(NProtoBuf::IsEqual(empty, m)); - } - - // - // Test cases for `Merge` - // - { - NProtobufUtilUt::TTextTest message; - message.SetFoo(100500); - TStringInput in{CORRECT_MESSAGE}; - UNIT_ASSERT(TryMergeFromTextFormat(in, message)); - UNIT_ASSERT(NProtoBuf::IsEqual(message, GetCorrectMessage())); - } - } + }; + UNIT_ASSERT_NO_EXCEPTION(f(m)); + UNIT_ASSERT(NProtoBuf::IsEqual(empty, m)); + } + + // + // Test cases for `Merge` + // + { + NProtobufUtilUt::TTextTest message; + message.SetFoo(100500); + TStringInput in{CORRECT_MESSAGE}; + UNIT_ASSERT(TryMergeFromTextFormat(in, message)); + UNIT_ASSERT(NProtoBuf::IsEqual(message, GetCorrectMessage())); + } + } Y_UNIT_TEST(TestMergeFromString) { NProtobufUtilUt::TMergeTest message; @@ -415,4 +415,4 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { UNIT_ASSERT(NProtoBuf::IsEqual(message, m3)); } } -} +} diff --git a/library/cpp/protobuf/util/repeated_field_utils_ut.cpp b/library/cpp/protobuf/util/repeated_field_utils_ut.cpp index d8944cad04..58aaaa9e12 100644 --- a/library/cpp/protobuf/util/repeated_field_utils_ut.cpp +++ b/library/cpp/protobuf/util/repeated_field_utils_ut.cpp @@ -5,8 +5,8 @@ using namespace NProtoBuf; -Y_UNIT_TEST_SUITE(RepeatedFieldUtils) { - Y_UNIT_TEST(RemoveIf) { +Y_UNIT_TEST_SUITE(RepeatedFieldUtils) { + Y_UNIT_TEST(RemoveIf) { { NProtobufUtilUt::TWalkTest msg; msg.AddRepInt(0); diff --git a/library/cpp/protobuf/util/simple_reflection.h b/library/cpp/protobuf/util/simple_reflection.h index 94723d8155..61e877a787 100644 --- a/library/cpp/protobuf/util/simple_reflection.h +++ b/library/cpp/protobuf/util/simple_reflection.h @@ -145,7 +145,7 @@ namespace NProtoBuf { } /* void Swap(TMutableField& f) { - Y_ASSERT(Field() == f.Field()); + Y_ASSERT(Field() == f.Field()); // not implemented yet, TODO: implement when Reflection::Mutable(Ptr)RepeatedField // is ported into arcadia protobuf library from up-stream. diff --git a/library/cpp/protobuf/util/simple_reflection_ut.cpp b/library/cpp/protobuf/util/simple_reflection_ut.cpp index bd5b32e463..169d4703c9 100644 --- a/library/cpp/protobuf/util/simple_reflection_ut.cpp +++ b/library/cpp/protobuf/util/simple_reflection_ut.cpp @@ -6,7 +6,7 @@ using namespace NProtoBuf; -Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { +Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { static TSample GenSampleForMergeFrom() { TSample smf; smf.SetOneStr("one str"); @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { return smf; } - Y_UNIT_TEST(MergeFromGeneric) { + Y_UNIT_TEST(MergeFromGeneric) { const TSample src(GenSampleForMergeFrom()); TSample dst; const Descriptor* descr = dst.GetDescriptor(); @@ -51,7 +51,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { } } - Y_UNIT_TEST(MergeFromSelf) { + Y_UNIT_TEST(MergeFromSelf) { const TSample sample(GenSampleForMergeFrom()); TSample msg(sample); const Descriptor* descr = msg.GetDescriptor(); @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { UNIT_ASSERT_VALUES_EQUAL(msg.GetOneMsg().RepIntSize(), sample.GetOneMsg().RepIntSize()); } - Y_UNIT_TEST(MergeFromAnotherFD) { + Y_UNIT_TEST(MergeFromAnotherFD) { const TSample sample(GenSampleForMergeFrom()); TSample msg(GenSampleForMergeFrom()); const Descriptor* descr = msg.GetDescriptor(); @@ -96,7 +96,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { } } - Y_UNIT_TEST(RemoveByIndex) { + Y_UNIT_TEST(RemoveByIndex) { TSample msg; const Descriptor* descr = msg.GetDescriptor(); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { } } - Y_UNIT_TEST(GetFieldByPath) { + Y_UNIT_TEST(GetFieldByPath) { // Simple get by path { TSample msg; diff --git a/library/cpp/protobuf/util/ut/common_ut.proto b/library/cpp/protobuf/util/ut/common_ut.proto index 638f13778c..9cf803ffbf 100644 --- a/library/cpp/protobuf/util/ut/common_ut.proto +++ b/library/cpp/protobuf/util/ut/common_ut.proto @@ -58,10 +58,10 @@ message TMergeTest { repeated TMergeTestMerge NoMergeRepSub = 4 [(DontMergeField)=true]; optional TMergeTestNoMerge NoMergeOptSub = 5; } - -message TTextTest { - optional uint32 Foo = 1; -} + +message TTextTest { + optional uint32 Foo = 1; +} message TTextEnumTest { enum EnumTest { diff --git a/library/cpp/protobuf/util/ut/ya.make b/library/cpp/protobuf/util/ut/ya.make index c358aac35c..701ba9a8c8 100644 --- a/library/cpp/protobuf/util/ut/ya.make +++ b/library/cpp/protobuf/util/ut/ya.make @@ -7,7 +7,7 @@ SRCS( sample_for_is_equal.proto sample_for_simple_reflection.proto common_ut.proto - pb_io_ut.cpp + pb_io_ut.cpp is_equal_ut.cpp iterators_ut.cpp simple_reflection_ut.cpp diff --git a/library/cpp/protobuf/util/walk_ut.cpp b/library/cpp/protobuf/util/walk_ut.cpp index 319e87983e..2ea6071b17 100644 --- a/library/cpp/protobuf/util/walk_ut.cpp +++ b/library/cpp/protobuf/util/walk_ut.cpp @@ -6,7 +6,7 @@ using namespace NProtoBuf; -Y_UNIT_TEST_SUITE(ProtobufWalk) { +Y_UNIT_TEST_SUITE(ProtobufWalk) { static void InitProto(NProtobufUtilUt::TWalkTest & p, int level = 0) { p.SetOptInt(1); p.AddRepInt(2); diff --git a/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp b/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp index b12985579c..9caa53f2e7 100644 --- a/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp +++ b/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp @@ -7,11 +7,11 @@ #include <array> #include <algorithm> -Y_UNIT_TEST_SUITE(HyperscanWrappers) { +Y_UNIT_TEST_SUITE(HyperscanWrappers) { using namespace NHyperscan; using namespace NHyperscan::NPrivate; - Y_UNIT_TEST(CompileAndScan) { + Y_UNIT_TEST(CompileAndScan) { TDatabase db = Compile("a.c", HS_FLAG_DOTALL | HS_FLAG_SINGLEMATCH); TScratch scratch = MakeScratch(db); @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { UNIT_ASSERT_EQUAL(foundId, 0); } - Y_UNIT_TEST(Matches) { + Y_UNIT_TEST(Matches) { NHyperscan::TDatabase db = NHyperscan::Compile( "a.c", HS_FLAG_DOTALL | HS_FLAG_SINGLEMATCH); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { UNIT_ASSERT(!NHyperscan::Matches(db, scratch, "foo")); } - Y_UNIT_TEST(Multi) { + Y_UNIT_TEST(Multi) { NHyperscan::TDatabase db = NHyperscan::CompileMulti( { "foo", @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { } // https://ml.yandex-team.ru/thread/2370000002965712422/ - Y_UNIT_TEST(MultiRegression) { + Y_UNIT_TEST(MultiRegression) { NHyperscan::CompileMulti( { "aa.bb/cc.dd", @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { }); } - Y_UNIT_TEST(Serialize) { + Y_UNIT_TEST(Serialize) { NHyperscan::TDatabase db = NHyperscan::Compile( "foo", HS_FLAG_DOTALL | HS_FLAG_SINGLEMATCH); @@ -98,7 +98,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { UNIT_ASSERT(!NHyperscan::Matches(db2, scratch, "FOO")); } - Y_UNIT_TEST(GrowScratch) { + Y_UNIT_TEST(GrowScratch) { NHyperscan::TDatabase db1 = NHyperscan::Compile( "foo", HS_FLAG_DOTALL | HS_FLAG_SINGLEMATCH); @@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { UNIT_ASSERT(NHyperscan::Matches(db2, scratch, "longerWWWpattern")); } - Y_UNIT_TEST(CloneScratch) { + Y_UNIT_TEST(CloneScratch) { NHyperscan::TDatabase db = NHyperscan::Compile( "foo", HS_FLAG_DOTALL | HS_FLAG_SINGLEMATCH); diff --git a/library/cpp/regex/pcre/regexp_ut.cpp b/library/cpp/regex/pcre/regexp_ut.cpp index 3818fe59c3..5184e801cc 100644 --- a/library/cpp/regex/pcre/regexp_ut.cpp +++ b/library/cpp/regex/pcre/regexp_ut.cpp @@ -1,6 +1,6 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/string/strip.h> +#include <util/string/strip.h> #include <library/cpp/regex/pcre/regexp.h> #include <util/stream/output.h> @@ -54,17 +54,17 @@ private: UNIT_TEST_SUITE_END(); inline void TestRe() { - for (const auto& regTest : REGTEST_DATA) { + for (const auto& regTest : REGTEST_DATA) { memset(Matches, 0, sizeof(Matches)); TString result; TRegExBase re(regTest.Regexp, regTest.CompileOptions); if (re.Exec(regTest.Data, Matches, regTest.RunOptions) == 0) { - for (auto& matche : Matches) { - if (matche.rm_so == -1) { + for (auto& matche : Matches) { + if (matche.rm_so == -1) { break; } - result.append(Sprintf("%i %i ", matche.rm_so, matche.rm_eo)); + result.append(Sprintf("%i %i ", matche.rm_so, matche.rm_eo)); } } else { result = "NM"; @@ -75,7 +75,7 @@ private: } inline void TestSubst() { - for (const auto& substTest : SUBSTTEST_DATA) { + for (const auto& substTest : SUBSTTEST_DATA) { TRegExSubst subst(substTest.Regexp, substTest.CompileOptions); subst.ParseReplacement(substTest.Replacement); TString result = subst.Replace(substTest.Data, substTest.RunOptions); diff --git a/library/cpp/regex/pire/regexp.h b/library/cpp/regex/pire/regexp.h index 9321863bad..94bba4064b 100644 --- a/library/cpp/regex/pire/regexp.h +++ b/library/cpp/regex/pire/regexp.h @@ -58,8 +58,8 @@ namespace NRegExp { size_t outWritten = 0; int recodeRes = RecodeToUnicode(opts.Charset, regexp.data(), ucs4.data(), regexp.size(), regexp.size(), inRead, outWritten); - Y_ASSERT(recodeRes == RECODE_OK); - Y_ASSERT(outWritten < ucs4.size()); + Y_ASSERT(recodeRes == RECODE_OK); + Y_ASSERT(outWritten < ucs4.size()); ucs4[outWritten] = 0; lexer.Assign(ucs4.begin(), diff --git a/library/cpp/regex/pire/ut/regexp_ut.cpp b/library/cpp/regex/pire/ut/regexp_ut.cpp index 0bb72b3fde..e7206de9ad 100644 --- a/library/cpp/regex/pire/ut/regexp_ut.cpp +++ b/library/cpp/regex/pire/ut/regexp_ut.cpp @@ -3,20 +3,20 @@ #include <library/cpp/regex/pire/regexp.h> #include <library/cpp/regex/pire/pcre2pire.h> -Y_UNIT_TEST_SUITE(TRegExp) { +Y_UNIT_TEST_SUITE(TRegExp) { using namespace NRegExp; - Y_UNIT_TEST(False) { + Y_UNIT_TEST(False) { UNIT_ASSERT(!TMatcher(TFsm::False()).Match("").Final()); UNIT_ASSERT(!TMatcher(TFsm::False()).Match(TStringBuf{}).Final()); } - Y_UNIT_TEST(Surround) { + Y_UNIT_TEST(Surround) { UNIT_ASSERT(TMatcher(TFsm("qw", TFsm::TOptions().SetSurround(true))).Match("aqwb").Final()); UNIT_ASSERT(!TMatcher(TFsm("qw", TFsm::TOptions().SetSurround(false))).Match("aqwb").Final()); } - Y_UNIT_TEST(Boundaries) { + Y_UNIT_TEST(Boundaries) { UNIT_ASSERT(!TMatcher(TFsm("qwb$", TFsm::TOptions().SetSurround(true))).Match("aqwb").Final()); UNIT_ASSERT(!TMatcher(TFsm("^aqw", TFsm::TOptions().SetSurround(true))).Match("aqwb").Final()); UNIT_ASSERT(TMatcher(TFsm("qwb$", TFsm::TOptions().SetSurround(true))).Match(TStringBuf("aqwb"), true, true).Final()); @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { .Final()); } - Y_UNIT_TEST(Case) { + Y_UNIT_TEST(Case) { UNIT_ASSERT(TMatcher(TFsm("qw", TFsm::TOptions().SetCaseInsensitive(true))).Match("Qw").Final()); UNIT_ASSERT(!TMatcher(TFsm("qw", TFsm::TOptions().SetCaseInsensitive(false))).Match("Qw").Final()); } @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT(!TMatcher(TFsm("\\x{61}\\x{62}", TFsm::TOptions().SetCaseInsensitive(false))).Match("Ab").Final()); } - Y_UNIT_TEST(Utf) { + Y_UNIT_TEST(Utf) { NRegExp::TFsmBase::TOptions opts; opts.Charset = CODES_UTF8; opts.Surround = true; @@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { } } - Y_UNIT_TEST(Glue) { + Y_UNIT_TEST(Glue) { TFsm glued = TFsm("qw", TFsm::TOptions().SetCaseInsensitive(true)) | TFsm("qw", TFsm::TOptions().SetCaseInsensitive(false)) | @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT(!TMatcher(glued).Match("Abc").Final()); } - Y_UNIT_TEST(Capture1) { + Y_UNIT_TEST(Capture1) { TCapturingFsm fsm("here we have user_id=([a-z0-9]+);"); TSearcher searcher(fsm); @@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("0x0d0a")); } - Y_UNIT_TEST(Capture2) { + Y_UNIT_TEST(Capture2) { TCapturingFsm fsm("w([abcdez]+)f"); TSearcher searcher(fsm); @@ -112,7 +112,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("abcde")); } - Y_UNIT_TEST(Capture3) { + Y_UNIT_TEST(Capture3) { TCapturingFsm fsm("http://vk(ontakte[.]ru|[.]com)/id(\\d+)([^0-9]|$)", TFsm::TOptions().SetCapture(2)); @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("100500")); } - Y_UNIT_TEST(Capture4) { + Y_UNIT_TEST(Capture4) { TCapturingFsm fsm("Здравствуйте, ((\\s|\\w|[()]|-)+)!", TFsm::TOptions().SetCharset(CODES_UTF8)); @@ -132,7 +132,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("Уважаемый (-ая)")); } - Y_UNIT_TEST(Capture5) { + Y_UNIT_TEST(Capture5) { TCapturingFsm fsm("away\\.php\\?to=http:([^\"])+\""); TSearcher searcher(fsm); searcher.Search("\"/away.php?to=http:some.addr\"&id=1"); @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { //UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("some.addr")); } - Y_UNIT_TEST(Capture6) { + Y_UNIT_TEST(Capture6) { TCapturingFsm fsm("(/to-match-with)"); TSearcher searcher(fsm); searcher.Search("/some/table/path/to-match-with"); @@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("/to-match-with")); } - Y_UNIT_TEST(Capture7) { + Y_UNIT_TEST(Capture7) { TCapturingFsm fsm("(pref.*suff)"); TSearcher searcher(fsm); searcher.Search("ala pref bla suff cla"); @@ -305,7 +305,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT(!searcher.Captured()); } - Y_UNIT_TEST(Pcre2PireTest) { + Y_UNIT_TEST(Pcre2PireTest) { UNIT_ASSERT_VALUES_EQUAL(Pcre2Pire("(?:fake)"), "(fake)"); UNIT_ASSERT_VALUES_EQUAL(Pcre2Pire("(?:fake)??"), "(fake)?"); UNIT_ASSERT_VALUES_EQUAL(Pcre2Pire("(?:fake)*?fake"), "(fake)*fake"); diff --git a/library/cpp/resource/registry.cpp b/library/cpp/resource/registry.cpp index f9e4ca0bf7..66001c4769 100644 --- a/library/cpp/resource/registry.cpp +++ b/library/cpp/resource/registry.cpp @@ -69,8 +69,8 @@ namespace { } void FindMatch(const TStringBuf subkey, IMatch& cb) const override { - for (const auto& it : *this) { - if (it.first.StartsWith(subkey)) { + for (const auto& it : *this) { + if (it.first.StartsWith(subkey)) { // temporary // https://st.yandex-team.ru/DEVTOOLS-3985 try { diff --git a/library/cpp/resource/ut/resource_ut.cpp b/library/cpp/resource/ut/resource_ut.cpp index 68b34485cf..b6fa8e4df3 100644 --- a/library/cpp/resource/ut/resource_ut.cpp +++ b/library/cpp/resource/ut/resource_ut.cpp @@ -1,8 +1,8 @@ #include <library/cpp/resource/resource.h> #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestResource) { - Y_UNIT_TEST(Test1) { +Y_UNIT_TEST_SUITE(TestResource) { + Y_UNIT_TEST(Test1) { UNIT_ASSERT_VALUES_EQUAL(NResource::Find("/x"), "na gorshke sidel korol\n"); } } diff --git a/library/cpp/retry/retry.h b/library/cpp/retry/retry.h index 63a2b38967..c47ff5070f 100644 --- a/library/cpp/retry/retry.h +++ b/library/cpp/retry/retry.h @@ -128,6 +128,6 @@ void DoWithRetry(std::function<void()> func, TRetryOptions retryOptions); bool DoWithRetryOnRetCode(std::function<bool()> func, TRetryOptions retryOptions); -Y_DECLARE_PODTYPE(TRetryOptions); +Y_DECLARE_PODTYPE(TRetryOptions); TRetryOptions MakeRetryOptions(const NRetry::TRetryOptionsPB& retryOptions); diff --git a/library/cpp/retry/retry_ut.cpp b/library/cpp/retry/retry_ut.cpp index c9cbb72a50..92153e987e 100644 --- a/library/cpp/retry/retry_ut.cpp +++ b/library/cpp/retry/retry_ut.cpp @@ -27,8 +27,8 @@ namespace { }; } -Y_UNIT_TEST_SUITE(Retry) { - Y_UNIT_TEST(RetryOnExceptionSuccess) { +Y_UNIT_TEST_SUITE(Retry) { + Y_UNIT_TEST(RetryOnExceptionSuccess) { UNIT_ASSERT_NO_EXCEPTION(DoWithRetry(TDoOnSecondOrThrow{}, TRetryOptions(1, TDuration::Zero()))); } Y_UNIT_TEST(RetryOnExceptionSuccessWithOnFail) { @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT_NO_EXCEPTION(DoWithRetry<ui32>(TDoOnSecondOrThrow{}, cb, TRetryOptions(1, TDuration::Zero()), true)); UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnExceptionFail) { + Y_UNIT_TEST(RetryOnExceptionFail) { UNIT_ASSERT_EXCEPTION(DoWithRetry(TDoOnSecondOrThrow{}, TRetryOptions(0, TDuration::Zero())), yexception); } Y_UNIT_TEST(RetryOnExceptionFailWithOnFail) { @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnExceptionSuccessWithValue) { + Y_UNIT_TEST(RetryOnExceptionSuccessWithValue) { std::function<ui32()> f = TDoOnSecondOrThrow{}; UNIT_ASSERT(42 == *DoWithRetry<ui32>(f, TRetryOptions(1, TDuration::Zero()), false)); } @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT(42 == *DoWithRetry<ui32>(f, cb, TRetryOptions(1, TDuration::Zero()), false)); UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnExceptionFailWithValue) { + Y_UNIT_TEST(RetryOnExceptionFailWithValue) { std::function<ui32()> f = TDoOnSecondOrThrow{}; UNIT_ASSERT(!DoWithRetry<ui32>(f, TRetryOptions(0, TDuration::Zero()), false).Defined()); } @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnExceptionSuccessWithValueAndRethrow) { + Y_UNIT_TEST(RetryOnExceptionSuccessWithValueAndRethrow) { std::function<ui32()> f = TDoOnSecondOrThrow{}; UNIT_ASSERT(42 == *DoWithRetry<ui32>(f, TRetryOptions(1, TDuration::Zero()), true)); } @@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT(42 == *DoWithRetry<ui32>(f, cb, TRetryOptions(1, TDuration::Zero()), true)); UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnExceptionFailWithValueAndRethrow) { + Y_UNIT_TEST(RetryOnExceptionFailWithValueAndRethrow) { std::function<ui32()> f = TDoOnSecondOrThrow{}; UNIT_ASSERT_EXCEPTION(DoWithRetry<ui32>(f, TRetryOptions(0, TDuration::Zero()), true), yexception); } @@ -93,10 +93,10 @@ Y_UNIT_TEST_SUITE(Retry) { UNIT_ASSERT_EQUAL(value, 1); } - Y_UNIT_TEST(RetryOnRetCodeSuccess) { + Y_UNIT_TEST(RetryOnRetCodeSuccess) { UNIT_ASSERT(true == DoWithRetryOnRetCode(TDoOnSecondOrFail{}, TRetryOptions(1, TDuration::Zero()))); } - Y_UNIT_TEST(RetryOnRetCodeFail) { + Y_UNIT_TEST(RetryOnRetCodeFail) { UNIT_ASSERT(false == DoWithRetryOnRetCode(TDoOnSecondOrFail{}, TRetryOptions(0, TDuration::Zero()))); } Y_UNIT_TEST(MakeRetryOptionsFromProto) { diff --git a/library/cpp/scheme/scheme.cpp b/library/cpp/scheme/scheme.cpp index 9ecdb4ac76..3efd116d4f 100644 --- a/library/cpp/scheme/scheme.cpp +++ b/library/cpp/scheme/scheme.cpp @@ -593,6 +593,6 @@ namespace NSc { } template <> -void Out<NSc::TValue>(IOutputStream& o, TTypeTraits<NSc::TValue>::TFuncParam v) { +void Out<NSc::TValue>(IOutputStream& o, TTypeTraits<NSc::TValue>::TFuncParam v) { o.Write(v.ToJson(true)); } diff --git a/library/cpp/scheme/scheme.h b/library/cpp/scheme/scheme.h index 93ea9e24e4..3d7c59f3c9 100644 --- a/library/cpp/scheme/scheme.h +++ b/library/cpp/scheme/scheme.h @@ -302,15 +302,15 @@ namespace NSc { // TODO: Переименовать ToJson в ToJsonUnsafe, а ToJsonSafe в ToJson TString ToJson(const TJsonOpts& = TJsonOpts()) const; - const TValue& ToJson(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; // returns self + const TValue& ToJson(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; // returns self // ToJson(JO_SORT_KEYS | JO_SKIP_UNSAFE) TString ToJsonSafe(const TJsonOpts& = TJsonOpts()) const; - const TValue& ToJsonSafe(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; + const TValue& ToJsonSafe(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; // ToJson(JO_SORT_KEYS | JO_PRETTY | JO_SKIP_UNSAFE) TString ToJsonPretty(const TJsonOpts& = TJsonOpts()) const; - const TValue& ToJsonPretty(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; + const TValue& ToJsonPretty(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; NJson::TJsonValue ToJsonValue() const; @@ -400,7 +400,7 @@ namespace NSc { return DefaultValue(); } - void DoWriteJsonImpl(IOutputStream&, const TJsonOpts&, NImpl::TKeySortContext&, NImpl::TSelfLoopContext&) const; + void DoWriteJsonImpl(IOutputStream&, const TJsonOpts&, NImpl::TKeySortContext&, NImpl::TSelfLoopContext&) const; bool IsSameOrAncestorOf(const TValue& other) const; diff --git a/library/cpp/scheme/scheme_cast.h b/library/cpp/scheme/scheme_cast.h index 0fa1242da5..00839e8017 100644 --- a/library/cpp/scheme/scheme_cast.h +++ b/library/cpp/scheme/scheme_cast.h @@ -161,13 +161,13 @@ namespace NJsonConverters { typedef typename T::key_type TKey; typedef typename T::mapped_type TMapped; if (validate) - Y_ENSURE(x.IsDict() || x.IsNull(), "not valid input scheme"); + Y_ENSURE(x.IsDict() || x.IsNull(), "not valid input scheme"); out.clear(); if (x.IsDict()) { const NSc::TDict& dict = x.GetDict(); - for (const auto& it : dict) { - TKey key = NJsonConverters::FromString<TKey>(it.first, validate); - TMapped val = NJsonConverters::FromTValue<TMapped>(it.second, validate); + for (const auto& it : dict) { + TKey key = NJsonConverters::FromString<TKey>(it.first, validate); + TMapped val = NJsonConverters::FromTValue<TMapped>(it.second, validate); out.insert(std::pair<TKey, TMapped>(key, val)); } } @@ -187,13 +187,13 @@ namespace NJsonConverters { void FromTValueSet(const NSc::TValue& x, T& out, const bool validate) { typedef typename T::key_type TKey; if (validate) - Y_ENSURE(x.IsDict() || x.IsNull(), "not valid input scheme"); + Y_ENSURE(x.IsDict() || x.IsNull(), "not valid input scheme"); out.clear(); if (x.IsDict()) { const NSc::TDict& dict = x.GetDict(); - for (const auto& it : dict) { + for (const auto& it : dict) { TKey key; - NJsonConverters::FromString<TKey>(it.first, key, validate); + NJsonConverters::FromString<TKey>(it.first, key, validate); out.insert(key); } } @@ -215,14 +215,14 @@ namespace NJsonConverters { template <typename T, typename A> void FromTValue(const NSc::TValue& x, TVector<T, A>& out, const bool validate) { if (validate) - Y_ENSURE(x.IsArray() || x.IsNull(), "not valid input scheme"); + Y_ENSURE(x.IsArray() || x.IsNull(), "not valid input scheme"); out.clear(); if (x.IsArray()) { const NSc::TArray& arr = x.GetArray(); out.reserve(arr.size()); - for (const auto& it : arr) { + for (const auto& it : arr) { T val; - NJsonConverters::FromTValue(it, val, validate); + NJsonConverters::FromTValue(it, val, validate); out.push_back(val); } } @@ -289,7 +289,7 @@ namespace NJsonConverters { template <class T1, class T2> void FromTValue(const NSc::TValue& x, std::pair<T1, T2>& out, const bool validate) { if (validate) - Y_ENSURE(x.IsArray() || x.IsNull(), "not valid input scheme"); + Y_ENSURE(x.IsArray() || x.IsNull(), "not valid input scheme"); if (x.IsArray()) { const NSc::TArray& arr = x.GetArray(); if (arr.size() == 2) { diff --git a/library/cpp/scheme/scimpl_json_write.cpp b/library/cpp/scheme/scimpl_json_write.cpp index f792851098..aadd7e6cd5 100644 --- a/library/cpp/scheme/scimpl_json_write.cpp +++ b/library/cpp/scheme/scimpl_json_write.cpp @@ -18,7 +18,7 @@ namespace NSc { return IsFinite(d); } - static inline void WriteString(IOutputStream& out, TStringBuf s) { + static inline void WriteString(IOutputStream& out, TStringBuf s) { NEscJ::EscapeJ<true, true>(s, out); } @@ -39,7 +39,7 @@ namespace NSc { } template <typename TDictKeys> - static inline void WriteDict(IOutputStream& out, const TDictKeys& keys, const TDict& dict, + static inline void WriteDict(IOutputStream& out, const TDictKeys& keys, const TDict& dict, const TJsonOpts& jopts, NImpl::TKeySortContext& sortCtx, NImpl::TSelfLoopContext& loopCtx) { using const_iterator = typename TDictKeys::const_iterator; const_iterator begin = keys.begin(); @@ -63,7 +63,7 @@ namespace NSc { } } - void TValue::DoWriteJsonImpl(IOutputStream& out, const TJsonOpts& jopts, + void TValue::DoWriteJsonImpl(IOutputStream& out, const TJsonOpts& jopts, NImpl::TKeySortContext& sortCtx, NImpl::TSelfLoopContext& loopCtx) const { const TScCore& core = Core(); @@ -140,7 +140,7 @@ namespace NSc { } } - const TValue& TValue::ToJson(IOutputStream& out, const TJsonOpts& jopts) const { + const TValue& TValue::ToJson(IOutputStream& out, const TJsonOpts& jopts) const { using namespace NImpl; if (jopts.FormatJson) { @@ -179,7 +179,7 @@ namespace NSc { return ToJson(MakeOptsSafeForSerializer(jopts)); } - const TValue& TValue::ToJsonSafe(IOutputStream& out, const TJsonOpts& jopts) const { + const TValue& TValue::ToJsonSafe(IOutputStream& out, const TJsonOpts& jopts) const { return ToJson(out, MakeOptsSafeForSerializer(jopts)); } @@ -187,7 +187,7 @@ namespace NSc { return ToJson(MakeOptsPrettyForSerializer(jopts)); } - const TValue& TValue::ToJsonPretty(IOutputStream& out, const TJsonOpts& jopts) const { + const TValue& TValue::ToJsonPretty(IOutputStream& out, const TJsonOpts& jopts) const { return ToJson(out, MakeOptsPrettyForSerializer(jopts)); } } diff --git a/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp b/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp index b2eb7226b4..4f907157e9 100644 --- a/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp @@ -16,8 +16,8 @@ using THSI = THashSet<int>; using TSI = TSet<int>; using TPI = std::pair<int, int>; -Y_UNIT_TEST_SUITE(TSchemeCastTest) { - Y_UNIT_TEST(TestYVector) { +Y_UNIT_TEST_SUITE(TSchemeCastTest) { + Y_UNIT_TEST(TestYVector) { TVI v; for (int i = 0; i < 3; ++i) v.push_back(i); @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT(std::equal(v.begin(), v.end(), y.begin())); } - Y_UNIT_TEST(TestYHash) { + Y_UNIT_TEST(TestYHash) { THI h; for (int i = 0; i < 3; ++i) h[i] = i * i; @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(h2, true), ToJson(h, true)); } - Y_UNIT_TEST(TestYMap) { + Y_UNIT_TEST(TestYMap) { TMI h; for (int i = 0; i < 3; ++i) h[i] = i * i; @@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(h2, true), ToJson(h, true)); } - Y_UNIT_TEST(TestYHashSet) { + Y_UNIT_TEST(TestYHashSet) { THSI h; for (int i = 0; i < 3; ++i) h.insert(i * i); @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(h2, true), ToJson(h, true)); } - Y_UNIT_TEST(TestYSet) { + Y_UNIT_TEST(TestYSet) { TSI h; for (int i = 0; i < 3; ++i) h.insert(i * i); @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(h2, true), ToJson(h, true)); } - Y_UNIT_TEST(TestTPair) { + Y_UNIT_TEST(TestTPair) { TPI p(1, 1); const TString etalon = "[1,1]"; @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { } }; - Y_UNIT_TEST(TestTCustom) { + Y_UNIT_TEST(TestTCustom) { TCustom x(2, 3); const TString etalon = "{\"a\":2,\"b\":3}"; @@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(x2, true), ToJson(x, true)); } - Y_UNIT_TEST(TestVectorOfPairs) { + Y_UNIT_TEST(TestVectorOfPairs) { typedef TVector<TPI> TVPI; TVPI v; @@ -137,7 +137,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(v2, true), ToJson(v, true)); } - Y_UNIT_TEST(TestSetOfCustom) { + Y_UNIT_TEST(TestSetOfCustom) { typedef TSet<TCustom> TSC; TSC s; s.insert(TCustom(2, 3)); @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { UNIT_ASSERT_VALUES_EQUAL(ToJson(s2, true), ToJson(s, true)); } - Y_UNIT_TEST(TestExceptions) { + Y_UNIT_TEST(TestExceptions) { NSc::TValue v = 1; const TString json = v.ToJson(); UNIT_ASSERT_EXCEPTION(FromJson<TVI>(json, true), yexception); diff --git a/library/cpp/sliding_window/sliding_window_ut.cpp b/library/cpp/sliding_window/sliding_window_ut.cpp index 3b2366791a..1e7343a8d3 100644 --- a/library/cpp/sliding_window/sliding_window_ut.cpp +++ b/library/cpp/sliding_window/sliding_window_ut.cpp @@ -4,8 +4,8 @@ using namespace NSlidingWindow; -Y_UNIT_TEST_SUITE(TSlidingWindowTest) { - Y_UNIT_TEST(TestSlidingWindowMax) { +Y_UNIT_TEST_SUITE(TSlidingWindowTest) { + Y_UNIT_TEST(TestSlidingWindowMax) { TSlidingWindow<TMaxOperation<unsigned>> w(TDuration::Minutes(5), 5); TInstant start = TInstant::MicroSeconds(TDuration::Hours(1).MicroSeconds()); TInstant now = start; @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TSlidingWindowTest) { UNIT_ASSERT_VALUES_EQUAL(w.Update(now), 0); } - Y_UNIT_TEST(TestSlidingWindowMin) { + Y_UNIT_TEST(TestSlidingWindowMin) { TSlidingWindow<TMinOperation<unsigned>> w(TDuration::Minutes(5), 5); TInstant start = TInstant::MicroSeconds(TDuration::Hours(1).MicroSeconds()); TInstant now = start; @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TSlidingWindowTest) { UNIT_ASSERT_VALUES_EQUAL(w.Update(now), std::numeric_limits<unsigned>::max()); } - Y_UNIT_TEST(TestSlidingWindowSum) { + Y_UNIT_TEST(TestSlidingWindowSum) { TSlidingWindow<TSumOperation<unsigned>> w(TDuration::Minutes(5), 5); UNIT_ASSERT_VALUES_EQUAL(w.GetValue(), 0); // current sum diff --git a/library/cpp/streams/brotli/brotli_ut.cpp b/library/cpp/streams/brotli/brotli_ut.cpp index 6dcec657b1..aeb2e284dc 100644 --- a/library/cpp/streams/brotli/brotli_ut.cpp +++ b/library/cpp/streams/brotli/brotli_ut.cpp @@ -4,7 +4,7 @@ #include <util/random/fast.h> -Y_UNIT_TEST_SUITE(TBrotliTestSuite) { +Y_UNIT_TEST_SUITE(TBrotliTestSuite) { TString Compress(TString data) { TString compressed; TStringOutput output(compressed); @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(TBrotliTestSuite) { return result; } - Y_UNIT_TEST(TestHelloWorld) { + Y_UNIT_TEST(TestHelloWorld) { TestCase("hello world"); } @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TBrotliTestSuite) { } } - Y_UNIT_TEST(TestSeveralStreams) { + Y_UNIT_TEST(TestSeveralStreams) { auto s1 = GenerateRandomString(1 << 15); auto s2 = GenerateRandomString(1 << 15); auto c1 = Compress(s1); @@ -66,24 +66,24 @@ Y_UNIT_TEST_SUITE(TBrotliTestSuite) { UNIT_ASSERT_VALUES_EQUAL(s1 + s2, Decompress(c1 + c2)); } - Y_UNIT_TEST(TestIncompleteStream) { + Y_UNIT_TEST(TestIncompleteStream) { TString manyAs(64 * 1024, 'a'); auto compressed = Compress(manyAs); TString truncated(compressed.data(), compressed.size() - 1); UNIT_CHECK_GENERATED_EXCEPTION(Decompress(truncated), std::exception); } - Y_UNIT_TEST(Test64KB) { + Y_UNIT_TEST(Test64KB) { auto manyAs = TString(64 * 1024, 'a'); TString str("Hello from the Matrix!@#% How are you?}{\n\t\a"); TestCase(manyAs + str + manyAs); } - Y_UNIT_TEST(Test1MB) { + Y_UNIT_TEST(Test1MB) { TestCase(GenerateRandomString(1 * 1024 * 1024)); } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { TestCase(""); } } diff --git a/library/cpp/streams/bzip2/bzip2.cpp b/library/cpp/streams/bzip2/bzip2.cpp index 1fcb31c99c..bccc5c6807 100644 --- a/library/cpp/streams/bzip2/bzip2.cpp +++ b/library/cpp/streams/bzip2/bzip2.cpp @@ -7,7 +7,7 @@ class TBZipDecompress::TImpl: public TAdditionalStorage<TImpl> { public: - inline TImpl(IInputStream* input) + inline TImpl(IInputStream* input) : Stream_(input) { Zero(BzStream_); @@ -70,11 +70,11 @@ public: } private: - IInputStream* Stream_; + IInputStream* Stream_; bz_stream BzStream_; }; -TBZipDecompress::TBZipDecompress(IInputStream* input, size_t bufLen) +TBZipDecompress::TBZipDecompress(IInputStream* input, size_t bufLen) : Impl_(new (bufLen) TImpl(input)) { } @@ -88,7 +88,7 @@ size_t TBZipDecompress::DoRead(void* buf, size_t size) { class TBZipCompress::TImpl: public TAdditionalStorage<TImpl> { public: - inline TImpl(IOutputStream* stream, size_t level) + inline TImpl(IOutputStream* stream, size_t level) : Stream_(stream) { Zero(BzStream_); @@ -165,11 +165,11 @@ private: } private: - IOutputStream* Stream_; + IOutputStream* Stream_; bz_stream BzStream_; }; -TBZipCompress::TBZipCompress(IOutputStream* out, size_t compressionLevel, size_t bufLen) +TBZipCompress::TBZipCompress(IOutputStream* out, size_t compressionLevel, size_t bufLen) : Impl_(new (bufLen) TImpl(out, compressionLevel)) { } diff --git a/library/cpp/streams/bzip2/bzip2.h b/library/cpp/streams/bzip2/bzip2.h index 1271b976df..2322277ef6 100644 --- a/library/cpp/streams/bzip2/bzip2.h +++ b/library/cpp/streams/bzip2/bzip2.h @@ -22,9 +22,9 @@ class TBZipDecompressError: public TBZipException { class TBZipCompressError: public TBZipException { }; -class TBZipDecompress: public IInputStream { +class TBZipDecompress: public IInputStream { public: - TBZipDecompress(IInputStream* input, size_t bufLen = BZIP_BUF_LEN); + TBZipDecompress(IInputStream* input, size_t bufLen = BZIP_BUF_LEN); ~TBZipDecompress() override; private: @@ -35,9 +35,9 @@ private: THolder<TImpl> Impl_; }; -class TBZipCompress: public IOutputStream { +class TBZipCompress: public IOutputStream { public: - TBZipCompress(IOutputStream* out, size_t compressionLevel = BZIP_COMPRESSION_LEVEL, size_t bufLen = BZIP_BUF_LEN); + TBZipCompress(IOutputStream* out, size_t compressionLevel = BZIP_COMPRESSION_LEVEL, size_t bufLen = BZIP_BUF_LEN); ~TBZipCompress() override; private: diff --git a/library/cpp/streams/bzip2/bzip2_ut.cpp b/library/cpp/streams/bzip2/bzip2_ut.cpp index cb7e11d099..69a98f296c 100644 --- a/library/cpp/streams/bzip2/bzip2_ut.cpp +++ b/library/cpp/streams/bzip2/bzip2_ut.cpp @@ -7,10 +7,10 @@ #define ZDATA "./zdata" -Y_UNIT_TEST_SUITE(TBZipTest) { +Y_UNIT_TEST_SUITE(TBZipTest) { static const TString data = "8s7d5vc6s5vc67sa4c65ascx6asd4xcv76adsfxv76s"; - Y_UNIT_TEST(TestCompress) { + Y_UNIT_TEST(TestCompress) { TUnbufferedFileOutput o(ZDATA); TBZipCompress c(&o); @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TBZipTest) { o.Finish(); } - Y_UNIT_TEST(TestDecompress) { + Y_UNIT_TEST(TestDecompress) { TTempFile tmp(ZDATA); { @@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TBZipTest) { } } - Y_UNIT_TEST(TestCorrupted) { + Y_UNIT_TEST(TestCorrupted) { TMemoryInput i("blablabla", 10); TBZipDecompress d(&i); diff --git a/library/cpp/streams/lz/lz.cpp b/library/cpp/streams/lz/lz.cpp index 2bfa93a4aa..b65bb3ed96 100644 --- a/library/cpp/streams/lz/lz.cpp +++ b/library/cpp/streams/lz/lz.cpp @@ -32,7 +32,7 @@ const size_t SIGNATURE_SIZE = 4; template <class TCompressor, class TBase> class TCompressorBase: public TAdditionalStorage<TCompressorBase<TCompressor, TBase>>, public TCompressor, public TCommonData { public: - inline TCompressorBase(IOutputStream* slave, ui16 blockSize) + inline TCompressorBase(IOutputStream* slave, ui16 blockSize) : Slave_(slave) , BlockSize_(blockSize) { @@ -76,7 +76,7 @@ public: } template <class T> - static inline void Save(T t, IOutputStream* out) { + static inline void Save(T t, IOutputStream* out) { t = HostToLittle(t); out->Write(&t, sizeof(t)); @@ -97,14 +97,14 @@ private: } inline void WriteBlock(const void* ptr, ui16 len) { - Y_ASSERT(len <= this->BlockSize()); + Y_ASSERT(len <= this->BlockSize()); ui8 compressed = false; if (len) { const size_t out = this->Compress((const char*)ptr, len, (char*)Block(), this->AdditionalDataLength()); // catch compressor buffer overrun (e.g. SEARCH-2043) - //Y_VERIFY(out <= this->Hint(this->BlockSize())); + //Y_VERIFY(out <= this->Hint(this->BlockSize())); if (out < len || TCompressor::SaveIncompressibleChunks()) { compressed = true; @@ -119,7 +119,7 @@ private: this->Save(len, &header); this->Save(compressed, &header); - using TPart = IOutputStream::TPart; + using TPart = IOutputStream::TPart; if (ptr) { const TPart parts[] = { TPart(tmp, sizeof(tmp)), @@ -133,12 +133,12 @@ private: } private: - IOutputStream* Slave_; + IOutputStream* Slave_; const ui16 BlockSize_; }; template <class T> -static inline T GLoad(IInputStream* input) { +static inline T GLoad(IInputStream* input) { T t; if (input->Load(&t, sizeof(t)) != sizeof(t)) { @@ -150,7 +150,7 @@ static inline T GLoad(IInputStream* input) { class TDecompressSignature { public: - inline TDecompressSignature(IInputStream* input) { + inline TDecompressSignature(IInputStream* input) { if (input->Load(Buffer_, SIGNATURE_SIZE) != SIGNATURE_SIZE) { ythrow TDecompressorError() << "can not load stream signature"; } @@ -167,7 +167,7 @@ private: }; template <class TDecompressor> -static inline IInputStream* ConsumeSignature(IInputStream* input) { +static inline IInputStream* ConsumeSignature(IInputStream* input) { TDecompressSignature sign(input); if (!sign.Check<TDecompressor>()) { ythrow TDecompressorError() << "incorrect signature"; @@ -186,7 +186,7 @@ public: return v; } - inline TDecompressorBaseImpl(IInputStream* slave) + inline TDecompressorBaseImpl(IInputStream* slave) : Slave_(slave) , Input_(nullptr, 0) , Eof_(false) @@ -265,7 +265,7 @@ public: } protected: - IInputStream* Slave_; + IInputStream* Slave_; TMemoryInput Input_; bool Eof_; const ui32 Version_; @@ -279,7 +279,7 @@ protected: template <class TDecompressor, class TBase> class TDecompressorBase: public TDecompressorBaseImpl<TDecompressor> { public: - inline TDecompressorBase(IInputStream* slave) + inline TDecompressorBase(IInputStream* slave) : TDecompressorBaseImpl<TDecompressor>(ConsumeSignature<TDecompressor>(slave)) { } @@ -323,12 +323,12 @@ public: #define DEF_COMPRESSOR(rname, name) \ class rname::TImpl: public TCompressorBase<name, TImpl> { \ public: \ - inline TImpl(IOutputStream* out, ui16 blockSize) \ + inline TImpl(IOutputStream* out, ui16 blockSize) \ : TCompressorBase<name, TImpl>(out, blockSize) { \ } \ }; \ \ - rname::rname(IOutputStream* slave, ui16 blockSize) \ + rname::rname(IOutputStream* slave, ui16 blockSize) \ : Impl_(new (TImpl::Hint(blockSize)) TImpl(slave, blockSize)) { \ } \ \ @@ -337,12 +337,12 @@ public: #define DEF_DECOMPRESSOR(rname, name) \ class rname::TImpl: public TDecompressorBase<name, TImpl> { \ public: \ - inline TImpl(IInputStream* in) \ + inline TImpl(IInputStream* in) \ : TDecompressorBase<name, TImpl>(in) { \ } \ }; \ \ - rname::rname(IInputStream* slave) \ + rname::rname(IInputStream* slave) \ : Impl_(new TImpl(slave)) { \ } \ \ @@ -420,7 +420,7 @@ public: return ret; } - inline void InitFromStream(IInputStream*) const noexcept { + inline void InitFromStream(IInputStream*) const noexcept { } }; @@ -446,7 +446,7 @@ public: return fastlz_decompress(data, len, ptr, max); } - inline void InitFromStream(IInputStream*) const noexcept { + inline void InitFromStream(IInputStream*) const noexcept { } static inline bool SaveIncompressibleChunks() noexcept { @@ -481,7 +481,7 @@ public: return res; } - inline void InitFromStream(IInputStream*) const noexcept { + inline void InitFromStream(IInputStream*) const noexcept { } static inline bool SaveIncompressibleChunks() noexcept { @@ -518,7 +518,7 @@ public: return srclen; } - inline void InitFromStream(IInputStream*) const noexcept { + inline void InitFromStream(IInputStream*) const noexcept { } static inline bool SaveIncompressibleChunks() noexcept { @@ -586,7 +586,7 @@ public: return Table_->Decompress(data, ptr, (char*)Mem_.Get()); } - inline void InitFromStream(IInputStream* in) { + inline void InitFromStream(IInputStream* in) { const ui8 ver = ::GLoad<ui8>(in); const ui8 lev = ::GLoad<ui8>(in); const ui8 mod = ::GLoad<ui8>(in); @@ -597,7 +597,7 @@ public: class TLzqCompress::TImpl: public TCompressorBase<TQuickLZCompress, TImpl> { public: - inline TImpl(IOutputStream* out, ui16 blockSize, EVersion ver, unsigned level, EMode mode) + inline TImpl(IOutputStream* out, ui16 blockSize, EVersion ver, unsigned level, EMode mode) : TCompressorBase<TQuickLZCompress, TImpl>(out, blockSize) { memset(AdditionalData(), 0, AdditionalDataLength()); @@ -610,7 +610,7 @@ public: } }; -TLzqCompress::TLzqCompress(IOutputStream* slave, ui16 blockSize, EVersion ver, unsigned level, EMode mode) +TLzqCompress::TLzqCompress(IOutputStream* slave, ui16 blockSize, EVersion ver, unsigned level, EMode mode) : Impl_(new (TImpl::Hint(blockSize)) TImpl(slave, blockSize, ver, level, mode)) { } @@ -639,7 +639,7 @@ namespace { // Decompressing input streams without signature verification template <class TInput, class TDecompressor> - class TLzDecompressInput: public TInputHolder<TInput>, public IInputStream { + class TLzDecompressInput: public TInputHolder<TInput>, public IInputStream { public: inline TLzDecompressInput(TInput in) : Impl_(this->Set(in)) @@ -657,7 +657,7 @@ namespace { } template <class T> -static TAutoPtr<IInputStream> TryOpenLzDecompressorX(const TDecompressSignature& s, T input) { +static TAutoPtr<IInputStream> TryOpenLzDecompressorX(const TDecompressSignature& s, T input) { if (s.Check<TLZ4>()) return new TLzDecompressInput<T, TLZ4>(input); @@ -677,7 +677,7 @@ static TAutoPtr<IInputStream> TryOpenLzDecompressorX(const TDecompressSignature& } template <class T> -static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(const TStringBuf& signature, T input) { +static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(const TStringBuf& signature, T input) { if (signature.size() == SIGNATURE_SIZE) { TMemoryInput mem(signature.data(), signature.size()); TDecompressSignature s(&mem); @@ -689,15 +689,15 @@ static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(const TStringBuf& } template <class T> -static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(T input) { +static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(T input) { TDecompressSignature s(&*input); return TryOpenLzDecompressorX(s, input); } template <class T> -static inline TAutoPtr<IInputStream> OpenLzDecompressorImpl(T input) { - TAutoPtr<IInputStream> ret = TryOpenLzDecompressorImpl(input); +static inline TAutoPtr<IInputStream> OpenLzDecompressorImpl(T input) { + TAutoPtr<IInputStream> ret = TryOpenLzDecompressorImpl(input); if (!ret) { ythrow TDecompressorError() << "Unknown compression format"; @@ -706,26 +706,26 @@ static inline TAutoPtr<IInputStream> OpenLzDecompressorImpl(T input) { return ret; } -TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input) { +TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input) { return OpenLzDecompressorImpl(input); } -TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input) { +TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input) { return TryOpenLzDecompressorImpl(input); } -TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input) { +TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input) { return TryOpenLzDecompressorImpl(signature, input); } -TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) { +TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) { return OpenLzDecompressorImpl(input); } -TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) { +TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) { return TryOpenLzDecompressorImpl(input); } -TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input) { +TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input) { return TryOpenLzDecompressorImpl(signature, input); } diff --git a/library/cpp/streams/lz/lz.h b/library/cpp/streams/lz/lz.h index 2207a46fe5..3a2eaad88b 100644 --- a/library/cpp/streams/lz/lz.h +++ b/library/cpp/streams/lz/lz.h @@ -30,9 +30,9 @@ struct TDecompressorError: public yexception { * * @see http://code.google.com/p/lz4/ */ -class TLz4Compress: public IOutputStream { +class TLz4Compress: public IOutputStream { public: - TLz4Compress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); + TLz4Compress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); ~TLz4Compress() override; private: @@ -50,9 +50,9 @@ private: * * @see http://code.google.com/p/lz4/ */ -class TLz4Decompress: public IInputStream { +class TLz4Decompress: public IInputStream { public: - TLz4Decompress(IInputStream* slave); + TLz4Decompress(IInputStream* slave); ~TLz4Decompress() override; private: @@ -68,9 +68,9 @@ private: * * @see http://code.google.com/p/snappy/ */ -class TSnappyCompress: public IOutputStream { +class TSnappyCompress: public IOutputStream { public: - TSnappyCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); + TSnappyCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); ~TSnappyCompress() override; private: @@ -88,9 +88,9 @@ private: * * @see http://code.google.com/p/snappy/ */ -class TSnappyDecompress: public IInputStream { +class TSnappyDecompress: public IInputStream { public: - TSnappyDecompress(IInputStream* slave); + TSnappyDecompress(IInputStream* slave); ~TSnappyDecompress() override; private: @@ -104,9 +104,9 @@ private: /** * MiniLZO compressing stream. */ -class TLzoCompress: public IOutputStream { +class TLzoCompress: public IOutputStream { public: - TLzoCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); + TLzoCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); ~TLzoCompress() override; private: @@ -122,9 +122,9 @@ private: /** * MiniLZO decompressing stream. */ -class TLzoDecompress: public IInputStream { +class TLzoDecompress: public IInputStream { public: - TLzoDecompress(IInputStream* slave); + TLzoDecompress(IInputStream* slave); ~TLzoDecompress() override; private: @@ -138,9 +138,9 @@ private: /** * FastLZ compressing stream. */ -class TLzfCompress: public IOutputStream { +class TLzfCompress: public IOutputStream { public: - TLzfCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); + TLzfCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); ~TLzfCompress() override; private: @@ -156,9 +156,9 @@ private: /** * FastLZ decompressing stream. */ -class TLzfDecompress: public IInputStream { +class TLzfDecompress: public IInputStream { public: - TLzfDecompress(IInputStream* slave); + TLzfDecompress(IInputStream* slave); ~TLzfDecompress() override; private: @@ -172,7 +172,7 @@ private: /** * QuickLZ compressing stream. */ -class TLzqCompress: public IOutputStream { +class TLzqCompress: public IOutputStream { public: enum EVersion { V_1_31 = 0, @@ -189,7 +189,7 @@ public: M_1000000 = 2 }; - TLzqCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15, + TLzqCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15, EVersion ver = V_1_31, unsigned level = 0, EMode mode = M_0); @@ -208,9 +208,9 @@ private: /** * QuickLZ decompressing stream. */ -class TLzqDecompress: public IInputStream { +class TLzqDecompress: public IInputStream { public: - TLzqDecompress(IInputStream* slave); + TLzqDecompress(IInputStream* slave); ~TLzqDecompress() override; private: @@ -233,10 +233,10 @@ private: * @param input Stream to decompress. * @return Decompressing proxy input stream. */ -TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input); -TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input); -TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input); +TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input); +TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input); +TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input); -TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input); -TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input); -TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input); +TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input); +TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input); +TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input); diff --git a/library/cpp/streams/lz/lz_ut.cpp b/library/cpp/streams/lz/lz_ut.cpp index ffa0065f46..6876f070fc 100644 --- a/library/cpp/streams/lz/lz_ut.cpp +++ b/library/cpp/streams/lz/lz_ut.cpp @@ -31,7 +31,7 @@ namespace { seed += 1; } } while (!sym); - Y_ASSERT(sym); + Y_ASSERT(sym); j = (j + 1) % entropy.size(); result += char(sym + entropy[j]); } @@ -75,7 +75,7 @@ static const TVector<size_t> bufferSizes = { namespace { template <TLzqCompress::EVersion Ver, int Level, TLzqCompress::EMode Mode> struct TLzqCompressX: public TLzqCompress { - inline TLzqCompressX(IOutputStream* out, size_t bufLen) + inline TLzqCompressX(IOutputStream* out, size_t bufLen) : TLzqCompress(out, bufLen, Ver, Level, Mode) { } @@ -160,9 +160,9 @@ static inline void TestDecompress() { } } -class TMixedDecompress: public IInputStream { +class TMixedDecompress: public IInputStream { public: - TMixedDecompress(IInputStream* input) + TMixedDecompress(IInputStream* input) : Slave_(OpenLzDecompressor(input).Release()) { } @@ -173,7 +173,7 @@ private: } private: - THolder<IInputStream> Slave_; + THolder<IInputStream> Slave_; }; template <class C> @@ -188,63 +188,63 @@ static inline void TestDecompressError() { UNIT_ASSERT_EXCEPTION(TestDecompress<D>(), TDecompressorError); } -Y_UNIT_TEST_SUITE(TLzTest) { - Y_UNIT_TEST(TestLzo) { +Y_UNIT_TEST_SUITE(TLzTest) { + Y_UNIT_TEST(TestLzo) { TestCompress<TLzoCompress>(); TestDecompress<TLzoDecompress>(); } - Y_UNIT_TEST(TestLzf) { + Y_UNIT_TEST(TestLzf) { TestCompress<TLzfCompress>(); TestDecompress<TLzfDecompress>(); } - Y_UNIT_TEST(TestLzq) { + Y_UNIT_TEST(TestLzq) { TestCompress<TLzqCompress>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq151_1) { + Y_UNIT_TEST(TestLzq151_1) { TestCompress<TLzqCompressX<TLzqCompress::V_1_51, 1, TLzqCompress::M_0>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq151_2) { + Y_UNIT_TEST(TestLzq151_2) { TestCompress<TLzqCompressX<TLzqCompress::V_1_51, 2, TLzqCompress::M_100000>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq151_3) { + Y_UNIT_TEST(TestLzq151_3) { TestCompress<TLzqCompressX<TLzqCompress::V_1_51, 3, TLzqCompress::M_1000000>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq140_1) { + Y_UNIT_TEST(TestLzq140_1) { TestCompress<TLzqCompressX<TLzqCompress::V_1_40, 1, TLzqCompress::M_0>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq140_2) { + Y_UNIT_TEST(TestLzq140_2) { TestCompress<TLzqCompressX<TLzqCompress::V_1_40, 2, TLzqCompress::M_100000>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLzq140_3) { + Y_UNIT_TEST(TestLzq140_3) { TestCompress<TLzqCompressX<TLzqCompress::V_1_40, 3, TLzqCompress::M_1000000>>(); TestDecompress<TLzqDecompress>(); } - Y_UNIT_TEST(TestLz4) { + Y_UNIT_TEST(TestLz4) { TestCompress<TLz4Compress>(); TestDecompress<TLz4Decompress>(); } - Y_UNIT_TEST(TestSnappy) { + Y_UNIT_TEST(TestSnappy) { TestCompress<TSnappyCompress>(); TestDecompress<TSnappyDecompress>(); } - Y_UNIT_TEST(TestGeneric) { + Y_UNIT_TEST(TestGeneric) { TestMixedDecompress<TLzoCompress>(); TestMixedDecompress<TLzfCompress>(); TestMixedDecompress<TLzqCompress>(); @@ -252,7 +252,7 @@ Y_UNIT_TEST_SUITE(TLzTest) { TestMixedDecompress<TSnappyCompress>(); } - Y_UNIT_TEST(TestDecompressorError) { + Y_UNIT_TEST(TestDecompressorError) { TestDecompressError<TLzoDecompress, TLzfCompress>(); TestDecompressError<TLzfDecompress, TLzqCompress>(); TestDecompressError<TLzqDecompress, TLz4Compress>(); @@ -261,7 +261,7 @@ Y_UNIT_TEST_SUITE(TLzTest) { TestDecompressError<TMixedDecompress, TBufferedOutput>(); } - Y_UNIT_TEST(TestFactory) { + Y_UNIT_TEST(TestFactory) { TStringStream ss; { @@ -271,7 +271,7 @@ Y_UNIT_TEST_SUITE(TLzTest) { c.Finish(); } - TAutoPtr<IInputStream> is(OpenOwnedLzDecompressor(new TStringInput(ss.Str()))); + TAutoPtr<IInputStream> is(OpenOwnedLzDecompressor(new TStringInput(ss.Str()))); UNIT_ASSERT_EQUAL(is->ReadAll(), "123456789"); } diff --git a/library/cpp/streams/lzma/lzma.cpp b/library/cpp/streams/lzma/lzma.cpp index 0a8235d02b..f1942fa546 100644 --- a/library/cpp/streams/lzma/lzma.cpp +++ b/library/cpp/streams/lzma/lzma.cpp @@ -58,7 +58,7 @@ namespace { TInverseFilter* Parent_; }; - class TInput: public IInputStream { + class TInput: public IInputStream { public: inline TInput(TInverseFilter* parent) : Parent_(parent) @@ -76,7 +76,7 @@ namespace { TInverseFilter* Parent_; }; - class TOutput: public IOutputStream { + class TOutput: public IOutputStream { public: inline TOutput(TInverseFilter* parent) : Parent_(parent) @@ -95,7 +95,7 @@ namespace { }; public: - inline TInverseFilter(IOutputStream* slave, T* filter) + inline TInverseFilter(IOutputStream* slave, T* filter) : Slave_(slave) , Filter_(filter) , TrampoLine_(this) @@ -168,7 +168,7 @@ namespace { } inline void WriteImpl(const void* ptr, size_t len) { - Y_ASSERT(!Out_.Avail()); + Y_ASSERT(!Out_.Avail()); Out_.Reset(ptr, len); @@ -205,7 +205,7 @@ namespace { } private: - IOutputStream* Slave_; + IOutputStream* Slave_; T* Filter_; TTrampoLine TrampoLine_; char Stack_[16 * 1024]; @@ -221,7 +221,7 @@ namespace { public: class TLzmaInput: public ISeqInStream { public: - inline TLzmaInput(IInputStream* slave) + inline TLzmaInput(IInputStream* slave) : Slave_(slave) { Read = ReadFunc; @@ -235,12 +235,12 @@ namespace { } private: - IInputStream* Slave_; + IInputStream* Slave_; }; class TLzmaOutput: public ISeqOutStream { public: - inline TLzmaOutput(IOutputStream* slave) + inline TLzmaOutput(IOutputStream* slave) : Slave_(slave) { Write = WriteFunc; @@ -254,7 +254,7 @@ namespace { } private: - IOutputStream* Slave_; + IOutputStream* Slave_; }; class TAlloc: public ISzAlloc { @@ -321,7 +321,7 @@ namespace { LzmaEnc_Destroy(H_, Alloc(), Alloc()); } - inline void operator()(IInputStream* in, IOutputStream* out) { + inline void operator()(IInputStream* in, IOutputStream* out) { TLzmaInput input(in); TLzmaOutput output(out); @@ -339,7 +339,7 @@ namespace { class TLzmaCompress::TImpl: public TLzmaCompressBase, public TInverseFilter<TLzmaCompressBase> { public: - inline TImpl(IOutputStream* slave, size_t level) + inline TImpl(IOutputStream* slave, size_t level) : TLzmaCompressBase(level) , TInverseFilter<TLzmaCompressBase>(slave, this) { @@ -373,7 +373,7 @@ public: pos += bufLen; if (status == LZMA_STATUS_NEEDS_MORE_INPUT) { - Y_ASSERT(InEnd_ == InBegin_); + Y_ASSERT(InEnd_ == InBegin_); if (!Fill()) { ythrow yexception() << "incomplete lzma stream"; } @@ -395,7 +395,7 @@ protected: class TLzmaDecompress::TImplStream: public TImpl { public: - inline TImplStream(IInputStream* slave) + inline TImplStream(IInputStream* slave) : Slave_(slave) { Byte buf[LZMA_PROPS_SIZE]; @@ -417,13 +417,13 @@ private: } private: - IInputStream* Slave_; + IInputStream* Slave_; char In_[4096]; }; class TLzmaDecompress::TImplZeroCopy: public TLzmaDecompress::TImpl { public: - inline TImplZeroCopy(IZeroCopyInput* in) + inline TImplZeroCopy(IZeroCopyInput* in) : Input_(in) { if (!Fill()) @@ -475,10 +475,10 @@ private: return false; } - IZeroCopyInput* Input_; + IZeroCopyInput* Input_; }; -TLzmaCompress::TLzmaCompress(IOutputStream* slave, size_t level) +TLzmaCompress::TLzmaCompress(IOutputStream* slave, size_t level) : Impl_(new TImpl(slave, level)) { } @@ -502,12 +502,12 @@ void TLzmaCompress::DoFinish() { } } -TLzmaDecompress::TLzmaDecompress(IInputStream* slave) +TLzmaDecompress::TLzmaDecompress(IInputStream* slave) : Impl_(new TImplStream(slave)) { } -TLzmaDecompress::TLzmaDecompress(IZeroCopyInput* input) +TLzmaDecompress::TLzmaDecompress(IZeroCopyInput* input) : Impl_(new TImplZeroCopy(input)) { } diff --git a/library/cpp/streams/lzma/lzma.h b/library/cpp/streams/lzma/lzma.h index 9a86213655..ca1e06e9ef 100644 --- a/library/cpp/streams/lzma/lzma.h +++ b/library/cpp/streams/lzma/lzma.h @@ -6,9 +6,9 @@ #include <util/generic/ptr.h> -class TLzmaCompress: public IOutputStream { +class TLzmaCompress: public IOutputStream { public: - TLzmaCompress(IOutputStream* slave, size_t level = 7); + TLzmaCompress(IOutputStream* slave, size_t level = 7); ~TLzmaCompress() override; private: @@ -20,10 +20,10 @@ private: THolder<TImpl> Impl_; }; -class TLzmaDecompress: public IInputStream { +class TLzmaDecompress: public IInputStream { public: - TLzmaDecompress(IInputStream* slave); - TLzmaDecompress(IZeroCopyInput* input); + TLzmaDecompress(IInputStream* slave); + TLzmaDecompress(IZeroCopyInput* input); ~TLzmaDecompress() override; private: diff --git a/library/cpp/streams/lzma/lzma_ut.cpp b/library/cpp/streams/lzma/lzma_ut.cpp index e71e1bde49..847e98d1ca 100644 --- a/library/cpp/streams/lzma/lzma_ut.cpp +++ b/library/cpp/streams/lzma/lzma_ut.cpp @@ -6,7 +6,7 @@ #include <util/random/fast.h> #include <util/random/random.h> -class TStrokaByOneByte: public IZeroCopyInput { +class TStrokaByOneByte: public IZeroCopyInput { public: TStrokaByOneByte(const TString& s) : Data(s) @@ -52,7 +52,7 @@ private: } inline void Test2() { - class TExcOutput: public IOutputStream { + class TExcOutput: public IOutputStream { public: ~TExcOutput() override { } @@ -93,7 +93,7 @@ private: { TMemoryInput mi(res.data(), res.size()); TStringOutput so(data1); - TLzmaDecompress d((IInputStream*)&mi); + TLzmaDecompress d((IInputStream*)&mi); TransferData(&d, &so); } diff --git a/library/cpp/string_utils/base64/base64.cpp b/library/cpp/string_utils/base64/base64.cpp index 9e90ed7bb1..05c201f0de 100644 --- a/library/cpp/string_utils/base64/base64.cpp +++ b/library/cpp/string_utils/base64/base64.cpp @@ -1,36 +1,36 @@ #include "base64.h" -#include <contrib/libs/base64/avx2/libbase64.h> -#include <contrib/libs/base64/ssse3/libbase64.h> -#include <contrib/libs/base64/neon32/libbase64.h> -#include <contrib/libs/base64/neon64/libbase64.h> -#include <contrib/libs/base64/plain32/libbase64.h> -#include <contrib/libs/base64/plain64/libbase64.h> - +#include <contrib/libs/base64/avx2/libbase64.h> +#include <contrib/libs/base64/ssse3/libbase64.h> +#include <contrib/libs/base64/neon32/libbase64.h> +#include <contrib/libs/base64/neon64/libbase64.h> +#include <contrib/libs/base64/plain32/libbase64.h> +#include <contrib/libs/base64/plain64/libbase64.h> + #include <util/generic/yexception.h> -#include <util/system/cpu_id.h> -#include <util/system/platform.h> - -#include <cstdlib> - -namespace { - struct TImpl { - void (*Encode)(const char* src, size_t srclen, char* out, size_t* outlen); - int (*Decode)(const char* src, size_t srclen, char* out, size_t* outlen); - - TImpl() { -#if defined(_arm32_) - const bool haveNEON32 = true; -#else - const bool haveNEON32 = false; -#endif - -#if defined(_arm64_) - const bool haveNEON64 = true; -#else - const bool haveNEON64 = false; -#endif - +#include <util/system/cpu_id.h> +#include <util/system/platform.h> + +#include <cstdlib> + +namespace { + struct TImpl { + void (*Encode)(const char* src, size_t srclen, char* out, size_t* outlen); + int (*Decode)(const char* src, size_t srclen, char* out, size_t* outlen); + + TImpl() { +#if defined(_arm32_) + const bool haveNEON32 = true; +#else + const bool haveNEON32 = false; +#endif + +#if defined(_arm64_) + const bool haveNEON64 = true; +#else + const bool haveNEON64 = false; +#endif + # ifdef _windows_ // msvc does something wrong in release-build, so we temprorary disable this branch on windows // https://developercommunity.visualstudio.com/content/problem/334085/release-build-has-made-wrong-optimizaion-in-base64.html @@ -39,59 +39,59 @@ namespace { const bool isWin = false; # endif if (!isWin && NX86::HaveAVX() && NX86::HaveAVX2()) { - Encode = avx2_base64_encode; - Decode = avx2_base64_decode; - } else if (NX86::HaveSSSE3()) { - Encode = ssse3_base64_encode; - Decode = ssse3_base64_decode; - } else if (haveNEON64) { - Encode = neon64_base64_encode; - Decode = neon64_base64_decode; - } else if (haveNEON32) { - Encode = neon32_base64_encode; - Decode = neon32_base64_decode; - } else if (sizeof(void*) == 8) { - // running on a 64 bit platform - Encode = plain64_base64_encode; - Decode = plain64_base64_decode; - } else if (sizeof(void*) == 4) { - // running on a 32 bit platform (actually impossible in Arcadia) - Encode = plain32_base64_encode; - Decode = plain32_base64_decode; - } else { - // failed to find appropriate implementation - std::abort(); - } - } - }; - + Encode = avx2_base64_encode; + Decode = avx2_base64_decode; + } else if (NX86::HaveSSSE3()) { + Encode = ssse3_base64_encode; + Decode = ssse3_base64_decode; + } else if (haveNEON64) { + Encode = neon64_base64_encode; + Decode = neon64_base64_decode; + } else if (haveNEON32) { + Encode = neon32_base64_encode; + Decode = neon32_base64_decode; + } else if (sizeof(void*) == 8) { + // running on a 64 bit platform + Encode = plain64_base64_encode; + Decode = plain64_base64_decode; + } else if (sizeof(void*) == 4) { + // running on a 32 bit platform (actually impossible in Arcadia) + Encode = plain32_base64_encode; + Decode = plain32_base64_decode; + } else { + // failed to find appropriate implementation + std::abort(); + } + } + }; + const TImpl GetImpl() { - static const TImpl IMPL; - return IMPL; - } -} - + static const TImpl IMPL; + return IMPL; + } +} + static const char base64_etab_std[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char base64_bkw[] = { - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 0..15 - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 16..31 - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\76', '\0', '\76', '\0', '\77', // 32.47 - '\64', '\65', '\66', '\67', '\70', '\71', '\72', '\73', '\74', '\75', '\0', '\0', '\0', '\0', '\0', '\0', // 48..63 - '\0', '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7', '\10', '\11', '\12', '\13', '\14', '\15', '\16', // 64..79 - '\17', '\20', '\21', '\22', '\23', '\24', '\25', '\26', '\27', '\30', '\31', '\0', '\0', '\0', '\0', '\77', // 80..95 - '\0', '\32', '\33', '\34', '\35', '\36', '\37', '\40', '\41', '\42', '\43', '\44', '\45', '\46', '\47', '\50', // 96..111 - '\51', '\52', '\53', '\54', '\55', '\56', '\57', '\60', '\61', '\62', '\63', '\0', '\0', '\0', '\0', '\0', // 112..127 - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 128..143 - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}; - -static_assert(Y_ARRAY_SIZE(base64_bkw) == 256, "wrong size"); - +static const char base64_bkw[] = { + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 0..15 + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 16..31 + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\76', '\0', '\76', '\0', '\77', // 32.47 + '\64', '\65', '\66', '\67', '\70', '\71', '\72', '\73', '\74', '\75', '\0', '\0', '\0', '\0', '\0', '\0', // 48..63 + '\0', '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7', '\10', '\11', '\12', '\13', '\14', '\15', '\16', // 64..79 + '\17', '\20', '\21', '\22', '\23', '\24', '\25', '\26', '\27', '\30', '\31', '\0', '\0', '\0', '\0', '\77', // 80..95 + '\0', '\32', '\33', '\34', '\35', '\36', '\37', '\40', '\41', '\42', '\43', '\44', '\45', '\46', '\47', '\50', // 96..111 + '\51', '\52', '\53', '\54', '\55', '\56', '\57', '\60', '\61', '\62', '\63', '\0', '\0', '\0', '\0', '\0', // 112..127 + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', // 128..143 + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}; + +static_assert(Y_ARRAY_SIZE(base64_bkw) == 256, "wrong size"); + // Base64 for url encoding, RFC3548 static const char base64_etab_url[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; @@ -141,7 +141,7 @@ static inline char* Base64EncodeImpl(char* outstr, const unsigned char* instr, s return outstr; } -static char* Base64EncodePlain(char* outstr, const unsigned char* instr, size_t len) { +static char* Base64EncodePlain(char* outstr, const unsigned char* instr, size_t len) { return Base64EncodeImpl<false>(outstr, instr, len); } @@ -155,7 +155,7 @@ inline void uudecode_1(char* dst, unsigned char* src) { dst[2] = char((base64_bkw[src[2]] << 6) | base64_bkw[src[3]]); } -static size_t Base64DecodePlain(void* dst, const char* b, const char* e) { +static size_t Base64DecodePlain(void* dst, const char* b, const char* e) { size_t n = 0; while (b < e) { uudecode_1((char*)dst + n, (unsigned char*)b); @@ -193,7 +193,7 @@ size_t Base64StrictDecode(void* out, const char* b, const char* e) { const unsigned char* src = (unsigned char*)b; const unsigned char* const end = (unsigned char*)e; - Y_ENSURE(!((e - b) % 4), "incorrect input length for base64 decode"); + Y_ENSURE(!((e - b) % 4), "incorrect input length for base64 decode"); while (src < end) { const char zeroth = base64_bkw_strict[src[0]]; @@ -203,10 +203,10 @@ size_t Base64StrictDecode(void* out, const char* b, const char* e) { constexpr char invalid = 64; constexpr char padding = 65; - if (Y_UNLIKELY(zeroth == invalid || first == invalid || - second == invalid || third == invalid || - zeroth == padding || first == padding)) - { + if (Y_UNLIKELY(zeroth == invalid || first == invalid || + second == invalid || third == invalid || + zeroth == padding || first == padding)) + { ythrow yexception() << "invalid character in input"; } @@ -223,28 +223,28 @@ size_t Base64StrictDecode(void* out, const char* b, const char* e) { if (src[-2] == ',' || src[-2] == '=') { --dst; } - } else if (Y_UNLIKELY(src[-2] == ',' || src[-2] == '=')) { + } else if (Y_UNLIKELY(src[-2] == ',' || src[-2] == '=')) { ythrow yexception() << "incorrect padding"; } } return dst - (char*)out; } - -size_t Base64Decode(void* dst, const char* b, const char* e) { - static const TImpl IMPL = GetImpl(); - const auto size = e - b; - Y_ENSURE(!(size % 4), "incorrect input length for base64 decode"); - if (Y_LIKELY(size < 8)) { - return Base64DecodePlain(dst, b, e); - } - - size_t outLen; - IMPL.Decode(b, size, (char*)dst, &outLen); - - return outLen; -} - + +size_t Base64Decode(void* dst, const char* b, const char* e) { + static const TImpl IMPL = GetImpl(); + const auto size = e - b; + Y_ENSURE(!(size % 4), "incorrect input length for base64 decode"); + if (Y_LIKELY(size < 8)) { + return Base64DecodePlain(dst, b, e); + } + + size_t outLen; + IMPL.Decode(b, size, (char*)dst, &outLen); + + return outLen; +} + TString Base64DecodeUneven(const TStringBuf s) { if (s.length() % 4 == 0) { return Base64Decode(s); @@ -254,15 +254,15 @@ TString Base64DecodeUneven(const TStringBuf s) { return Base64Decode(TString(s) + TString(4 - (s.length() % 4), '=')); } -char* Base64Encode(char* outstr, const unsigned char* instr, size_t len) { - static const TImpl IMPL = GetImpl(); - if (Y_LIKELY(len < 8)) { - return Base64EncodePlain(outstr, instr, len); - } - - size_t outLen; - IMPL.Encode((char*)instr, len, outstr, &outLen); - - *(outstr + outLen) = '\0'; - return outstr + outLen; -} +char* Base64Encode(char* outstr, const unsigned char* instr, size_t len) { + static const TImpl IMPL = GetImpl(); + if (Y_LIKELY(len < 8)) { + return Base64EncodePlain(outstr, instr, len); + } + + size_t outLen; + IMPL.Encode((char*)instr, len, outstr, &outLen); + + *(outstr + outLen) = '\0'; + return outstr + outLen; +} diff --git a/library/cpp/string_utils/base64/base64.h b/library/cpp/string_utils/base64/base64.h index 57a121537d..f778a6425a 100644 --- a/library/cpp/string_utils/base64/base64.h +++ b/library/cpp/string_utils/base64/base64.h @@ -4,26 +4,26 @@ #include <util/generic/strbuf.h> #include <util/generic/string.h> -/* @return Size of the buffer required to decode Base64 encoded data of size `len`. - */ -constexpr size_t Base64DecodeBufSize(const size_t len) noexcept { - return (len + 3) / 4 * 3; +/* @return Size of the buffer required to decode Base64 encoded data of size `len`. + */ +constexpr size_t Base64DecodeBufSize(const size_t len) noexcept { + return (len + 3) / 4 * 3; } -/* Decode Base64 encoded data. Can decode both regular Base64 and Base64URL encoded data. Can decode - * only valid Base64[URL] data, behaviour for invalid data is unspecified. - * - * @throws Throws exception in case of incorrect padding. - * - * @param dst memory for writing output. - * @param b pointer to the beginning of base64 encoded string. - * @param a pointer to the end of base64 encoded string - * - * @return Return number of bytes decoded. - */ +/* Decode Base64 encoded data. Can decode both regular Base64 and Base64URL encoded data. Can decode + * only valid Base64[URL] data, behaviour for invalid data is unspecified. + * + * @throws Throws exception in case of incorrect padding. + * + * @param dst memory for writing output. + * @param b pointer to the beginning of base64 encoded string. + * @param a pointer to the end of base64 encoded string + * + * @return Return number of bytes decoded. + */ size_t Base64Decode(void* dst, const char* b, const char* e); -inline TStringBuf Base64Decode(const TStringBuf src, void* dst) { +inline TStringBuf Base64Decode(const TStringBuf src, void* dst) { return TStringBuf((const char*)dst, Base64Decode(dst, src.begin(), src.end())); } @@ -63,7 +63,7 @@ size_t Base64StrictDecode(void* dst, const char* b, const char* e); /// /// @return Returns dst wrapped into TStringBuf. /// -inline TStringBuf Base64StrictDecode(const TStringBuf src, void* dst) { +inline TStringBuf Base64StrictDecode(const TStringBuf src, void* dst) { return TStringBuf((const char*)dst, Base64StrictDecode(dst, src.begin(), src.end())); } @@ -92,18 +92,18 @@ inline TString Base64StrictDecode(const TStringBuf src) { TString Base64DecodeUneven(const TStringBuf s); //encode -constexpr size_t Base64EncodeBufSize(const size_t len) noexcept { - return (len + 2) / 3 * 4 + 1; +constexpr size_t Base64EncodeBufSize(const size_t len) noexcept { + return (len + 2) / 3 * 4 + 1; } char* Base64Encode(char* outstr, const unsigned char* instr, size_t len); char* Base64EncodeUrl(char* outstr, const unsigned char* instr, size_t len); -inline TStringBuf Base64Encode(const TStringBuf src, void* tmp) { +inline TStringBuf Base64Encode(const TStringBuf src, void* tmp) { return TStringBuf((const char*)tmp, Base64Encode((char*)tmp, (const unsigned char*)src.data(), src.size())); } -inline TStringBuf Base64EncodeUrl(const TStringBuf src, void* tmp) { +inline TStringBuf Base64EncodeUrl(const TStringBuf src, void* tmp) { return TStringBuf((const char*)tmp, Base64EncodeUrl((char*)tmp, (const unsigned char*)src.data(), src.size())); } diff --git a/library/cpp/string_utils/base64/base64_ut.cpp b/library/cpp/string_utils/base64/base64_ut.cpp index 2873706301..bcc1e65879 100644 --- a/library/cpp/string_utils/base64/base64_ut.cpp +++ b/library/cpp/string_utils/base64/base64_ut.cpp @@ -1,168 +1,168 @@ #include "base64.h" -#include <contrib/libs/base64/avx2/libbase64.h> -#include <contrib/libs/base64/neon32/libbase64.h> -#include <contrib/libs/base64/neon64/libbase64.h> -#include <contrib/libs/base64/plain32/libbase64.h> -#include <contrib/libs/base64/plain64/libbase64.h> -#include <contrib/libs/base64/ssse3/libbase64.h> - +#include <contrib/libs/base64/avx2/libbase64.h> +#include <contrib/libs/base64/neon32/libbase64.h> +#include <contrib/libs/base64/neon64/libbase64.h> +#include <contrib/libs/base64/plain32/libbase64.h> +#include <contrib/libs/base64/plain64/libbase64.h> +#include <contrib/libs/base64/ssse3/libbase64.h> + #include <library/cpp/testing/unittest/registar.h> -#include <util/generic/vector.h> -#include <util/random/fast.h> -#include <util/system/cpu_id.h> -#include <util/system/platform.h> - -#include <array> - +#include <util/generic/vector.h> +#include <util/random/fast.h> +#include <util/system/cpu_id.h> +#include <util/system/platform.h> + +#include <array> + using namespace std::string_view_literals; -#define BASE64_UT_DECLARE_BASE64_IMPL(prefix, encFunction, decFunction) \ - Y_DECLARE_UNUSED \ - static size_t prefix##Base64Decode(void* dst, const char* b, const char* e) { \ - const auto size = e - b; \ - Y_ENSURE(!(size % 4), "incorrect input length for base64 decode"); \ - \ - size_t outLen; \ - decFunction(b, size, (char*)dst, &outLen); \ - return outLen; \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline TStringBuf prefix##Base64Decode(const TStringBuf& src, void* dst) { \ - return TStringBuf((const char*)dst, ::NB64Etalon::prefix##Base64Decode(dst, src.begin(), src.end())); \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline void prefix##Base64Decode(const TStringBuf& src, TString& dst) { \ - dst.ReserveAndResize(Base64DecodeBufSize(src.size())); \ - dst.resize(::NB64Etalon::prefix##Base64Decode(src, dst.begin()).size()); \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline TString prefix##Base64Decode(const TStringBuf& s) { \ - TString ret; \ - prefix##Base64Decode(s, ret); \ - return ret; \ - } \ - \ - Y_DECLARE_UNUSED \ - static char* prefix##Base64Encode(char* outstr, const unsigned char* instr, size_t len) { \ - size_t outLen; \ - encFunction((char*)instr, len, outstr, &outLen); \ - *(outstr + outLen) = '\0'; \ - return outstr + outLen; \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline TStringBuf prefix##Base64Encode(const TStringBuf& src, void* tmp) { \ +#define BASE64_UT_DECLARE_BASE64_IMPL(prefix, encFunction, decFunction) \ + Y_DECLARE_UNUSED \ + static size_t prefix##Base64Decode(void* dst, const char* b, const char* e) { \ + const auto size = e - b; \ + Y_ENSURE(!(size % 4), "incorrect input length for base64 decode"); \ + \ + size_t outLen; \ + decFunction(b, size, (char*)dst, &outLen); \ + return outLen; \ + } \ + \ + Y_DECLARE_UNUSED \ + static inline TStringBuf prefix##Base64Decode(const TStringBuf& src, void* dst) { \ + return TStringBuf((const char*)dst, ::NB64Etalon::prefix##Base64Decode(dst, src.begin(), src.end())); \ + } \ + \ + Y_DECLARE_UNUSED \ + static inline void prefix##Base64Decode(const TStringBuf& src, TString& dst) { \ + dst.ReserveAndResize(Base64DecodeBufSize(src.size())); \ + dst.resize(::NB64Etalon::prefix##Base64Decode(src, dst.begin()).size()); \ + } \ + \ + Y_DECLARE_UNUSED \ + static inline TString prefix##Base64Decode(const TStringBuf& s) { \ + TString ret; \ + prefix##Base64Decode(s, ret); \ + return ret; \ + } \ + \ + Y_DECLARE_UNUSED \ + static char* prefix##Base64Encode(char* outstr, const unsigned char* instr, size_t len) { \ + size_t outLen; \ + encFunction((char*)instr, len, outstr, &outLen); \ + *(outstr + outLen) = '\0'; \ + return outstr + outLen; \ + } \ + \ + Y_DECLARE_UNUSED \ + static inline TStringBuf prefix##Base64Encode(const TStringBuf& src, void* tmp) { \ return TStringBuf((const char*)tmp, ::NB64Etalon::prefix##Base64Encode((char*)tmp, (const unsigned char*)src.data(), src.size())); \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline void prefix##Base64Encode(const TStringBuf& src, TString& dst) { \ - dst.ReserveAndResize(Base64EncodeBufSize(src.size())); \ - dst.resize(::NB64Etalon::prefix##Base64Encode(src, dst.begin()).size()); \ - } \ - \ - Y_DECLARE_UNUSED \ - static inline TString prefix##Base64Encode(const TStringBuf& s) { \ - TString ret; \ - prefix##Base64Encode(s, ret); \ - return ret; \ - } - -namespace NB64Etalon { - BASE64_UT_DECLARE_BASE64_IMPL(PLAIN32, plain32_base64_encode, plain32_base64_decode); - BASE64_UT_DECLARE_BASE64_IMPL(PLAIN64, plain64_base64_encode, plain64_base64_decode); - BASE64_UT_DECLARE_BASE64_IMPL(NEON32, neon32_base64_encode, neon32_base64_decode); - BASE64_UT_DECLARE_BASE64_IMPL(NEON64, neon64_base64_encode, neon64_base64_decode); - BASE64_UT_DECLARE_BASE64_IMPL(AVX2, avx2_base64_encode, avx2_base64_decode); - BASE64_UT_DECLARE_BASE64_IMPL(SSSE3, ssse3_base64_encode, ssse3_base64_decode); - -#undef BASE64_UT_DECLARE_BASE64_IMPL - - struct TImpls { - enum EImpl : size_t { - PLAIN32_IMPL, - PLAIN64_IMPL, - NEON32_IMPL, - NEON64_IMPL, - AVX2_IMPL, - SSSE3_IMPL, - MAX_IMPL - }; - + } \ + \ + Y_DECLARE_UNUSED \ + static inline void prefix##Base64Encode(const TStringBuf& src, TString& dst) { \ + dst.ReserveAndResize(Base64EncodeBufSize(src.size())); \ + dst.resize(::NB64Etalon::prefix##Base64Encode(src, dst.begin()).size()); \ + } \ + \ + Y_DECLARE_UNUSED \ + static inline TString prefix##Base64Encode(const TStringBuf& s) { \ + TString ret; \ + prefix##Base64Encode(s, ret); \ + return ret; \ + } + +namespace NB64Etalon { + BASE64_UT_DECLARE_BASE64_IMPL(PLAIN32, plain32_base64_encode, plain32_base64_decode); + BASE64_UT_DECLARE_BASE64_IMPL(PLAIN64, plain64_base64_encode, plain64_base64_decode); + BASE64_UT_DECLARE_BASE64_IMPL(NEON32, neon32_base64_encode, neon32_base64_decode); + BASE64_UT_DECLARE_BASE64_IMPL(NEON64, neon64_base64_encode, neon64_base64_decode); + BASE64_UT_DECLARE_BASE64_IMPL(AVX2, avx2_base64_encode, avx2_base64_decode); + BASE64_UT_DECLARE_BASE64_IMPL(SSSE3, ssse3_base64_encode, ssse3_base64_decode); + +#undef BASE64_UT_DECLARE_BASE64_IMPL + + struct TImpls { + enum EImpl : size_t { + PLAIN32_IMPL, + PLAIN64_IMPL, + NEON32_IMPL, + NEON64_IMPL, + AVX2_IMPL, + SSSE3_IMPL, + MAX_IMPL + }; + using TEncodeF = void (*)(const TStringBuf&, TString&); using TDecodeF = void (*)(const TStringBuf&, TString&); - - struct TImpl { - TEncodeF Encode = nullptr; - TDecodeF Decode = nullptr; - }; - - std::array<TImpl, MAX_IMPL> Impl; - - TImpls() { - Impl[PLAIN32_IMPL].Encode = PLAIN32Base64Encode; - Impl[PLAIN32_IMPL].Decode = PLAIN32Base64Decode; - Impl[PLAIN64_IMPL].Encode = PLAIN64Base64Encode; - Impl[PLAIN64_IMPL].Decode = PLAIN64Base64Decode; -#if defined(_arm32_) - Impl[NEON32_IMPL].Encode = NEON32Base64Encode; - Impl[NEON32_IMPL].Decode = NEON32Base64Decode; -#elif defined(_arm64_) - Impl[NEON64_IMPL].Encode = NEON64Base64Encode; - Impl[NEON64_IMPL].Decode = NEON64Base64Decode; -#elif defined(_x86_64_) - if (NX86::HaveSSSE3()) { - Impl[SSSE3_IMPL].Encode = SSSE3Base64Encode; - Impl[SSSE3_IMPL].Decode = SSSE3Base64Decode; - } - - if (NX86::HaveAVX2()) { - Impl[AVX2_IMPL].Encode = AVX2Base64Encode; - Impl[AVX2_IMPL].Decode = AVX2Base64Decode; - } -#else - ythrow yexception() << "Failed to identify the platform"; -#endif - } - }; - - TImpls GetImpls() { - static const TImpls IMPLS; - return IMPLS; - } -} - -template <> -void Out<NB64Etalon::TImpls::EImpl>(IOutputStream& o, typename TTypeTraits<NB64Etalon::TImpls::EImpl>::TFuncParam v) { - switch (v) { - case NB64Etalon::TImpls::PLAIN32_IMPL: - o << TStringBuf{"PLAIN32"}; - return; - case NB64Etalon::TImpls::PLAIN64_IMPL: - o << TStringBuf{"PLAIN64"}; - return; - case NB64Etalon::TImpls::NEON64_IMPL: - o << TStringBuf{"NEON64"}; - return; - case NB64Etalon::TImpls::NEON32_IMPL: - o << TStringBuf{"NEON32"}; - return; - case NB64Etalon::TImpls::SSSE3_IMPL: - o << TStringBuf{"SSSE3"}; - return; - case NB64Etalon::TImpls::AVX2_IMPL: - o << TStringBuf{"AVX2"}; - return; - default: - ythrow yexception() << "invalid"; - } -} - + + struct TImpl { + TEncodeF Encode = nullptr; + TDecodeF Decode = nullptr; + }; + + std::array<TImpl, MAX_IMPL> Impl; + + TImpls() { + Impl[PLAIN32_IMPL].Encode = PLAIN32Base64Encode; + Impl[PLAIN32_IMPL].Decode = PLAIN32Base64Decode; + Impl[PLAIN64_IMPL].Encode = PLAIN64Base64Encode; + Impl[PLAIN64_IMPL].Decode = PLAIN64Base64Decode; +#if defined(_arm32_) + Impl[NEON32_IMPL].Encode = NEON32Base64Encode; + Impl[NEON32_IMPL].Decode = NEON32Base64Decode; +#elif defined(_arm64_) + Impl[NEON64_IMPL].Encode = NEON64Base64Encode; + Impl[NEON64_IMPL].Decode = NEON64Base64Decode; +#elif defined(_x86_64_) + if (NX86::HaveSSSE3()) { + Impl[SSSE3_IMPL].Encode = SSSE3Base64Encode; + Impl[SSSE3_IMPL].Decode = SSSE3Base64Decode; + } + + if (NX86::HaveAVX2()) { + Impl[AVX2_IMPL].Encode = AVX2Base64Encode; + Impl[AVX2_IMPL].Decode = AVX2Base64Decode; + } +#else + ythrow yexception() << "Failed to identify the platform"; +#endif + } + }; + + TImpls GetImpls() { + static const TImpls IMPLS; + return IMPLS; + } +} + +template <> +void Out<NB64Etalon::TImpls::EImpl>(IOutputStream& o, typename TTypeTraits<NB64Etalon::TImpls::EImpl>::TFuncParam v) { + switch (v) { + case NB64Etalon::TImpls::PLAIN32_IMPL: + o << TStringBuf{"PLAIN32"}; + return; + case NB64Etalon::TImpls::PLAIN64_IMPL: + o << TStringBuf{"PLAIN64"}; + return; + case NB64Etalon::TImpls::NEON64_IMPL: + o << TStringBuf{"NEON64"}; + return; + case NB64Etalon::TImpls::NEON32_IMPL: + o << TStringBuf{"NEON32"}; + return; + case NB64Etalon::TImpls::SSSE3_IMPL: + o << TStringBuf{"SSSE3"}; + return; + case NB64Etalon::TImpls::AVX2_IMPL: + o << TStringBuf{"AVX2"}; + return; + default: + ythrow yexception() << "invalid"; + } +} + static void TestEncodeDecodeIntoString(const TString& plain, const TString& encoded, const TString& encodedUrl) { TString a, b; @@ -195,15 +195,15 @@ static void TestEncodeStrictDecodeIntoString(const TString& plain, const TString UNIT_ASSERT_VALUES_EQUAL(b, plain); } -Y_UNIT_TEST_SUITE(TBase64) { - Y_UNIT_TEST(TestEncode) { +Y_UNIT_TEST_SUITE(TBase64) { + Y_UNIT_TEST(TestEncode) { UNIT_ASSERT_VALUES_EQUAL(Base64Encode("12z"), "MTJ6"); UNIT_ASSERT_VALUES_EQUAL(Base64Encode("123"), "MTIz"); UNIT_ASSERT_VALUES_EQUAL(Base64Encode("12"), "MTI="); UNIT_ASSERT_VALUES_EQUAL(Base64Encode("1"), "MQ=="); } - Y_UNIT_TEST(TestIntoString) { + Y_UNIT_TEST(TestIntoString) { { TString str; for (size_t i = 0; i < 256; ++i) @@ -241,7 +241,7 @@ Y_UNIT_TEST_SUITE(TBase64) { } } - Y_UNIT_TEST(TestDecode) { + Y_UNIT_TEST(TestDecode) { UNIT_ASSERT_EXCEPTION(Base64Decode("a"), yexception); UNIT_ASSERT_EXCEPTION(Base64StrictDecode("a"), yexception); @@ -285,7 +285,7 @@ Y_UNIT_TEST_SUITE(TBase64) { UNIT_ASSERT_VALUES_EQUAL(Base64DecodeUneven("dnluZHg"), "vyndx"); } - Y_UNIT_TEST(TestDecodeRandom) { + Y_UNIT_TEST(TestDecodeRandom) { TString input; constexpr size_t testSize = 240000; for (size_t i = 0; i < testSize; ++i) { @@ -296,202 +296,202 @@ Y_UNIT_TEST_SUITE(TBase64) { UNIT_ASSERT_VALUES_EQUAL(Base64Decode(encoded), input); UNIT_ASSERT_VALUES_EQUAL(Base64StrictDecode(encoded), input); } - - Y_UNIT_TEST(TestAllPossibleOctets) { + + Y_UNIT_TEST(TestAllPossibleOctets) { const TString x("\0\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0B\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7F"sv); const TString xEnc = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn8="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestTwoPaddingCharacters) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestTwoPaddingCharacters) { const TString x("a"); const TString xEnc = "YQ=="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestOnePaddingCharacter) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestOnePaddingCharacter) { const TString x("aa"); const TString xEnc = "YWE="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestNoPaddingCharacters) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestNoPaddingCharacters) { const TString x("aaa"); const TString xEnc = "YWFh"; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestTrailingZero) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestTrailingZero) { const TString x("foo\0"sv); const TString xEnc = "Zm9vAA=="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestTwoTrailingZeroes) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestTwoTrailingZeroes) { const TString x("foo\0\0"sv); const TString xEnc = "Zm9vAAA="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestZero) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestZero) { const TString x("\0"sv); const TString xEnc = "AA=="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestSymbolsAfterZero) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestSymbolsAfterZero) { const TString x("\0a"sv); const TString xEnc = "AGE="; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestEmptyString) { + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestEmptyString) { const TString x = ""; const TString xEnc = ""; const TString y = Base64Decode(xEnc); const TString yEnc = Base64Encode(x); - UNIT_ASSERT_VALUES_EQUAL(x, y); - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - } - - Y_UNIT_TEST(TestBackendsConsistencyOnRandomData) { - constexpr size_t TEST_CASES_COUNT = 1000; - constexpr size_t MAX_DATA_SIZE = 1000; - TFastRng<ui32> prng{42}; + UNIT_ASSERT_VALUES_EQUAL(x, y); + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + } + + Y_UNIT_TEST(TestBackendsConsistencyOnRandomData) { + constexpr size_t TEST_CASES_COUNT = 1000; + constexpr size_t MAX_DATA_SIZE = 1000; + TFastRng<ui32> prng{42}; TVector<TString> xs{TEST_CASES_COUNT}; TString xEnc; TString xDec; TString yEnc; TString yDec; - - for (auto& x : xs) { - const size_t size = prng() % MAX_DATA_SIZE; - for (size_t j = 0; j < size; ++j) { - x += static_cast<char>(prng() % 256); - } - } - - static const auto IMPLS = NB64Etalon::GetImpls(); - for (size_t i = 0; i < static_cast<size_t>(NB64Etalon::TImpls::MAX_IMPL); ++i) { - for (size_t j = 0; j < static_cast<size_t>(NB64Etalon::TImpls::MAX_IMPL); ++j) { - const auto ei = static_cast<NB64Etalon::TImpls::EImpl>(i); - const auto ej = static_cast<NB64Etalon::TImpls::EImpl>(j); - const auto impl = IMPLS.Impl[i]; - const auto otherImpl = IMPLS.Impl[j]; - if (!impl.Encode && !impl.Decode || !otherImpl.Encode && !otherImpl.Decode) { - continue; - } - - for (const auto& x : xs) { - impl.Encode(x, xEnc); - impl.Decode(xEnc, xDec); - Y_ENSURE(x == xDec, "something is wrong with " << ei << " implementation"); - - otherImpl.Encode(x, yEnc); - otherImpl.Decode(xEnc, yDec); - Y_ENSURE(x == yDec, "something is wrong with " << ej << " implementation"); - - UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); - UNIT_ASSERT_VALUES_EQUAL(xDec, yDec); - } - } - } - } - - Y_UNIT_TEST(TestIfEncodedDataIsZeroTerminatedOnRandomData) { - constexpr size_t TEST_CASES_COUNT = 1000; - constexpr size_t MAX_DATA_SIZE = 1000; - TFastRng<ui32> prng{42}; + + for (auto& x : xs) { + const size_t size = prng() % MAX_DATA_SIZE; + for (size_t j = 0; j < size; ++j) { + x += static_cast<char>(prng() % 256); + } + } + + static const auto IMPLS = NB64Etalon::GetImpls(); + for (size_t i = 0; i < static_cast<size_t>(NB64Etalon::TImpls::MAX_IMPL); ++i) { + for (size_t j = 0; j < static_cast<size_t>(NB64Etalon::TImpls::MAX_IMPL); ++j) { + const auto ei = static_cast<NB64Etalon::TImpls::EImpl>(i); + const auto ej = static_cast<NB64Etalon::TImpls::EImpl>(j); + const auto impl = IMPLS.Impl[i]; + const auto otherImpl = IMPLS.Impl[j]; + if (!impl.Encode && !impl.Decode || !otherImpl.Encode && !otherImpl.Decode) { + continue; + } + + for (const auto& x : xs) { + impl.Encode(x, xEnc); + impl.Decode(xEnc, xDec); + Y_ENSURE(x == xDec, "something is wrong with " << ei << " implementation"); + + otherImpl.Encode(x, yEnc); + otherImpl.Decode(xEnc, yDec); + Y_ENSURE(x == yDec, "something is wrong with " << ej << " implementation"); + + UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); + UNIT_ASSERT_VALUES_EQUAL(xDec, yDec); + } + } + } + } + + Y_UNIT_TEST(TestIfEncodedDataIsZeroTerminatedOnRandomData) { + constexpr size_t TEST_CASES_COUNT = 1000; + constexpr size_t MAX_DATA_SIZE = 1000; + TFastRng<ui32> prng{42}; TString x; TVector<char> buf; - for (size_t i = 0; i < TEST_CASES_COUNT; ++i) { - const size_t size = prng() % MAX_DATA_SIZE; - x.clear(); - for (size_t j = 0; j < size; ++j) { - x += static_cast<char>(prng() % 256); - } - - buf.assign(Base64EncodeBufSize(x.size()), Max<char>()); + for (size_t i = 0; i < TEST_CASES_COUNT; ++i) { + const size_t size = prng() % MAX_DATA_SIZE; + x.clear(); + for (size_t j = 0; j < size; ++j) { + x += static_cast<char>(prng() % 256); + } + + buf.assign(Base64EncodeBufSize(x.size()), Max<char>()); const auto* const xEncEnd = Base64Encode(buf.data(), (const unsigned char*)x.data(), x.size()); - UNIT_ASSERT_VALUES_EQUAL(*xEncEnd, '\0'); - } - } - - Y_UNIT_TEST(TestDecodeURLEncodedNoPadding) { - const auto x = "123"; - const auto xDec = Base64Decode("MTIz"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeURLEncodedOnePadding) { - const auto x = "12"; - const auto xDec = Base64Decode("MTI,"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeURLEncodedTwoPadding) { - const auto x = "1"; - const auto xDec = Base64Decode("MQ,,"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeNoPaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?a"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9h"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeOnePaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz8="); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeTwoPaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?aa"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9hYQ=="); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeURLEncodedNoPaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?a"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9h"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeURLEncodedOnePaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz8,"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } - - Y_UNIT_TEST(TestDecodeURLEncodedTwoPaddingLongString) { - const auto x = "How do I convert between big-endian and little-endian values in C++?aa"; - const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9hYQ,,"); - UNIT_ASSERT_VALUES_EQUAL(x, xDec); - } + UNIT_ASSERT_VALUES_EQUAL(*xEncEnd, '\0'); + } + } + + Y_UNIT_TEST(TestDecodeURLEncodedNoPadding) { + const auto x = "123"; + const auto xDec = Base64Decode("MTIz"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeURLEncodedOnePadding) { + const auto x = "12"; + const auto xDec = Base64Decode("MTI,"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeURLEncodedTwoPadding) { + const auto x = "1"; + const auto xDec = Base64Decode("MQ,,"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeNoPaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?a"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9h"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeOnePaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz8="); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeTwoPaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?aa"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9hYQ=="); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeURLEncodedNoPaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?a"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9h"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeURLEncodedOnePaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz8,"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } + + Y_UNIT_TEST(TestDecodeURLEncodedTwoPaddingLongString) { + const auto x = "How do I convert between big-endian and little-endian values in C++?aa"; + const auto xDec = Base64Decode("SG93IGRvIEkgY29udmVydCBiZXR3ZWVuIGJpZy1lbmRpYW4gYW5kIGxpdHRsZS1lbmRpYW4gdmFsdWVzIGluIEMrKz9hYQ,,"); + UNIT_ASSERT_VALUES_EQUAL(x, xDec); + } } diff --git a/library/cpp/string_utils/base64/bench/main.cpp b/library/cpp/string_utils/base64/bench/main.cpp index f3f8280136..10e09bc1c7 100644 --- a/library/cpp/string_utils/base64/bench/main.cpp +++ b/library/cpp/string_utils/base64/bench/main.cpp @@ -1,110 +1,110 @@ #include <library/cpp/string_utils/base64/base64.h> - + #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/buffer.h> -#include <util/generic/singleton.h> + +#include <util/generic/buffer.h> +#include <util/generic/singleton.h> #include <util/generic/string.h> -#include <util/generic/vector.h> -#include <util/generic/xrange.h> -#include <util/generic/yexception.h> -#include <util/random/random.h> - -#include <array> - +#include <util/generic/vector.h> +#include <util/generic/xrange.h> +#include <util/generic/yexception.h> +#include <util/random/random.h> + +#include <array> + static TString GenerateRandomData(const size_t minSize, const size_t maxSize) { - Y_ENSURE(minSize <= maxSize, "wow"); + Y_ENSURE(minSize <= maxSize, "wow"); TString r; - for (size_t i = 0; i < minSize; ++i) { - r.push_back(RandomNumber<char>()); - } - - if (minSize == maxSize) { - return r; - } - - const size_t size = RandomNumber<size_t>() % (maxSize - minSize + 1); - for (size_t i = 0; i < size; ++i) { - r.push_back(RandomNumber<char>()); - } - - return r; -} - -template <size_t N> + for (size_t i = 0; i < minSize; ++i) { + r.push_back(RandomNumber<char>()); + } + + if (minSize == maxSize) { + return r; + } + + const size_t size = RandomNumber<size_t>() % (maxSize - minSize + 1); + for (size_t i = 0; i < size; ++i) { + r.push_back(RandomNumber<char>()); + } + + return r; +} + +template <size_t N> static std::array<TString, N> GenerateRandomDataVector(const size_t minSize, const size_t maxSize) { std::array<TString, N> r; - for (size_t i = 0; i < N; ++i) { - r[i] = GenerateRandomData(minSize, maxSize); - } - - return r; -} - -template <size_t N> + for (size_t i = 0; i < N; ++i) { + r[i] = GenerateRandomData(minSize, maxSize); + } + + return r; +} + +template <size_t N> static std::array<TString, N> Encode(const std::array<TString, N>& d) { std::array<TString, N> r; - for (size_t i = 0, iEnd = d.size(); i < iEnd; ++i) { - r[i] = Base64Encode(d[i]); - } - - return r; -} - -namespace { - template <size_t N, size_t MinSize, size_t MaxSize> - struct TRandomDataHolder { - TRandomDataHolder() - : Data(GenerateRandomDataVector<N>(MinSize, MaxSize)) - , DataEncoded(Encode<N>(Data)) - { - for (size_t i = 0; i < N; ++i) { - const size_t size = Data[i].size(); - const size_t sizeEnc = DataEncoded[i].size(); - PlaceToEncode[i].Resize(Base64EncodeBufSize(size)); - PlaceToDecode[i].Resize(Base64DecodeBufSize(sizeEnc)); - } - } - - static constexpr size_t Size = N; + for (size_t i = 0, iEnd = d.size(); i < iEnd; ++i) { + r[i] = Base64Encode(d[i]); + } + + return r; +} + +namespace { + template <size_t N, size_t MinSize, size_t MaxSize> + struct TRandomDataHolder { + TRandomDataHolder() + : Data(GenerateRandomDataVector<N>(MinSize, MaxSize)) + , DataEncoded(Encode<N>(Data)) + { + for (size_t i = 0; i < N; ++i) { + const size_t size = Data[i].size(); + const size_t sizeEnc = DataEncoded[i].size(); + PlaceToEncode[i].Resize(Base64EncodeBufSize(size)); + PlaceToDecode[i].Resize(Base64DecodeBufSize(sizeEnc)); + } + } + + static constexpr size_t Size = N; const std::array<TString, N> Data; const std::array<TString, N> DataEncoded; - std::array<TBuffer, N> PlaceToEncode; - std::array<TBuffer, N> PlaceToDecode; - }; - - template <size_t N, size_t Size> - using TFixedSizeRandomDataHolder = TRandomDataHolder<N, Size, Size>; - - using FSRDH_1 = TFixedSizeRandomDataHolder<10, 1>; - using FSRDH_2 = TFixedSizeRandomDataHolder<10, 2>; - using FSRDH_4 = TFixedSizeRandomDataHolder<10, 4>; - using FSRDH_8 = TFixedSizeRandomDataHolder<10, 8>; - using FSRDH_16 = TFixedSizeRandomDataHolder<10, 16>; - using FSRDH_32 = TFixedSizeRandomDataHolder<10, 32>; - using FSRDH_64 = TFixedSizeRandomDataHolder<10, 64>; - using FSRDH_128 = TFixedSizeRandomDataHolder<10, 128>; - using FSRDH_1024 = TFixedSizeRandomDataHolder<10, 1024>; - using FSRDH_10240 = TFixedSizeRandomDataHolder<10, 10240>; - using FSRDH_102400 = TFixedSizeRandomDataHolder<10, 102400>; - using FSRDH_1048576 = TFixedSizeRandomDataHolder<10, 1048576>; - using FSRDH_10485760 = TFixedSizeRandomDataHolder<10, 10485760>; -} - -template <typename T> -static inline void BenchEncode(T& d, const NBench::NCpu::TParams& iface) { - for (const auto it : xrange(iface.Iterations())) { - Y_UNUSED(it); - for (size_t i = 0; i < d.Size; ++i) { + std::array<TBuffer, N> PlaceToEncode; + std::array<TBuffer, N> PlaceToDecode; + }; + + template <size_t N, size_t Size> + using TFixedSizeRandomDataHolder = TRandomDataHolder<N, Size, Size>; + + using FSRDH_1 = TFixedSizeRandomDataHolder<10, 1>; + using FSRDH_2 = TFixedSizeRandomDataHolder<10, 2>; + using FSRDH_4 = TFixedSizeRandomDataHolder<10, 4>; + using FSRDH_8 = TFixedSizeRandomDataHolder<10, 8>; + using FSRDH_16 = TFixedSizeRandomDataHolder<10, 16>; + using FSRDH_32 = TFixedSizeRandomDataHolder<10, 32>; + using FSRDH_64 = TFixedSizeRandomDataHolder<10, 64>; + using FSRDH_128 = TFixedSizeRandomDataHolder<10, 128>; + using FSRDH_1024 = TFixedSizeRandomDataHolder<10, 1024>; + using FSRDH_10240 = TFixedSizeRandomDataHolder<10, 10240>; + using FSRDH_102400 = TFixedSizeRandomDataHolder<10, 102400>; + using FSRDH_1048576 = TFixedSizeRandomDataHolder<10, 1048576>; + using FSRDH_10485760 = TFixedSizeRandomDataHolder<10, 10485760>; +} + +template <typename T> +static inline void BenchEncode(T& d, const NBench::NCpu::TParams& iface) { + for (const auto it : xrange(iface.Iterations())) { + Y_UNUSED(it); + for (size_t i = 0; i < d.Size; ++i) { NBench::Escape(d.PlaceToEncode[i].data()); - Y_DO_NOT_OPTIMIZE_AWAY( + Y_DO_NOT_OPTIMIZE_AWAY( Base64Encode(d.PlaceToEncode[i].data(), (const unsigned char*)d.Data[i].data(), d.Data[i].size())); - NBench::Clobber(); - } - } -} - -template <typename T> + NBench::Clobber(); + } + } +} + +template <typename T> static inline void BenchEncodeUrl(T& d, const NBench::NCpu::TParams& iface) { for (const auto it : xrange(iface.Iterations())) { Y_UNUSED(it); @@ -118,147 +118,147 @@ static inline void BenchEncodeUrl(T& d, const NBench::NCpu::TParams& iface) { } template <typename T> -static inline void BenchDecode(T& d, const NBench::NCpu::TParams& iface) { - for (const auto it : xrange(iface.Iterations())) { - Y_UNUSED(it); - for (size_t i = 0; i < d.Size; ++i) { +static inline void BenchDecode(T& d, const NBench::NCpu::TParams& iface) { + for (const auto it : xrange(iface.Iterations())) { + Y_UNUSED(it); + for (size_t i = 0; i < d.Size; ++i) { NBench::Escape(d.PlaceToDecode[i].data()); - Y_DO_NOT_OPTIMIZE_AWAY( + Y_DO_NOT_OPTIMIZE_AWAY( Base64Decode(d.PlaceToDecode[i].data(), (const char*)d.DataEncoded[i].data(), (const char*)(d.DataEncoded[i].data() + d.DataEncoded[i].size()))); - NBench::Clobber(); - } - } -} - -Y_CPU_BENCHMARK(EncodeF1, iface) { - auto& d = *Singleton<FSRDH_1>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF1, iface) { - auto& d = *Singleton<FSRDH_1>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF2, iface) { - auto& d = *Singleton<FSRDH_2>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF2, iface) { - auto& d = *Singleton<FSRDH_2>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF4, iface) { - auto& d = *Singleton<FSRDH_4>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF4, iface) { - auto& d = *Singleton<FSRDH_4>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF8, iface) { - auto& d = *Singleton<FSRDH_8>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF8, iface) { - auto& d = *Singleton<FSRDH_8>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF16, iface) { - auto& d = *Singleton<FSRDH_16>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF16, iface) { - auto& d = *Singleton<FSRDH_16>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF32, iface) { - auto& d = *Singleton<FSRDH_32>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF32, iface) { - auto& d = *Singleton<FSRDH_32>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF64, iface) { - auto& d = *Singleton<FSRDH_64>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF64, iface) { - auto& d = *Singleton<FSRDH_64>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF128, iface) { - auto& d = *Singleton<FSRDH_128>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF128, iface) { - auto& d = *Singleton<FSRDH_128>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF1024, iface) { - auto& d = *Singleton<FSRDH_1024>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF1024, iface) { - auto& d = *Singleton<FSRDH_1024>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF10240, iface) { - auto& d = *Singleton<FSRDH_10240>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF10240, iface) { - auto& d = *Singleton<FSRDH_10240>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF102400, iface) { - auto& d = *Singleton<FSRDH_102400>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF102400, iface) { - auto& d = *Singleton<FSRDH_102400>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF1048576, iface) { - auto& d = *Singleton<FSRDH_1048576>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF1048576, iface) { - auto& d = *Singleton<FSRDH_1048576>(); - BenchDecode(d, iface); -} - -Y_CPU_BENCHMARK(EncodeF10485760, iface) { - auto& d = *Singleton<FSRDH_10485760>(); - BenchEncode(d, iface); -} - -Y_CPU_BENCHMARK(DecodeF10485760, iface) { - auto& d = *Singleton<FSRDH_10485760>(); - BenchDecode(d, iface); -} + NBench::Clobber(); + } + } +} + +Y_CPU_BENCHMARK(EncodeF1, iface) { + auto& d = *Singleton<FSRDH_1>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF1, iface) { + auto& d = *Singleton<FSRDH_1>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF2, iface) { + auto& d = *Singleton<FSRDH_2>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF2, iface) { + auto& d = *Singleton<FSRDH_2>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF4, iface) { + auto& d = *Singleton<FSRDH_4>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF4, iface) { + auto& d = *Singleton<FSRDH_4>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF8, iface) { + auto& d = *Singleton<FSRDH_8>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF8, iface) { + auto& d = *Singleton<FSRDH_8>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF16, iface) { + auto& d = *Singleton<FSRDH_16>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF16, iface) { + auto& d = *Singleton<FSRDH_16>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF32, iface) { + auto& d = *Singleton<FSRDH_32>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF32, iface) { + auto& d = *Singleton<FSRDH_32>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF64, iface) { + auto& d = *Singleton<FSRDH_64>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF64, iface) { + auto& d = *Singleton<FSRDH_64>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF128, iface) { + auto& d = *Singleton<FSRDH_128>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF128, iface) { + auto& d = *Singleton<FSRDH_128>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF1024, iface) { + auto& d = *Singleton<FSRDH_1024>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF1024, iface) { + auto& d = *Singleton<FSRDH_1024>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF10240, iface) { + auto& d = *Singleton<FSRDH_10240>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF10240, iface) { + auto& d = *Singleton<FSRDH_10240>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF102400, iface) { + auto& d = *Singleton<FSRDH_102400>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF102400, iface) { + auto& d = *Singleton<FSRDH_102400>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF1048576, iface) { + auto& d = *Singleton<FSRDH_1048576>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF1048576, iface) { + auto& d = *Singleton<FSRDH_1048576>(); + BenchDecode(d, iface); +} + +Y_CPU_BENCHMARK(EncodeF10485760, iface) { + auto& d = *Singleton<FSRDH_10485760>(); + BenchEncode(d, iface); +} + +Y_CPU_BENCHMARK(DecodeF10485760, iface) { + auto& d = *Singleton<FSRDH_10485760>(); + BenchDecode(d, iface); +} Y_CPU_BENCHMARK(EncodeUrlF1, iface) { auto& d = *Singleton<FSRDH_1>(); diff --git a/library/cpp/string_utils/base64/bench/metrics/main.py b/library/cpp/string_utils/base64/bench/metrics/main.py index 79577bf4d4..c35fd6d8cd 100644 --- a/library/cpp/string_utils/base64/bench/metrics/main.py +++ b/library/cpp/string_utils/base64/bench/metrics/main.py @@ -1,5 +1,5 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): +import yatest.common as yc + + +def test_export_metrics(metrics): metrics.set_benchmark(yc.execute_benchmark('library/cpp/string_utils/base64/bench/bench')) diff --git a/library/cpp/string_utils/base64/bench/metrics/ya.make b/library/cpp/string_utils/base64/bench/metrics/ya.make index 14b57dae22..b0406516c3 100644 --- a/library/cpp/string_utils/base64/bench/metrics/ya.make +++ b/library/cpp/string_utils/base64/bench/metrics/ya.make @@ -1,20 +1,20 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) - +) + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(library/cpp/string_utils/base64/bench) - -END() + +END() diff --git a/library/cpp/string_utils/base64/bench/ya.make b/library/cpp/string_utils/base64/bench/ya.make index 30a13c6509..5ac5f3d6ce 100644 --- a/library/cpp/string_utils/base64/bench/ya.make +++ b/library/cpp/string_utils/base64/bench/ya.make @@ -1,16 +1,16 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) - +) + Y_BENCHMARK() - -SRCS( - main.cpp -) - -PEERDIR( + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/string_utils/base64 -) - -END() +) + +END() diff --git a/library/cpp/string_utils/base64/fuzz/generic/ya.make b/library/cpp/string_utils/base64/fuzz/generic/ya.make index 608c12a09e..d155e2b0a0 100644 --- a/library/cpp/string_utils/base64/fuzz/generic/ya.make +++ b/library/cpp/string_utils/base64/fuzz/generic/ya.make @@ -1,12 +1,12 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) - -FUZZ() - -PEERDIR( +) + +FUZZ() + +PEERDIR( library/cpp/string_utils/base64/fuzz/lib -) - -END() +) + +END() diff --git a/library/cpp/string_utils/base64/fuzz/lib/main.cpp b/library/cpp/string_utils/base64/fuzz/lib/main.cpp index aec5655eec..28547ae7a5 100644 --- a/library/cpp/string_utils/base64/fuzz/lib/main.cpp +++ b/library/cpp/string_utils/base64/fuzz/lib/main.cpp @@ -1,13 +1,13 @@ #include <library/cpp/string_utils/base64/base64.h> - -#include <util/system/types.h> -#include <util/system/yassert.h> - -extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { - const TStringBuf example{reinterpret_cast<const char*>(data), size}; - const auto converted = Base64Decode(Base64Encode(example)); - - Y_VERIFY(example == converted); - - return 0; -} + +#include <util/system/types.h> +#include <util/system/yassert.h> + +extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { + const TStringBuf example{reinterpret_cast<const char*>(data), size}; + const auto converted = Base64Decode(Base64Encode(example)); + + Y_VERIFY(example == converted); + + return 0; +} diff --git a/library/cpp/string_utils/base64/fuzz/lib/ya.make b/library/cpp/string_utils/base64/fuzz/lib/ya.make index 6fee5c9f99..7b981b86a3 100644 --- a/library/cpp/string_utils/base64/fuzz/lib/ya.make +++ b/library/cpp/string_utils/base64/fuzz/lib/ya.make @@ -1,16 +1,16 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) - -LIBRARY() - -SRCS( - main.cpp -) - -PEERDIR( +) + +LIBRARY() + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/string_utils/base64 -) - -END() +) + +END() diff --git a/library/cpp/string_utils/base64/fuzz/ya.make b/library/cpp/string_utils/base64/fuzz/ya.make index a0ed64f273..bef82061c4 100644 --- a/library/cpp/string_utils/base64/fuzz/ya.make +++ b/library/cpp/string_utils/base64/fuzz/ya.make @@ -1,10 +1,10 @@ -OWNER( - yazevnul +OWNER( + yazevnul g:util -) - -RECURSE( - generic - lib +) + +RECURSE( + generic + lib uneven -) +) diff --git a/library/cpp/string_utils/base64/ut/ya.make b/library/cpp/string_utils/base64/ut/ya.make index 560d96423f..9b61241f0e 100644 --- a/library/cpp/string_utils/base64/ut/ya.make +++ b/library/cpp/string_utils/base64/ut/ya.make @@ -1,22 +1,22 @@ -OWNER( +OWNER( g:util - yazevnul -) - + yazevnul +) + UNITTEST_FOR(library/cpp/string_utils/base64) - -SRCS( - base64_ut.cpp + +SRCS( + base64_ut.cpp base64_decode_uneven_ut.cpp -) - -PEERDIR( - contrib/libs/base64/avx2 - contrib/libs/base64/ssse3 - contrib/libs/base64/neon32 - contrib/libs/base64/neon64 - contrib/libs/base64/plain32 - contrib/libs/base64/plain64 -) - -END() +) + +PEERDIR( + contrib/libs/base64/avx2 + contrib/libs/base64/ssse3 + contrib/libs/base64/neon32 + contrib/libs/base64/neon64 + contrib/libs/base64/plain32 + contrib/libs/base64/plain64 +) + +END() diff --git a/library/cpp/string_utils/base64/ya.make b/library/cpp/string_utils/base64/ya.make index ee1ec0e023..f5258c446c 100644 --- a/library/cpp/string_utils/base64/ya.make +++ b/library/cpp/string_utils/base64/ya.make @@ -1,23 +1,23 @@ -OWNER( +OWNER( g:util - yazevnul -) - -LIBRARY() - -SRCS( - base64.cpp -) - -PEERDIR( - contrib/libs/base64/avx2 - contrib/libs/base64/ssse3 - contrib/libs/base64/neon32 - contrib/libs/base64/neon64 - contrib/libs/base64/plain32 - contrib/libs/base64/plain64 -) - -END() + yazevnul +) + +LIBRARY() + +SRCS( + base64.cpp +) + +PEERDIR( + contrib/libs/base64/avx2 + contrib/libs/base64/ssse3 + contrib/libs/base64/neon32 + contrib/libs/base64/neon64 + contrib/libs/base64/plain32 + contrib/libs/base64/plain64 +) + +END() RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h index ac33cd87d2..8a240bfed8 100644 --- a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h +++ b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h @@ -112,7 +112,7 @@ namespace NLevenshtein { } // Tracing the path from final point res.clear(); - res.reserve(Max<size_t>(l1, l2)); + res.reserve(Max<size_t>(l1, l2)); for (int i = l1, j = l2; ma[i][j].second != EMT_SPECIAL;) { res.push_back(ma[i][j].second); switch (ma[i][j].second) { diff --git a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp index f8bdc941c8..cf0f78637f 100644 --- a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp +++ b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp @@ -24,8 +24,8 @@ namespace { } -Y_UNIT_TEST_SUITE(Levenstein) { - Y_UNIT_TEST(Distance) { +Y_UNIT_TEST_SUITE(Levenstein) { + Y_UNIT_TEST(Distance) { UNIT_ASSERT_VALUES_EQUAL(NLevenshtein::Distance(TStringBuf("hello"), TStringBuf("hulloah")), 3); UNIT_ASSERT_VALUES_EQUAL(NLevenshtein::Distance(TStringBuf("yeoman"), TStringBuf("yo man")), 2); } diff --git a/library/cpp/string_utils/parse_size/parse_size.cpp b/library/cpp/string_utils/parse_size/parse_size.cpp index 8c521b1e0c..39188d560b 100644 --- a/library/cpp/string_utils/parse_size/parse_size.cpp +++ b/library/cpp/string_utils/parse_size/parse_size.cpp @@ -90,6 +90,6 @@ NSize::TSize FromStringImpl<NSize::TSize>(const char* data, size_t len) { } template <> -void Out<NSize::TSize>(IOutputStream& os, const NSize::TSize& size) { +void Out<NSize::TSize>(IOutputStream& os, const NSize::TSize& size) { os << size.GetValue(); } diff --git a/library/cpp/string_utils/quote/quote.cpp b/library/cpp/string_utils/quote/quote.cpp index e7ce5667db..e523350b80 100644 --- a/library/cpp/string_utils/quote/quote.cpp +++ b/library/cpp/string_utils/quote/quote.cpp @@ -166,7 +166,7 @@ TString CGIEscapeRet(const TStringBuf url) { TString to; to.ReserveAndResize(CgiEscapeBufLen(url.size())); to.resize(CGIEscape(to.begin(), url.data(), url.size()) - to.data()); - return to; + return to; } TString& AppendCgiEscaped(const TStringBuf value, TString& to) { @@ -203,7 +203,7 @@ char* Quote(char* to, const char* from, const char* safe) { return Quote(to, FixZero(from), TCStringEndIterator(), safe); } -char* Quote(char* to, const TStringBuf s, const char* safe) { +char* Quote(char* to, const TStringBuf s, const char* safe) { return Quote(to, s.data(), s.data() + s.size(), safe); } @@ -239,7 +239,7 @@ TString CGIUnescapeRet(const TStringBuf from) { TString to; to.ReserveAndResize(CgiUnescapeBufLen(from.size())); to.resize(CGIUnescape(to.begin(), from.data(), from.size()) - to.data()); - return to; + return to; } char* UrlUnescape(char* to, TStringBuf from) { diff --git a/library/cpp/string_utils/quote/quote.h b/library/cpp/string_utils/quote/quote.h index 3cea6feba1..3b7221154e 100644 --- a/library/cpp/string_utils/quote/quote.h +++ b/library/cpp/string_utils/quote/quote.h @@ -10,17 +10,17 @@ // Returns pointer to the end of the result string char* CGIEscape(char* to, const char* from); char* CGIEscape(char* to, const char* from, size_t len); -inline char* CGIEscape(char* to, const TStringBuf from) { +inline char* CGIEscape(char* to, const TStringBuf from) { return CGIEscape(to, from.data(), from.size()); } void CGIEscape(TString& url); TString CGIEscapeRet(const TStringBuf url); TString& AppendCgiEscaped(const TStringBuf value, TString& to); -inline TStringBuf CgiEscapeBuf(char* to, const TStringBuf from) { +inline TStringBuf CgiEscapeBuf(char* to, const TStringBuf from) { return TStringBuf(to, CGIEscape(to, from.data(), from.size())); } -inline TStringBuf CgiEscape(void* tmp, const TStringBuf s) { +inline TStringBuf CgiEscape(void* tmp, const TStringBuf s) { return CgiEscapeBuf(static_cast<char*>(tmp), s); } @@ -33,17 +33,17 @@ char* CGIUnescape(char* to, const char* from, size_t len); void CGIUnescape(TString& url); TString CGIUnescapeRet(const TStringBuf from); -inline TStringBuf CgiUnescapeBuf(char* to, const TStringBuf from) { +inline TStringBuf CgiUnescapeBuf(char* to, const TStringBuf from) { return TStringBuf(to, CGIUnescape(to, from.data(), from.size())); } -inline TStringBuf CgiUnescape(void* tmp, const TStringBuf s) { +inline TStringBuf CgiUnescape(void* tmp, const TStringBuf s) { return CgiUnescapeBuf(static_cast<char*>(tmp), s); } //Quote: // Is like CGIEscape, also skips encoding of user-supplied 'safe' characters. char* Quote(char* to, const char* from, const char* safe = "/"); -char* Quote(char* to, const TStringBuf s, const char* safe = "/"); +char* Quote(char* to, const TStringBuf s, const char* safe = "/"); void Quote(TString& url, const char* safe = "/"); //UrlEscape: @@ -63,10 +63,10 @@ void UrlUnescape(TString& url); TString UrlUnescapeRet(const TStringBuf from); //*BufLen: how much characters you should allocate for 'char* to' buffers. -constexpr size_t CgiEscapeBufLen(const size_t len) noexcept { +constexpr size_t CgiEscapeBufLen(const size_t len) noexcept { return 3 * len + 1; } -constexpr size_t CgiUnescapeBufLen(const size_t len) noexcept { +constexpr size_t CgiUnescapeBufLen(const size_t len) noexcept { return len + 1; } diff --git a/library/cpp/string_utils/quote/quote_ut.cpp b/library/cpp/string_utils/quote/quote_ut.cpp index f505cf669a..6c552b279e 100644 --- a/library/cpp/string_utils/quote/quote_ut.cpp +++ b/library/cpp/string_utils/quote/quote_ut.cpp @@ -2,15 +2,15 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TCGIEscapeTest) { - Y_UNIT_TEST(ReturnsEndOfTo) { +Y_UNIT_TEST_SUITE(TCGIEscapeTest) { + Y_UNIT_TEST(ReturnsEndOfTo) { char r[10]; const char* returned = CGIEscape(r, "123"); UNIT_ASSERT_VALUES_EQUAL(r + strlen("123"), returned); UNIT_ASSERT_VALUES_EQUAL('\0', *returned); } - Y_UNIT_TEST(NotZeroTerminated) { + Y_UNIT_TEST(NotZeroTerminated) { char r[] = {'1', '2', '3', '4'}; char buf[sizeof(r) * 3 + 2]; @@ -19,13 +19,13 @@ Y_UNIT_TEST_SUITE(TCGIEscapeTest) { UNIT_ASSERT_EQUAL(ret, "1234"); } - Y_UNIT_TEST(StringBuf) { + Y_UNIT_TEST(StringBuf) { char tmp[100]; UNIT_ASSERT_VALUES_EQUAL(CgiEscape(tmp, "!@#$%^&*(){}[]\" "), TStringBuf("!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+")); } - Y_UNIT_TEST(StrokaRet) { + Y_UNIT_TEST(StrokaRet) { UNIT_ASSERT_VALUES_EQUAL(CGIEscapeRet("!@#$%^&*(){}[]\" "), TString("!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+")); } @@ -47,14 +47,14 @@ Y_UNIT_TEST_SUITE(TCGIEscapeTest) { } -Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { - Y_UNIT_TEST(StringBuf) { +Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { + Y_UNIT_TEST(StringBuf) { char tmp[100]; UNIT_ASSERT_VALUES_EQUAL(CgiUnescape(tmp, "!@%23$%25^%26*%28%29"), TStringBuf("!@#$%^&*()")); } - Y_UNIT_TEST(TestValidZeroTerm) { + Y_UNIT_TEST(TestValidZeroTerm) { char r[10]; CGIUnescape(r, "1234"); @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(r, "12=34"); } - Y_UNIT_TEST(TestInvalidZeroTerm) { + Y_UNIT_TEST(TestInvalidZeroTerm) { char r[10]; CGIUnescape(r, "%"); @@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(r, "%3u123"); } - Y_UNIT_TEST(TestValidNotZeroTerm) { + Y_UNIT_TEST(TestValidNotZeroTerm) { char r[10]; CGIUnescape(r, "123456789", 4); @@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(r, "12=34"); } - Y_UNIT_TEST(TestInvalidNotZeroTerm) { + Y_UNIT_TEST(TestInvalidNotZeroTerm) { char r[10]; CGIUnescape(r, "%3d", 1); @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(r, "%3u1"); } - Y_UNIT_TEST(StrokaOutParameterInplace) { + Y_UNIT_TEST(StrokaOutParameterInplace) { TString s; s = "hello%3dworld"; @@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(s, ""); } - Y_UNIT_TEST(StrokaOutParameterNotInplace) { + Y_UNIT_TEST(StrokaOutParameterNotInplace) { TString s, sCopy; s = "hello%3dworld"; @@ -230,8 +230,8 @@ Y_UNIT_TEST_SUITE(TUrlEscapeTest) { } } -Y_UNIT_TEST_SUITE(TUrlUnescapeTest) { - Y_UNIT_TEST(StrokaOutParameterInplace) { +Y_UNIT_TEST_SUITE(TUrlUnescapeTest) { + Y_UNIT_TEST(StrokaOutParameterInplace) { TString s; s = "hello%3dworld"; @@ -255,7 +255,7 @@ Y_UNIT_TEST_SUITE(TUrlUnescapeTest) { UNIT_ASSERT_VALUES_EQUAL(s, ""); } - Y_UNIT_TEST(StrokaOutParameterNotInplace) { + Y_UNIT_TEST(StrokaOutParameterNotInplace) { TString s, sCopy; s = "hello%3dworld"; @@ -285,15 +285,15 @@ Y_UNIT_TEST_SUITE(TUrlUnescapeTest) { } } -Y_UNIT_TEST_SUITE(TQuoteTest) { - Y_UNIT_TEST(ReturnsEndOfTo) { +Y_UNIT_TEST_SUITE(TQuoteTest) { + Y_UNIT_TEST(ReturnsEndOfTo) { char r[10]; const char* returned = Quote(r, "123"); UNIT_ASSERT_VALUES_EQUAL(r + strlen("123"), returned); UNIT_ASSERT_VALUES_EQUAL('\0', *returned); } - Y_UNIT_TEST(SlashIsSafeByDefault) { + Y_UNIT_TEST(SlashIsSafeByDefault) { char r[100]; Quote(r, "/path;tail/path,tail/"); UNIT_ASSERT_VALUES_EQUAL("/path%3Btail/path%2Ctail/", r); @@ -302,7 +302,7 @@ Y_UNIT_TEST_SUITE(TQuoteTest) { UNIT_ASSERT_VALUES_EQUAL("/path%3Btail/path%2Ctail/", s.c_str()); } - Y_UNIT_TEST(SafeColons) { + Y_UNIT_TEST(SafeColons) { char r[100]; Quote(r, "/path;tail/path,tail/", ";,"); UNIT_ASSERT_VALUES_EQUAL("%2Fpath;tail%2Fpath,tail%2F", r); @@ -311,7 +311,7 @@ Y_UNIT_TEST_SUITE(TQuoteTest) { UNIT_ASSERT_VALUES_EQUAL("%2Fpath;tail%2Fpath,tail%2F", s.c_str()); } - Y_UNIT_TEST(StringBuf) { + Y_UNIT_TEST(StringBuf) { char r[100]; char* end = Quote(r, "abc\0/path", ""); UNIT_ASSERT_VALUES_EQUAL("abc\0%2Fpath", TStringBuf(r, end)); diff --git a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h index 8620c7517b..d7ea7c1259 100644 --- a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h +++ b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h @@ -150,7 +150,7 @@ namespace NEscJ { } template <bool quote, bool tounicode> - inline void EscapeJ(TStringBuf in, IOutputStream& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { + inline void EscapeJ(TStringBuf in, IOutputStream& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { TTempBuf b(SuggestBuffer(in.size()) + 2); if (quote) @@ -192,7 +192,7 @@ namespace NEscJ { } template <bool quote> - inline void EscapeJ(TStringBuf in, IOutputStream& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { + inline void EscapeJ(TStringBuf in, IOutputStream& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { EscapeJ<quote, false>(in, out, safe, unsafe); } diff --git a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp index 3cc25dc887..768555ea3a 100644 --- a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp +++ b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp @@ -25,10 +25,10 @@ static const TStringBuf CommonTestData[] = { RESC_FIXED_STR("There\\tare\\ttabs."), RESC_FIXED_STR("There\tare\ttabs.")}; #undef RESC_FIXED_STR -Y_UNIT_TEST_SUITE(TRelaxedEscaperTest) { - Y_UNIT_TEST(TestEscaper) { +Y_UNIT_TEST_SUITE(TRelaxedEscaperTest) { + Y_UNIT_TEST(TestEscaper) { using namespace NEscJ; - for (size_t i = 0; i < Y_ARRAY_SIZE(CommonTestData); i += 2) { + for (size_t i = 0; i < Y_ARRAY_SIZE(CommonTestData); i += 2) { TString expected(CommonTestData[i].data(), CommonTestData[i].size()); TString source(CommonTestData[i + 1].data(), CommonTestData[i + 1].size()); TString actual(EscapeJ<false>(source)); diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp index 284842f831..85f4ac5d69 100644 --- a/library/cpp/string_utils/url/url.cpp +++ b/library/cpp/string_utils/url/url.cpp @@ -124,7 +124,7 @@ TStringBuf CutSchemePrefix(const TStringBuf url) noexcept { } template <bool KeepPort> -static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) { +static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) { TStringBuf urlNoScheme = url; urlNoScheme.Skip(GetHttpPrefixSize(url)); @@ -324,8 +324,8 @@ static bool HasPrefix(const TStringBuf url) noexcept { TString AddSchemePrefix(const TString& url) { return AddSchemePrefix(url, TStringBuf("http")); -} - +} + TString AddSchemePrefix(const TString& url, TStringBuf scheme) { if (HasPrefix(url)) { return url; @@ -347,7 +347,7 @@ static inline int x2c(unsigned char* x) { static inline int Unescape(char* str) { char *to, *from; int dlen = 0; - if ((str = strchr(str, '%')) == nullptr) + if ((str = strchr(str, '%')) == nullptr) return dlen; for (to = str, from = str; *from; from++, to++) { if ((*to = *from) == '%') { @@ -361,7 +361,7 @@ static inline int Unescape(char* str) { return dlen; } -size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size) { +size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size) { if (source.empty() || source[0] == '?') return strlcpy(dest, "/", dest_size); size_t len = Min(dest_size - 1, source.length()); @@ -372,7 +372,7 @@ size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size) { return len; } -size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport) { +size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport) { size_t len = Min(dest_size - 1, source.length()); memcpy(dest, source.data(), len); dest[len] = 0; diff --git a/library/cpp/string_utils/url/url.h b/library/cpp/string_utils/url/url.h index 287b42d3e3..84137ccc57 100644 --- a/library/cpp/string_utils/url/url.h +++ b/library/cpp/string_utils/url/url.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/fwd.h> +#include <util/generic/fwd.h> #include <util/generic/strbuf.h> namespace NUrl { @@ -60,9 +60,9 @@ TStringBuf CutSchemePrefix(const TStringBuf url) noexcept; //! @note if URL has scheme prefix already the function returns unchanged URL TString AddSchemePrefix(const TString& url, const TStringBuf scheme); -//! Same as `AddSchemePrefix(url, "http")`. +//! Same as `AddSchemePrefix(url, "http")`. TString AddSchemePrefix(const TString& url); - + Y_PURE_FUNCTION TStringBuf GetHost(const TStringBuf url) noexcept; @@ -159,8 +159,8 @@ TStringBuf CutMPrefix(const TStringBuf url) noexcept; Y_PURE_FUNCTION TStringBuf GetDomain(const TStringBuf host) noexcept; // should not be used -size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size); -size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport = 80); +size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size); +size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, ui16 defport = 80); Y_PURE_FUNCTION TStringBuf RemoveFinalSlash(TStringBuf str) noexcept; diff --git a/library/cpp/string_utils/url/url_ut.cpp b/library/cpp/string_utils/url/url_ut.cpp index 2c2f5948a0..1588013893 100644 --- a/library/cpp/string_utils/url/url_ut.cpp +++ b/library/cpp/string_utils/url/url_ut.cpp @@ -4,8 +4,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TUtilUrlTest) { - Y_UNIT_TEST(TestGetHostAndGetHostAndPort) { +Y_UNIT_TEST_SUITE(TUtilUrlTest) { + Y_UNIT_TEST(TestGetHostAndGetHostAndPort) { UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHost("ya.ru/bebe")); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHostAndPort("ya.ru/bebe")); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHost("ya.ru")); @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("", GetHost("")); } - Y_UNIT_TEST(TestGetPathAndQuery) { + Y_UNIT_TEST(TestGetPathAndQuery) { UNIT_ASSERT_VALUES_EQUAL("/", GetPathAndQuery("ru.wikipedia.org")); UNIT_ASSERT_VALUES_EQUAL("/", GetPathAndQuery("ru.wikipedia.org/")); UNIT_ASSERT_VALUES_EQUAL("/", GetPathAndQuery("ru.wikipedia.org:8080")); @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("/?1#comment", GetPathAndQuery("ru.wikipedia.org/?1#comment", false)); } - Y_UNIT_TEST(TestGetDomain) { + Y_UNIT_TEST(TestGetDomain) { UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetDomain("www.ya.ru")); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetDomain("ya.ru")); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetDomain("a.b.ya.ru")); @@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("", GetDomain("")); } - Y_UNIT_TEST(TestGetParentDomain) { + Y_UNIT_TEST(TestGetParentDomain) { UNIT_ASSERT_VALUES_EQUAL("", GetParentDomain("www.ya.ru", 0)); UNIT_ASSERT_VALUES_EQUAL("ru", GetParentDomain("www.ya.ru", 1)); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetParentDomain("www.ya.ru", 2)); @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("", GetParentDomain("", 1)); } - Y_UNIT_TEST(TestGetZone) { + Y_UNIT_TEST(TestGetZone) { UNIT_ASSERT_VALUES_EQUAL("ru", GetZone("www.ya.ru")); UNIT_ASSERT_VALUES_EQUAL("com", GetZone("ya.com")); UNIT_ASSERT_VALUES_EQUAL("RU", GetZone("RU")); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("", GetZone("")); } - Y_UNIT_TEST(TestAddSchemePrefix) { + Y_UNIT_TEST(TestAddSchemePrefix) { UNIT_ASSERT_VALUES_EQUAL("http://yandex.ru", AddSchemePrefix("yandex.ru")); UNIT_ASSERT_VALUES_EQUAL("http://yandex.ru", AddSchemePrefix("http://yandex.ru")); UNIT_ASSERT_VALUES_EQUAL("https://yandex.ru", AddSchemePrefix("https://yandex.ru")); @@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("ftp://ya.ru", AddSchemePrefix("ya.ru", "ftp")); } - Y_UNIT_TEST(TestSchemeGet) { + Y_UNIT_TEST(TestSchemeGet) { UNIT_ASSERT_VALUES_EQUAL("http://", GetSchemePrefix("http://ya.ru/bebe")); UNIT_ASSERT_VALUES_EQUAL("", GetSchemePrefix("yaru")); UNIT_ASSERT_VALUES_EQUAL("yaru://", GetSchemePrefix("yaru://ya.ru://zzz")); @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("https://", GetSchemePrefix("https://")); // is that right? } - Y_UNIT_TEST(TestSchemeCut) { + Y_UNIT_TEST(TestSchemeCut) { UNIT_ASSERT_VALUES_EQUAL("ya.ru/bebe", CutSchemePrefix("http://ya.ru/bebe")); UNIT_ASSERT_VALUES_EQUAL("yaru", CutSchemePrefix("yaru")); UNIT_ASSERT_VALUES_EQUAL("ya.ru://zzz", CutSchemePrefix("yaru://ya.ru://zzz")); @@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("https://", CutHttpPrefix("https://", true)); // is that right? } - Y_UNIT_TEST(TestMisc) { + Y_UNIT_TEST(TestMisc) { UNIT_ASSERT_VALUES_EQUAL("", CutWWWPrefix("www.")); UNIT_ASSERT_VALUES_EQUAL("", CutWWWPrefix("WwW.")); UNIT_ASSERT_VALUES_EQUAL("www", CutWWWPrefix("www")); @@ -127,7 +127,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutMPrefix("m.ya.ru")); } - Y_UNIT_TEST(TestSplitUrlToHostAndPath) { + Y_UNIT_TEST(TestSplitUrlToHostAndPath) { TStringBuf host, path; SplitUrlToHostAndPath("https://yandex.ru/yandsearch", host, path); @@ -175,7 +175,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_STRINGS_EQUAL(fragment, "fragment"); } - Y_UNIT_TEST(TestGetSchemeHostAndPort) { + Y_UNIT_TEST(TestGetSchemeHostAndPort) { { // all components are present TStringBuf scheme("unknown"), host("unknown"); ui16 port = 0; diff --git a/library/cpp/terminate_handler/segv_handler.cpp b/library/cpp/terminate_handler/segv_handler.cpp index f956f3bb97..f24ece4125 100644 --- a/library/cpp/terminate_handler/segv_handler.cpp +++ b/library/cpp/terminate_handler/segv_handler.cpp @@ -14,7 +14,7 @@ #ifndef _win_ static void SegvHandler(int sig) { - Y_UNUSED(sig); + Y_UNUSED(sig); const char msg[] = "Got SEGV\n"; Y_UNUSED(write(STDERR_FILENO, msg, sizeof(msg))); //PrintBackTrace(); @@ -29,6 +29,6 @@ static void SegvHandler(int sig) { void InstallSegvHandler() { #ifndef _win_ sig_t r = signal(SIGSEGV, &SegvHandler); - Y_VERIFY(r != SIG_ERR, "signal failed: %s", strerror(errno)); + Y_VERIFY(r != SIG_ERR, "signal failed: %s", strerror(errno)); #endif // !_win_ } diff --git a/library/cpp/testing/benchmark/bench.cpp b/library/cpp/testing/benchmark/bench.cpp index dc7f8b7856..08d8708005 100644 --- a/library/cpp/testing/benchmark/bench.cpp +++ b/library/cpp/testing/benchmark/bench.cpp @@ -1,7 +1,7 @@ #include "bench.h" -#include <contrib/libs/re2/re2/re2.h> - +#include <contrib/libs/re2/re2/re2.h> + #include <library/cpp/colorizer/output.h> #include <library/cpp/getopt/small/last_getopt.h> #include <library/cpp/json/json_value.h> @@ -9,7 +9,7 @@ #include <library/cpp/threading/poor_man_openmp/thread_helper.h> #include <util/system/hp_timer.h> -#include <util/system/info.h> +#include <util/system/info.h> #include <util/stream/output.h> #include <util/datetime/base.h> #include <util/random/random.h> @@ -26,7 +26,7 @@ #include <util/system/yield.h> using re2::RE2; - + using namespace NBench; using namespace NColorizer; using namespace NLastGetopt; @@ -47,7 +47,7 @@ namespace { }; struct ITestRunner: public TIntrusiveListItem<ITestRunner> { - virtual ~ITestRunner() = default; + virtual ~ITestRunner() = default; void Register(); virtual TStringBuf Name() const noexcept = 0; @@ -278,115 +278,115 @@ namespace { F(params); }, opts.TimeBudget, *this); } - - enum EOutFormat { - F_CONSOLE = 0 /* "console" */, + + enum EOutFormat { + F_CONSOLE = 0 /* "console" */, F_CSV /* "csv" */, F_JSON /* "json" */ - }; - + }; + TAdaptiveLock STDOUT_LOCK; - + struct IReporter { - virtual void Report(TResult&& result) = 0; - - virtual void Finish() { - } - - virtual ~IReporter() { - } - }; - + virtual void Report(TResult&& result) = 0; + + virtual void Finish() { + } + + virtual ~IReporter() { + } + }; + class TConsoleReporter: public IReporter { - public: + public: ~TConsoleReporter() override { - } - - void Report(TResult&& r) override { - with_lock (STDOUT_LOCK) { - Cout << r; - } - } - }; - + } + + void Report(TResult&& r) override { + with_lock (STDOUT_LOCK) { + Cout << r; + } + } + }; + class TCSVReporter: public IReporter { - public: - TCSVReporter() { + public: + TCSVReporter() { Cout << "Name\tSamples\tIterations\tRun_time\tPer_iteration_sec\tPer_iteration_cycles" << Endl; - } - + } + ~TCSVReporter() override { - } - - void Report(TResult&& r) override { - with_lock (STDOUT_LOCK) { - Cout << r.TestName - << '\t' << r.Samples - << '\t' << r.Iterations - << '\t' << r.RunTime; - - Cout << '\t'; - if (r.CyclesPerIteration) { - Cout << TCycleTimer::FmtTime(*r.CyclesPerIteration); - } else { - Cout << '-'; - } - - Cout << '\t'; - if (r.SecondsPerIteration) { - Cout << DoFmtTime(*r.SecondsPerIteration); - } else { - Cout << '-'; - } - - Cout << Endl; - } - } - }; - + } + + void Report(TResult&& r) override { + with_lock (STDOUT_LOCK) { + Cout << r.TestName + << '\t' << r.Samples + << '\t' << r.Iterations + << '\t' << r.RunTime; + + Cout << '\t'; + if (r.CyclesPerIteration) { + Cout << TCycleTimer::FmtTime(*r.CyclesPerIteration); + } else { + Cout << '-'; + } + + Cout << '\t'; + if (r.SecondsPerIteration) { + Cout << DoFmtTime(*r.SecondsPerIteration); + } else { + Cout << '-'; + } + + Cout << Endl; + } + } + }; + class TJSONReporter: public IReporter { - public: + public: ~TJSONReporter() override { - } - - void Report(TResult&& r) override { - with_lock (ResultsLock_) { - Results_.emplace_back(std::move(r)); - } - } - - void Finish() override { - NJson::TJsonValue report; - auto& bench = report["benchmark"]; - bench.SetType(NJson::JSON_ARRAY); - - NJson::TJsonValue benchReport; - - for (const auto& result : Results_) { - NJson::TJsonValue{}.Swap(benchReport); - benchReport["name"] = result.TestName; - benchReport["samples"] = result.Samples; - benchReport["run_time"] = result.RunTime; - - if (result.CyclesPerIteration) { - benchReport["per_iteration_cycles"] = *result.CyclesPerIteration; - } - - if (result.SecondsPerIteration) { - benchReport["per_iteration_secons"] = *result.SecondsPerIteration; - } - - bench.AppendValue(benchReport); - } - - Cout << report << Endl; - } - - private: - TAdaptiveLock ResultsLock_; + } + + void Report(TResult&& r) override { + with_lock (ResultsLock_) { + Results_.emplace_back(std::move(r)); + } + } + + void Finish() override { + NJson::TJsonValue report; + auto& bench = report["benchmark"]; + bench.SetType(NJson::JSON_ARRAY); + + NJson::TJsonValue benchReport; + + for (const auto& result : Results_) { + NJson::TJsonValue{}.Swap(benchReport); + benchReport["name"] = result.TestName; + benchReport["samples"] = result.Samples; + benchReport["run_time"] = result.RunTime; + + if (result.CyclesPerIteration) { + benchReport["per_iteration_cycles"] = *result.CyclesPerIteration; + } + + if (result.SecondsPerIteration) { + benchReport["per_iteration_secons"] = *result.SecondsPerIteration; + } + + bench.AppendValue(benchReport); + } + + Cout << report << Endl; + } + + private: + TAdaptiveLock ResultsLock_; TVector<TResult> Results_; - }; - + }; + class TOrderedReporter: public IReporter { public: TOrderedReporter(THolder<IReporter> slave) @@ -421,22 +421,22 @@ namespace { }; THolder<IReporter> MakeReporter(const EOutFormat type) { - switch (type) { - case F_CONSOLE: - return MakeHolder<TConsoleReporter>(); - - case F_CSV: - return MakeHolder<TCSVReporter>(); + switch (type) { + case F_CONSOLE: + return MakeHolder<TConsoleReporter>(); + + case F_CSV: + return MakeHolder<TCSVReporter>(); - case F_JSON: - return MakeHolder<TJSONReporter>(); + case F_JSON: + return MakeHolder<TJSONReporter>(); default: break; - } + } return MakeHolder<TConsoleReporter>(); // make compiler happy - } + } THolder<IReporter> MakeOrderedReporter(const EOutFormat type) { return MakeHolder<TOrderedReporter>(MakeReporter(type)); @@ -448,24 +448,24 @@ namespace { } } } - -template <> -EOutFormat FromStringImpl<EOutFormat>(const char* data, size_t len) { - const auto s = TStringBuf{data, len}; + +template <> +EOutFormat FromStringImpl<EOutFormat>(const char* data, size_t len) { + const auto s = TStringBuf{data, len}; if (TStringBuf("console") == s) { - return F_CONSOLE; + return F_CONSOLE; } else if (TStringBuf("csv") == s) { - return F_CSV; + return F_CSV; } else if (TStringBuf("json") == s) { - return F_JSON; - } - - ythrow TFromStringException{} << "failed to convert '" << s << '\''; + return F_JSON; + } + + ythrow TFromStringException{} << "failed to convert '" << s << '\''; } template <> -void Out<TResult>(IOutputStream& out, const TResult& r) { +void Out<TResult>(IOutputStream& out, const TResult& r) { out << "----------- " << LightRed() << r.TestName << Old() << " ---------------" << Endl << " samples: " << White() << r.Samples << Old() << Endl << " iterations: " << White() << r.Iterations << Old() << Endl @@ -482,9 +482,9 @@ void Out<TResult>(IOutputStream& out, const TResult& r) { } NCpu::TRegistar::TRegistar(const char* name, TUserFunc func) { - static_assert(sizeof(TCpuBenchmark) + alignof(TCpuBenchmark) < sizeof(Buf), "fix Buf size"); + static_assert(sizeof(TCpuBenchmark) + alignof(TCpuBenchmark) < sizeof(Buf), "fix Buf size"); - new (AlignUp(Buf, alignof(TCpuBenchmark))) TCpuBenchmark(name, func); + new (AlignUp(Buf, alignof(TCpuBenchmark))) TCpuBenchmark(name, func); } namespace { @@ -496,36 +496,36 @@ namespace { opts.AddLongOption('b', "budget") .StoreResult(&TimeBudget) - .RequiredArgument("SEC") + .RequiredArgument("SEC") .Optional() .Help("overall time budget"); opts.AddLongOption('l', "list") - .NoArgument() - .StoreValue(&ListTests, true) + .NoArgument() + .StoreValue(&ListTests, true) .Help("list all tests"); opts.AddLongOption('t', "threads") .StoreResult(&Threads) - .OptionalValue(ToString((NSystemInfo::CachedNumberOfCpus() + 1) / 2), "JOBS") - .DefaultValue("1") + .OptionalValue(ToString((NSystemInfo::CachedNumberOfCpus() + 1) / 2), "JOBS") + .DefaultValue("1") .Help("run benchmarks in parallel"); - opts.AddLongOption('f', "format") + opts.AddLongOption('f', "format") .AddLongName("benchmark_format") - .StoreResult(&OutFormat) - .RequiredArgument("FORMAT") - .DefaultValue("console") - .Help("output format (console|csv|json)"); - - opts.SetFreeArgDefaultTitle("REGEXP", "RE2 regular expression to filter tests"); - - const TOptsParseResult parseResult{&opts, argc, argv}; - - for (const auto& regexp : parseResult.GetFreeArgs()) { + .StoreResult(&OutFormat) + .RequiredArgument("FORMAT") + .DefaultValue("console") + .Help("output format (console|csv|json)"); + + opts.SetFreeArgDefaultTitle("REGEXP", "RE2 regular expression to filter tests"); + + const TOptsParseResult parseResult{&opts, argc, argv}; + + for (const auto& regexp : parseResult.GetFreeArgs()) { Filters.push_back(MakeHolder<RE2>(regexp.data(), RE2::Quiet)); - Y_ENSURE(Filters.back()->ok(), "incorrect RE2 expression '" << regexp << "'"); - } + Y_ENSURE(Filters.back()->ok(), "incorrect RE2 expression '" << regexp << "'"); + } } bool MatchFilters(const TStringBuf& name) const { @@ -533,72 +533,72 @@ namespace { return true; } - for (auto&& re : Filters) { + for (auto&& re : Filters) { if (RE2::FullMatchN({name.data(), name.size()}, *re, nullptr, 0)) { - return true; - } - } - - return false; - } - + return true; + } + } + + return false; + } + bool ListTests = false; double TimeBudget = -1.0; TVector<THolder<RE2>> Filters; size_t Threads = 0; - EOutFormat OutFormat; + EOutFormat OutFormat; }; } -int NBench::Main(int argc, char** argv) { - const TProgOpts opts(argc, argv); +int NBench::Main(int argc, char** argv) { + const TProgOpts opts(argc, argv); TVector<ITestRunner*> tests; - - for (auto&& it : Tests()) { - if (opts.MatchFilters(it.Name())) { - tests.push_back(&it); + + for (auto&& it : Tests()) { + if (opts.MatchFilters(it.Name())) { + tests.push_back(&it); } - } + } EnumerateTests(tests); - if (opts.ListTests) { - for (const auto* const it : tests) { - Cout << it->Name() << Endl; + if (opts.ListTests) { + for (const auto* const it : tests) { + Cout << it->Name() << Endl; } - return 0; - } + return 0; + } - if (!tests) { - return 0; - } + if (!tests) { + return 0; + } - double timeBudget = opts.TimeBudget; + double timeBudget = opts.TimeBudget; - if (timeBudget < 0) { + if (timeBudget < 0) { timeBudget = 5.0 * tests.size(); - } + } const TOptions testOpts = {timeBudget / tests.size()}; const auto reporter = MakeOrderedReporter(opts.OutFormat); std::function<void(ITestRunner**)> func = [&](ITestRunner** it) { - auto&& res = (*it)->Run(testOpts); + auto&& res = (*it)->Run(testOpts); - reporter->Report(std::move(res)); - }; - - if (opts.Threads > 1) { - NYmp::SetThreadCount(opts.Threads); + reporter->Report(std::move(res)); + }; + + if (opts.Threads > 1) { + NYmp::SetThreadCount(opts.Threads); NYmp::ParallelForStaticChunk(tests.data(), tests.data() + tests.size(), 1, func); - } else { - for (auto it : tests) { - func(&it); - } + } else { + for (auto it : tests) { + func(&it); + } } - - reporter->Finish(); - - return 0; + + reporter->Finish(); + + return 0; } diff --git a/library/cpp/testing/benchmark/bench.h b/library/cpp/testing/benchmark/bench.h index 5773fc1534..21551ad0dd 100644 --- a/library/cpp/testing/benchmark/bench.h +++ b/library/cpp/testing/benchmark/bench.h @@ -26,62 +26,62 @@ namespace NBench { /** * Functions that states "I can read and write everywhere in memory". - * - * Use it to prevent optimizer from reordering or discarding memory writes prior to it's call, - * and force memory reads after it's call. - */ - void Clobber(); - + * + * Use it to prevent optimizer from reordering or discarding memory writes prior to it's call, + * and force memory reads after it's call. + */ + void Clobber(); + /** * Forces whatever `p` points to be in memory and not in register. - * - * @param Pointer to data. - */ - template <typename T> - void Escape(T* p); - -#if defined(__GNUC__) - Y_FORCE_INLINE void Clobber() { + * + * @param Pointer to data. + */ + template <typename T> + void Escape(T* p); + +#if defined(__GNUC__) + Y_FORCE_INLINE void Clobber() { asm volatile("" : : : "memory"); - } + } #elif defined(_MSC_VER) Y_FORCE_INLINE void Clobber() { _ReadWriteBarrier(); } -#else - Y_FORCE_INLINE void Clobber() { - } -#endif - -#if defined(__GNUC__) - template <typename T> - Y_FORCE_INLINE void Escape(T* p) { +#else + Y_FORCE_INLINE void Clobber() { + } +#endif + +#if defined(__GNUC__) + template <typename T> + Y_FORCE_INLINE void Escape(T* p) { asm volatile("" : : "g"(p) : "memory"); - } -#else - template <typename T> - Y_FORCE_INLINE void Escape(T*) { - } -#endif - + } +#else + template <typename T> + Y_FORCE_INLINE void Escape(T*) { + } +#endif + /** * Use this function to prevent unused variables elimination. * * @param Unused variable (e.g. return value of benchmarked function). */ - template <typename T> + template <typename T> Y_FORCE_INLINE void DoNotOptimize(T&& datum) { ::DoNotOptimizeAway(std::forward<T>(datum)); } - - int Main(int argc, char** argv); + + int Main(int argc, char** argv); } #define Y_CPU_BENCHMARK(name, cnt) \ diff --git a/library/cpp/testing/benchmark/examples/main.cpp b/library/cpp/testing/benchmark/examples/main.cpp index 745e636d4c..ddd8b05ffc 100644 --- a/library/cpp/testing/benchmark/examples/main.cpp +++ b/library/cpp/testing/benchmark/examples/main.cpp @@ -120,9 +120,9 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufVal1, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); + NBench::Escape(&x); Y_DO_NOT_OPTIMIZE_AWAY(FS1(x)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -131,9 +131,9 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufRef1, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); + NBench::Escape(&x); Y_DO_NOT_OPTIMIZE_AWAY(FS2(x)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -143,10 +143,10 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufVal2, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); - NBench::Escape(&y); + NBench::Escape(&x); + NBench::Escape(&y); Y_DO_NOT_OPTIMIZE_AWAY(FS1_2(x, y)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -156,10 +156,10 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufRef2, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); - NBench::Escape(&y); + NBench::Escape(&x); + NBench::Escape(&y); Y_DO_NOT_OPTIMIZE_AWAY(FS2_2(x, y)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -181,35 +181,35 @@ Y_CPU_BENCHMARK(FunctionCallCost_TwoArg, iface) { Y_DO_NOT_OPTIMIZE_AWAY(FFF(i, i)); } } - -/* An example of incorrect benchmark. As of r2581591 Clang 3.7 produced following assembly: - * @code - * │ push %rbp - * │ mov %rsp,%rbp - * │ push %rbx - * │ push %rax - * │ mov (%rdi),%rbx - * │ test %rbx,%rbx - * │ ↓ je 25 - * │ xor %edi,%edi - * │ xor %esi,%esi + +/* An example of incorrect benchmark. As of r2581591 Clang 3.7 produced following assembly: + * @code + * │ push %rbp + * │ mov %rsp,%rbp + * │ push %rbx + * │ push %rax + * │ mov (%rdi),%rbx + * │ test %rbx,%rbx + * │ ↓ je 25 + * │ xor %edi,%edi + * │ xor %esi,%esi * │ → callq FS1(TBasicStringBuf<char, std::char_traits<char - * │ nop - * 100.00 │20:┌─→dec %rbx - * │ └──jne 20 - * │25: add $0x8,%rsp - * │ pop %rbx - * │ pop %rbp - * │ ← retq - * @endcode - * - * So, this benchmark is measuring empty loop! - */ -Y_CPU_BENCHMARK(Incorrect_FunctionCallCost_StringBufVal1, iface) { - TStringBuf x; - - for (auto i : xrange<size_t>(0, iface.Iterations())) { - (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(FS1(x)); - } -} + * │ nop + * 100.00 │20:┌─→dec %rbx + * │ └──jne 20 + * │25: add $0x8,%rsp + * │ pop %rbx + * │ pop %rbp + * │ ← retq + * @endcode + * + * So, this benchmark is measuring empty loop! + */ +Y_CPU_BENCHMARK(Incorrect_FunctionCallCost_StringBufVal1, iface) { + TStringBuf x; + + for (auto i : xrange<size_t>(0, iface.Iterations())) { + (void)i; + Y_DO_NOT_OPTIMIZE_AWAY(FS1(x)); + } +} diff --git a/library/cpp/testing/benchmark/examples/metrics/main.py b/library/cpp/testing/benchmark/examples/metrics/main.py index d826450400..8f9d9d06ae 100644 --- a/library/cpp/testing/benchmark/examples/metrics/main.py +++ b/library/cpp/testing/benchmark/examples/metrics/main.py @@ -1,7 +1,7 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark( +import yatest.common as yc + + +def test_export_metrics(metrics): + metrics.set_benchmark(yc.execute_benchmark( 'library/cpp/testing/benchmark/examples/examples', - threads=8)) + threads=8)) diff --git a/library/cpp/testing/benchmark/examples/metrics/ya.make b/library/cpp/testing/benchmark/examples/metrics/ya.make index a2c773a2d0..a9dbdca9fa 100644 --- a/library/cpp/testing/benchmark/examples/metrics/ya.make +++ b/library/cpp/testing/benchmark/examples/metrics/ya.make @@ -1,20 +1,20 @@ -OWNER( - pg - yazevnul -) - +OWNER( + pg + yazevnul +) + PY2TEST() - + SIZE(LARGE) - -TAG( + +TAG( ya:force_sandbox - sb:intel_e5_2660v1 + sb:intel_e5_2660v1 ya:fat -) - +) + TEST_SRCS(main.py) - + DEPENDS(library/cpp/testing/benchmark/examples) - -END() + +END() diff --git a/library/cpp/testing/benchmark/examples/ya.make b/library/cpp/testing/benchmark/examples/ya.make index d0d5bdca2c..7e696e127a 100644 --- a/library/cpp/testing/benchmark/examples/ya.make +++ b/library/cpp/testing/benchmark/examples/ya.make @@ -1,8 +1,8 @@ -OWNER( - pg - yazevnul -) - +OWNER( + pg + yazevnul +) + Y_BENCHMARK() SRCS( diff --git a/library/cpp/testing/benchmark/main/main.cpp b/library/cpp/testing/benchmark/main/main.cpp index b464c79023..aabcb89c43 100644 --- a/library/cpp/testing/benchmark/main/main.cpp +++ b/library/cpp/testing/benchmark/main/main.cpp @@ -1,16 +1,16 @@ #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/yexception.h> -#include <util/stream/output.h> - -#include <cstdlib> - -int main(int argc, char** argv) { - try { - return NBench::Main(argc, argv); + +#include <util/generic/yexception.h> +#include <util/stream/output.h> + +#include <cstdlib> + +int main(int argc, char** argv) { + try { + return NBench::Main(argc, argv); } catch (...) { - Cerr << CurrentExceptionMessage() << Endl; - } + Cerr << CurrentExceptionMessage() << Endl; + } return EXIT_FAILURE; -} +} diff --git a/library/cpp/testing/benchmark/main/ya.make b/library/cpp/testing/benchmark/main/ya.make index a434d42675..d00cdcf9fc 100644 --- a/library/cpp/testing/benchmark/main/ya.make +++ b/library/cpp/testing/benchmark/main/ya.make @@ -1,16 +1,16 @@ -LIBRARY() - +LIBRARY() + OWNER( pg yazevnul ) - -SRCS( + +SRCS( GLOBAL main.cpp -) - -PEERDIR( +) + +PEERDIR( library/cpp/testing/benchmark -) - -END() +) + +END() diff --git a/library/cpp/testing/benchmark/ya.make b/library/cpp/testing/benchmark/ya.make index 661e160238..f42be80698 100644 --- a/library/cpp/testing/benchmark/ya.make +++ b/library/cpp/testing/benchmark/ya.make @@ -4,19 +4,19 @@ OWNER( pg yazevnul ) - -SRCS( + +SRCS( bench.cpp dummy.cpp -) - -PEERDIR( - contrib/libs/re2 +) + +PEERDIR( + contrib/libs/re2 library/cpp/colorizer library/cpp/getopt/small library/cpp/json library/cpp/linear_regression library/cpp/threading/poor_man_openmp -) - -END() +) + +END() diff --git a/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp b/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp index 9d0a72fb47..97f19050e4 100644 --- a/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp +++ b/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp @@ -27,8 +27,8 @@ public: using namespace testing; -Y_UNIT_TEST_SUITE(TExampleGMockTest) { - Y_UNIT_TEST(TSimpleTest) { +Y_UNIT_TEST_SUITE(TExampleGMockTest) { + Y_UNIT_TEST(TSimpleTest) { TTestMock mock; EXPECT_CALL(mock, Func1()) .Times(AtLeast(1)); @@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) { } } - Y_UNIT_TEST(TNonExpectedCallTest) { + Y_UNIT_TEST(TNonExpectedCallTest) { TTestMock mock; EXPECT_CALL(mock, Func1()) .Times(AtMost(1)); @@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) { } } - Y_UNIT_TEST(TReturnValuesTest) { + Y_UNIT_TEST(TReturnValuesTest) { TTestMock mock; EXPECT_CALL(mock, Func2(TString("1"))) .WillOnce(Return(1)) @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) { } } - Y_UNIT_TEST(TStrictCallSequenceTest) { + Y_UNIT_TEST(TStrictCallSequenceTest) { TTestMock mock; { InSequence seq; @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) { } } - Y_UNIT_TEST(TUninterestingMethodIsFailureTest) { + Y_UNIT_TEST(TUninterestingMethodIsFailureTest) { StrictMock<TTestMock> mock; EXPECT_CALL(mock, Func1()) .Times(1); diff --git a/library/cpp/testing/unittest/checks.cpp b/library/cpp/testing/unittest/checks.cpp index 70d6bb3410..c5712ae9d2 100644 --- a/library/cpp/testing/unittest/checks.cpp +++ b/library/cpp/testing/unittest/checks.cpp @@ -1,5 +1,5 @@ #include <util/generic/string.h> -#include <util/string/type.h> +#include <util/string/type.h> bool CheckExceptionMessage(const char* msg, TString& err) { static const char* badMsg[] = { @@ -10,7 +10,7 @@ bool CheckExceptionMessage(const char* msg, TString& err) { err.clear(); - if (msg == nullptr) { + if (msg == nullptr) { err = "Error message is null"; return false; } @@ -20,8 +20,8 @@ bool CheckExceptionMessage(const char* msg, TString& err) { return false; } - for (auto& i : badMsg) { - if (strstr(msg, i) != nullptr) { + for (auto& i : badMsg) { + if (strstr(msg, i) != nullptr) { err = "Invalid error message: " + TString(msg); return false; } diff --git a/library/cpp/testing/unittest/example_ut.cpp b/library/cpp/testing/unittest/example_ut.cpp index e53d6a30fb..bcc1ce33f0 100644 --- a/library/cpp/testing/unittest/example_ut.cpp +++ b/library/cpp/testing/unittest/example_ut.cpp @@ -4,8 +4,8 @@ * just copy-paste it for good start point */ -Y_UNIT_TEST_SUITE(TUnitTest) { - Y_UNIT_TEST(TestEqual) { +Y_UNIT_TEST_SUITE(TUnitTest) { + Y_UNIT_TEST(TestEqual) { UNIT_ASSERT_EQUAL(0, 0); UNIT_ASSERT_EQUAL(1, 1); } diff --git a/library/cpp/testing/unittest/registar.cpp b/library/cpp/testing/unittest/registar.cpp index 945f70d1de..3679b768ed 100644 --- a/library/cpp/testing/unittest/registar.cpp +++ b/library/cpp/testing/unittest/registar.cpp @@ -59,7 +59,7 @@ void ::NUnitTest::SetRaiseErrorHandler(::NUnitTest::TRaiseErrorHandler handler) } void ::NUnitTest::NPrivate::SetUnittestThread(bool unittestThread) { - Y_VERIFY(UnittestThread != unittestThread, "state check"); + Y_VERIFY(UnittestThread != unittestThread, "state check"); UnittestThread = unittestThread; } diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index 8fb8f95e25..44517a0092 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -293,7 +293,7 @@ private: \ /* If you see this message - delete multiple UNIT_TEST(TestName) with same TestName. */ \ /* It's forbidden to declare same test twice because it breaks --fork-tests logic. */ \ int You_have_declared_test_##F##_multiple_times_This_is_forbidden; \ - Y_UNUSED(You_have_declared_test_##F##_multiple_times_This_is_forbidden); + Y_UNUSED(You_have_declared_test_##F##_multiple_times_This_is_forbidden); #define UNIT_TEST_RUN(F, FF, context) \ this->BeforeTest((#F)); \ @@ -914,7 +914,7 @@ public: \ #define UNIT_TEST_SUITE_REGISTRATION(T) \ static const ::NUnitTest::TTestBaseFactory<T> Y_GENERATE_UNIQUE_ID(UTREG_); -#define Y_UNIT_TEST_SUITE_IMPL_F(N, T, F) \ +#define Y_UNIT_TEST_SUITE_IMPL_F(N, T, F) \ namespace NTestSuite##N { \ class TCurrentTestCase: public F { \ }; \ @@ -982,12 +982,12 @@ public: \ } \ namespace NTestSuite##N -#define Y_UNIT_TEST_SUITE_IMPL(N, T) Y_UNIT_TEST_SUITE_IMPL_F(N, T, ::NUnitTest::TBaseTestCase) -#define Y_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, TTestBase) -#define Y_UNIT_TEST_SUITE_F(N, F) Y_UNIT_TEST_SUITE_IMPL_F(N, TTestBase, F) -#define RUSAGE_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, NUnitTest::TRusageTest, ::NUnitTest::TBaseTestCase) +#define Y_UNIT_TEST_SUITE_IMPL(N, T) Y_UNIT_TEST_SUITE_IMPL_F(N, T, ::NUnitTest::TBaseTestCase) +#define Y_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, TTestBase) +#define Y_UNIT_TEST_SUITE_F(N, F) Y_UNIT_TEST_SUITE_IMPL_F(N, TTestBase, F) +#define RUSAGE_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, NUnitTest::TRusageTest, ::NUnitTest::TBaseTestCase) -#define Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \ +#define Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \ struct TTestCase##N : public F { \ TTestCase##N() \ : F() \ @@ -1007,21 +1007,21 @@ public: \ }; \ static const TTestRegistration##N testRegistration##N; -#define Y_UNIT_TEST_IMPL(N, FF, F) \ - Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \ +#define Y_UNIT_TEST_IMPL(N, FF, F) \ + Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \ void TTestCase##N::Execute_(NUnitTest::TTestContext& ut_context Y_DECLARE_UNUSED) -#define Y_UNIT_TEST(N) Y_UNIT_TEST_IMPL(N, false, TCurrentTestCase) -#define Y_UNIT_TEST_F(N, F) Y_UNIT_TEST_IMPL(N, false, F) -#define SIMPLE_UNIT_FORKED_TEST(N) Y_UNIT_TEST_IMPL(N, true, TCurrentTestCase) +#define Y_UNIT_TEST(N) Y_UNIT_TEST_IMPL(N, false, TCurrentTestCase) +#define Y_UNIT_TEST_F(N, F) Y_UNIT_TEST_IMPL(N, false, F) +#define SIMPLE_UNIT_FORKED_TEST(N) Y_UNIT_TEST_IMPL(N, true, TCurrentTestCase) -#define Y_UNIT_TEST_SUITE_IMPLEMENTATION(N) \ +#define Y_UNIT_TEST_SUITE_IMPLEMENTATION(N) \ namespace NTestSuite##N -#define Y_UNIT_TEST_DECLARE(N) \ +#define Y_UNIT_TEST_DECLARE(N) \ struct TTestCase##N -#define Y_UNIT_TEST_FRIEND(N, T) \ +#define Y_UNIT_TEST_FRIEND(N, T) \ friend NTestSuite##N::TTestCase##T \ TString RandomString(size_t len, ui32 seed = 0); diff --git a/library/cpp/testing/unittest/registar_ut.cpp b/library/cpp/testing/unittest/registar_ut.cpp index 46b455281b..1f36d53abb 100644 --- a/library/cpp/testing/unittest/registar_ut.cpp +++ b/library/cpp/testing/unittest/registar_ut.cpp @@ -1,7 +1,7 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { - Y_UNIT_TEST(Assert) { +Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { + Y_UNIT_TEST(Assert) { auto unitAssert = [] { UNIT_ASSERT(false); }; @@ -10,7 +10,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT(true); } - Y_UNIT_TEST(TypesEqual) { + Y_UNIT_TEST(TypesEqual) { auto typesEqual = [] { UNIT_ASSERT_TYPES_EQUAL(int, long); }; @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_TYPES_EQUAL(TString, TString); } - Y_UNIT_TEST(DoublesEqual) { + Y_UNIT_TEST(DoublesEqual) { auto doublesEqual = [](double d1, double d2, double precision) { UNIT_ASSERT_DOUBLES_EQUAL(d1, d2, precision); }; @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_DOUBLES_EQUAL(nan, nan, 0.1); } - Y_UNIT_TEST(StringsEqual) { + Y_UNIT_TEST(StringsEqual) { auto stringsEqual = [](auto s1, auto s2) { UNIT_ASSERT_STRINGS_EQUAL(s1, s2); }; @@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_STRINGS_EQUAL("", static_cast<const char*>(nullptr)); } - Y_UNIT_TEST(StringContains) { + Y_UNIT_TEST(StringContains) { auto stringContains = [](auto s, auto substr) { UNIT_ASSERT_STRING_CONTAINS(s, substr); }; @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_STRING_CONTAINS("lurkmore", "more"); } - Y_UNIT_TEST(NoDiff) { + Y_UNIT_TEST(NoDiff) { auto noDiff = [](auto s1, auto s2) { UNIT_ASSERT_NO_DIFF(s1, s2); }; @@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_NO_DIFF("a", "a"); } - Y_UNIT_TEST(StringsUnequal) { + Y_UNIT_TEST(StringsUnequal) { auto stringsUnequal = [](auto s1, auto s2) { UNIT_ASSERT_STRINGS_UNEQUAL(s1, s2); }; @@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_STRINGS_UNEQUAL(TStringBuf("C++"), TString("python")); } - Y_UNIT_TEST(Equal) { + Y_UNIT_TEST(Equal) { auto equal = [](auto v1, auto v2) { UNIT_ASSERT_EQUAL(v1, v2); }; @@ -114,7 +114,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_EQUAL(55, 55); } - Y_UNIT_TEST(Unequal) { + Y_UNIT_TEST(Unequal) { auto unequal = [](auto v1, auto v2) { UNIT_ASSERT_UNEQUAL(v1, v2); }; @@ -235,7 +235,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_GE(100ul, static_cast<unsigned short>(42)); } - Y_UNIT_TEST(ValuesEqual) { + Y_UNIT_TEST(ValuesEqual) { auto valuesEqual = [](auto v1, auto v2) { UNIT_ASSERT_VALUES_EQUAL(v1, v2); }; @@ -246,7 +246,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_VALUES_EQUAL(1.0, 1.0); } - Y_UNIT_TEST(ValuesUnequal) { + Y_UNIT_TEST(ValuesUnequal) { auto valuesUnequal = [](auto v1, auto v2) { UNIT_ASSERT_VALUES_UNEQUAL(v1, v2); }; @@ -325,7 +325,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { } }; - Y_UNIT_TEST(Exception) { + Y_UNIT_TEST(Exception) { UNIT_ASSERT_TEST_FAILS(TTestException("", false).AssertException<TTestException>()); UNIT_ASSERT_TEST_FAILS(TTestException().AssertException<TOtherTestException>()); @@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_EXCEPTION(TTestException().Throw(), TTestException); } - Y_UNIT_TEST(ExceptionAssertionContainsOtherExceptionMessage) { + Y_UNIT_TEST(ExceptionAssertionContainsOtherExceptionMessage) { NUnitTest::TUnitTestFailChecker checker; { auto guard = checker.InvokeGuard(); @@ -343,14 +343,14 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_STRING_CONTAINS(checker.Msg(), "custom exception message"); } - Y_UNIT_TEST(NoException) { + Y_UNIT_TEST(NoException) { UNIT_ASSERT_TEST_FAILS(TTestException().AssertNoException()); UNIT_ASSERT_TEST_FAILS(TTestException().AssertNoExceptionRet()); UNIT_ASSERT_NO_EXCEPTION(TTestException("", false).Throw()); } - Y_UNIT_TEST(ExceptionContains) { + Y_UNIT_TEST(ExceptionContains) { UNIT_ASSERT_TEST_FAILS(TTestException("abc").AssertExceptionContains<TTestException>("cba")); UNIT_ASSERT_TEST_FAILS(TTestException("abc").AssertExceptionContains<TTestException>(TStringBuf("cba"))); UNIT_ASSERT_TEST_FAILS(TTestException("abc").AssertExceptionContains<TTestException>(TString("cba"))); diff --git a/library/cpp/testing/unittest/ut/main.cpp b/library/cpp/testing/unittest/ut/main.cpp index 13c7642dd9..e303e21e30 100644 --- a/library/cpp/testing/unittest/ut/main.cpp +++ b/library/cpp/testing/unittest/ut/main.cpp @@ -61,25 +61,25 @@ TEST(ETest, Test1) { UNIT_CHECK_GENERATED_NO_EXCEPTION(true, yexception); } -Y_UNIT_TEST_SUITE(TestSingleTestFixture) +Y_UNIT_TEST_SUITE(TestSingleTestFixture) { - Y_UNIT_TEST_F(Test3, TSimpleFixture) { + Y_UNIT_TEST_F(Test3, TSimpleFixture) { UNIT_ASSERT_EQUAL(Value, 24); } } -Y_UNIT_TEST_SUITE_F(TestSuiteFixture, TSimpleFixture) +Y_UNIT_TEST_SUITE_F(TestSuiteFixture, TSimpleFixture) { - Y_UNIT_TEST(Test1) { + Y_UNIT_TEST(Test1) { UNIT_ASSERT(Value == 24); Value = 25; } - Y_UNIT_TEST(Test2) { + Y_UNIT_TEST(Test2) { UNIT_ASSERT_EQUAL(Value, 24); } - Y_UNIT_TEST_F(Test3, TOtherFixture) { + Y_UNIT_TEST_F(Test3, TOtherFixture) { UNIT_ASSERT_EQUAL(TheAnswer, 42); } } diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp index 09605828a6..305bc6b40f 100644 --- a/library/cpp/testing/unittest/utmain.cpp +++ b/library/cpp/testing/unittest/utmain.cpp @@ -20,7 +20,7 @@ #include <util/network/init.h> #include <util/stream/file.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/string/join.h> #include <util/string/util.h> @@ -502,7 +502,7 @@ private: ythrow yexception() << "Forked test finished with unknown status"; } case TShellCommand::SHELL_RUNNING: { - Y_VERIFY(false, "This can't happen, we used sync mode, it's a bug!"); + Y_VERIFY(false, "This can't happen, we used sync mode, it's a bug!"); } case TShellCommand::SHELL_INTERNAL_ERROR: { ythrow yexception() << "Forked test failed with internal error: " << cmd.GetInternalError(); @@ -539,7 +539,7 @@ const char* const TColoredProcessor::ForkCorrectExitMsg = "--END--"; class TEnumeratingProcessor: public ITestSuiteProcessor { public: - TEnumeratingProcessor(bool verbose, IOutputStream& stream) noexcept + TEnumeratingProcessor(bool verbose, IOutputStream& stream) noexcept : Verbose_(verbose) , Stream_(stream) { @@ -564,7 +564,7 @@ public: private: bool Verbose_; - IOutputStream& Stream_; + IOutputStream& Stream_; }; #ifdef _win_ @@ -600,7 +600,7 @@ private: static const TWinEnvironment Instance; #endif // _win_ -static int DoList(bool verbose, IOutputStream& stream) { +static int DoList(bool verbose, IOutputStream& stream) { TEnumeratingProcessor eproc(verbose, stream); TTestFactory::Instance().SetProcessor(&eproc); TTestFactory::Instance().Execute(); @@ -665,8 +665,8 @@ int NUnitTest::RunMain(int argc, char** argv) { Y_DEFER { NPlugin::OnStopMain(argc, argv); }; TColoredProcessor processor(GetExecPath()); - IOutputStream* listStream = &Cout; - THolder<IOutputStream> listFile; + IOutputStream* listStream = &Cout; + THolder<IOutputStream> listFile; enum EListType { DONT_LIST, diff --git a/library/cpp/threading/atomic/bool_ut.cpp b/library/cpp/threading/atomic/bool_ut.cpp index 86ea26a23d..9481f41d8d 100644 --- a/library/cpp/threading/atomic/bool_ut.cpp +++ b/library/cpp/threading/atomic/bool_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(AtomicBool) { - Y_UNIT_TEST(ReadWrite) { +Y_UNIT_TEST_SUITE(AtomicBool) { + Y_UNIT_TEST(ReadWrite) { NAtomic::TBool v; UNIT_ASSERT_VALUES_EQUAL((bool)v, false); diff --git a/library/cpp/threading/chunk_queue/queue_ut.cpp b/library/cpp/threading/chunk_queue/queue_ut.cpp index 3913bd2545..8cb36d8dd1 100644 --- a/library/cpp/threading/chunk_queue/queue_ut.cpp +++ b/library/cpp/threading/chunk_queue/queue_ut.cpp @@ -7,8 +7,8 @@ namespace NThreading { //////////////////////////////////////////////////////////////////////////////// - Y_UNIT_TEST_SUITE(TOneOneQueueTest){ - Y_UNIT_TEST(ShouldBeEmptyAtStart){ + Y_UNIT_TEST_SUITE(TOneOneQueueTest){ + Y_UNIT_TEST(ShouldBeEmptyAtStart){ TOneOneQueue<int> queue; int result = 0; @@ -16,7 +16,7 @@ namespace NThreading { UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldReturnEntries) { +Y_UNIT_TEST(ShouldReturnEntries) { TOneOneQueue<int> queue; queue.Enqueue(1); queue.Enqueue(2); @@ -39,7 +39,7 @@ Y_UNIT_TEST(ShouldReturnEntries) { UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldStoreMultipleChunks) { +Y_UNIT_TEST(ShouldStoreMultipleChunks) { TOneOneQueue<int, 100> queue; for (int i = 0; i < 1000; ++i) { queue.Enqueue(i); @@ -57,8 +57,8 @@ Y_UNIT_TEST(ShouldStoreMultipleChunks) { //////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TManyOneQueueTest){ - Y_UNIT_TEST(ShouldBeEmptyAtStart){ +Y_UNIT_TEST_SUITE(TManyOneQueueTest){ + Y_UNIT_TEST(ShouldBeEmptyAtStart){ TManyOneQueue<int> queue; int result; @@ -66,7 +66,7 @@ UNIT_ASSERT(queue.IsEmpty()); UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldReturnEntries) { +Y_UNIT_TEST(ShouldReturnEntries) { TManyOneQueue<int> queue; queue.Enqueue(1); queue.Enqueue(2); @@ -93,8 +93,8 @@ Y_UNIT_TEST(ShouldReturnEntries) { //////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TManyManyQueueTest){ - Y_UNIT_TEST(ShouldBeEmptyAtStart){ +Y_UNIT_TEST_SUITE(TManyManyQueueTest){ + Y_UNIT_TEST(ShouldBeEmptyAtStart){ TManyManyQueue<int> queue; int result = 0; @@ -102,7 +102,7 @@ UNIT_ASSERT(queue.IsEmpty()); UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldReturnEntries) { +Y_UNIT_TEST(ShouldReturnEntries) { TManyManyQueue<int> queue; queue.Enqueue(1); queue.Enqueue(2); @@ -129,8 +129,8 @@ Y_UNIT_TEST(ShouldReturnEntries) { //////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TRelaxedManyOneQueueTest){ - Y_UNIT_TEST(ShouldBeEmptyAtStart){ +Y_UNIT_TEST_SUITE(TRelaxedManyOneQueueTest){ + Y_UNIT_TEST(ShouldBeEmptyAtStart){ TRelaxedManyOneQueue<int> queue; int result; @@ -138,7 +138,7 @@ UNIT_ASSERT(queue.IsEmpty()); UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldReturnEntries) { +Y_UNIT_TEST(ShouldReturnEntries) { TSet<int> items = {1, 2, 3}; TRelaxedManyOneQueue<int> queue; @@ -167,8 +167,8 @@ Y_UNIT_TEST(ShouldReturnEntries) { //////////////////////////////////////////////////////////////////////////////// -Y_UNIT_TEST_SUITE(TRelaxedManyManyQueueTest){ - Y_UNIT_TEST(ShouldBeEmptyAtStart){ +Y_UNIT_TEST_SUITE(TRelaxedManyManyQueueTest){ + Y_UNIT_TEST(ShouldBeEmptyAtStart){ TRelaxedManyManyQueue<int> queue; int result = 0; @@ -176,7 +176,7 @@ UNIT_ASSERT(queue.IsEmpty()); UNIT_ASSERT(!queue.Dequeue(result)); } -Y_UNIT_TEST(ShouldReturnEntries) { +Y_UNIT_TEST(ShouldReturnEntries) { TSet<int> items = {1, 2, 3}; TRelaxedManyManyQueue<int> queue; diff --git a/library/cpp/threading/equeue/equeue_ut.cpp b/library/cpp/threading/equeue/equeue_ut.cpp index a2072f9a83..9cf2aced44 100644 --- a/library/cpp/threading/equeue/equeue_ut.cpp +++ b/library/cpp/threading/equeue/equeue_ut.cpp @@ -6,7 +6,7 @@ #include <util/datetime/base.h> #include <util/generic/vector.h> -Y_UNIT_TEST_SUITE(TElasticQueueTest) { +Y_UNIT_TEST_SUITE(TElasticQueueTest) { const size_t MaxQueueSize = 20; const size_t ThreadCount = 10; const size_t N = 100000; @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(TElasticQueueTest) { //fill test -- fill queue with "endless" jobs TSystemEvent WaitEvent; - Y_UNIT_TEST(FillTest) { + Y_UNIT_TEST(FillTest) { Counters.Reset(); struct TWaitJob: public IObjectInQueue { @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TElasticQueueTest) { static size_t TryCounter; - Y_UNIT_TEST(ConcurrentTest) { + Y_UNIT_TEST(ConcurrentTest) { Counters.Reset(); TryCounter = 0; diff --git a/library/cpp/threading/future/async_ut.cpp b/library/cpp/threading/future/async_ut.cpp index 07f2a66951..a3699744e4 100644 --- a/library/cpp/threading/future/async_ut.cpp +++ b/library/cpp/threading/future/async_ut.cpp @@ -27,15 +27,15 @@ namespace NThreading { } -Y_UNIT_TEST_SUITE(Async) { - Y_UNIT_TEST(ExtensionExample) { +Y_UNIT_TEST_SUITE(Async) { + Y_UNIT_TEST(ExtensionExample) { TMySuperTaskQueue queue; auto future = NThreading::Async([]() { return 5; }, queue); future.Wait(); UNIT_ASSERT_VALUES_EQUAL(future.GetValue(), 5); } - Y_UNIT_TEST(WorksWithIMtpQueue) { + Y_UNIT_TEST(WorksWithIMtpQueue) { auto queue = MakeHolder<TThreadPool>(); queue->Start(1); @@ -44,7 +44,7 @@ Y_UNIT_TEST_SUITE(Async) { UNIT_ASSERT_VALUES_EQUAL(future.GetValue(), 5); } - Y_UNIT_TEST(ProperlyDeducesFutureType) { + Y_UNIT_TEST(ProperlyDeducesFutureType) { // Compileability test auto queue = CreateThreadPool(1); diff --git a/library/cpp/threading/future/core/future.h b/library/cpp/threading/future/core/future.h index 4ab56efb30..2e82bb953e 100644 --- a/library/cpp/threading/future/core/future.h +++ b/library/cpp/threading/future/core/future.h @@ -1,7 +1,7 @@ #pragma once -#include "fwd.h" - +#include "fwd.h" + #include <util/datetime/base.h> #include <util/generic/function.h> #include <util/generic/maybe.h> diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp index f45fc84e23..05950a568d 100644 --- a/library/cpp/threading/future/future_ut.cpp +++ b/library/cpp/threading/future/future_ut.cpp @@ -64,8 +64,8 @@ namespace { //////////////////////////////////////////////////////////////////////////////// - Y_UNIT_TEST_SUITE(TFutureTest) { - Y_UNIT_TEST(ShouldInitiallyHasNoValue) { + Y_UNIT_TEST_SUITE(TFutureTest) { + Y_UNIT_TEST(ShouldInitiallyHasNoValue) { TPromise<int> promise; UNIT_ASSERT(!promise.HasValue()); @@ -79,7 +79,7 @@ namespace { UNIT_ASSERT(!future.HasValue()); } - Y_UNIT_TEST(ShouldInitiallyHasNoValueVoid) { + Y_UNIT_TEST(ShouldInitiallyHasNoValueVoid) { TPromise<void> promise; UNIT_ASSERT(!promise.HasValue()); @@ -93,7 +93,7 @@ namespace { UNIT_ASSERT(!future.HasValue()); } - Y_UNIT_TEST(ShouldStoreValue) { + Y_UNIT_TEST(ShouldStoreValue) { TPromise<int> promise = NewPromise<int>(); promise.SetValue(123); UNIT_ASSERT(promise.HasValue()); @@ -108,7 +108,7 @@ namespace { UNIT_ASSERT_EQUAL(future.GetValue(), 345); } - Y_UNIT_TEST(ShouldStoreValueVoid) { + Y_UNIT_TEST(ShouldStoreValueVoid) { TPromise<void> promise = NewPromise(); promise.SetValue(); UNIT_ASSERT(promise.HasValue()); @@ -151,7 +151,7 @@ namespace { } }; - Y_UNIT_TEST(ShouldInvokeCallback) { + Y_UNIT_TEST(ShouldInvokeCallback) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -163,7 +163,7 @@ namespace { UNIT_ASSERT_EQUAL(callback.Value, 123 + 456); } - Y_UNIT_TEST(ShouldApplyFunc) { + Y_UNIT_TEST(ShouldApplyFunc) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -175,7 +175,7 @@ namespace { UNIT_ASSERT_EQUAL(callback.Value, 123 + 456); } - Y_UNIT_TEST(ShouldApplyVoidFunc) { + Y_UNIT_TEST(ShouldApplyVoidFunc) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -186,7 +186,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldApplyFutureFunc) { + Y_UNIT_TEST(ShouldApplyFutureFunc) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -198,7 +198,7 @@ namespace { UNIT_ASSERT_EQUAL(callback.Value, 123 + 456); } - Y_UNIT_TEST(ShouldApplyFutureVoidFunc) { + Y_UNIT_TEST(ShouldApplyFutureVoidFunc) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -212,7 +212,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldIgnoreResultIfAsked) { + Y_UNIT_TEST(ShouldIgnoreResultIfAsked) { TPromise<int> promise = NewPromise<int>(); TTestCallback callback(123); @@ -225,7 +225,7 @@ namespace { class TCustomException: public yexception { }; - Y_UNIT_TEST(ShouldRethrowException) { + Y_UNIT_TEST(ShouldRethrowException) { TPromise<int> promise = NewPromise<int>(); try { ythrow TCustomException(); @@ -335,7 +335,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitAnyVector) { + Y_UNIT_TEST(ShouldWaitAnyVector) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); @@ -372,7 +372,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitAnyList) { + Y_UNIT_TEST(ShouldWaitAnyList) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); @@ -390,14 +390,14 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitAnyVectorEmpty) { + Y_UNIT_TEST(ShouldWaitAnyVectorEmpty) { TVector<TFuture<void>> promises; TFuture<void> future = WaitAny(promises); UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitAny) { + Y_UNIT_TEST(ShouldWaitAny) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); @@ -411,7 +411,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldStoreTypesWithoutDefaultConstructor) { + Y_UNIT_TEST(ShouldStoreTypesWithoutDefaultConstructor) { // compileability test struct TRec { explicit TRec(int) { @@ -426,7 +426,7 @@ namespace { Y_UNUSED(rec); } - Y_UNIT_TEST(ShouldStoreMovableTypes) { + Y_UNIT_TEST(ShouldStoreMovableTypes) { // compileability test struct TRec : TMoveOnly { explicit TRec(int) { @@ -441,7 +441,7 @@ namespace { Y_UNUSED(rec); } - Y_UNIT_TEST(ShouldMoveMovableTypes) { + Y_UNIT_TEST(ShouldMoveMovableTypes) { // compileability test struct TRec : TMoveOnly { explicit TRec(int) { @@ -456,7 +456,7 @@ namespace { Y_UNUSED(rec); } - Y_UNIT_TEST(ShouldNotExtractAfterGet) { + Y_UNIT_TEST(ShouldNotExtractAfterGet) { TPromise<int> promise = NewPromise<int>(); promise.SetValue(123); UNIT_ASSERT(promise.HasValue()); @@ -464,7 +464,7 @@ namespace { UNIT_CHECK_GENERATED_EXCEPTION(promise.ExtractValue(), TFutureException); } - Y_UNIT_TEST(ShouldNotGetAfterExtract) { + Y_UNIT_TEST(ShouldNotGetAfterExtract) { TPromise<int> promise = NewPromise<int>(); promise.SetValue(123); UNIT_ASSERT(promise.HasValue()); @@ -472,7 +472,7 @@ namespace { UNIT_CHECK_GENERATED_EXCEPTION(promise.GetValue(), TFutureException); } - Y_UNIT_TEST(ShouldNotExtractAfterExtract) { + Y_UNIT_TEST(ShouldNotExtractAfterExtract) { TPromise<int> promise = NewPromise<int>(); promise.SetValue(123); UNIT_ASSERT(promise.HasValue()); diff --git a/library/cpp/threading/future/fwd.cpp b/library/cpp/threading/future/fwd.cpp index 2261ef316c..4214b6df83 100644 --- a/library/cpp/threading/future/fwd.cpp +++ b/library/cpp/threading/future/fwd.cpp @@ -1 +1 @@ -#include "fwd.h" +#include "fwd.h" diff --git a/library/cpp/threading/future/fwd.h b/library/cpp/threading/future/fwd.h index b51d9b0019..0cd25dd288 100644 --- a/library/cpp/threading/future/fwd.h +++ b/library/cpp/threading/future/fwd.h @@ -1,8 +1,8 @@ -#pragma once - +#pragma once + #include "core/fwd.h" -namespace NThreading { - template <typename TR = void, bool IgnoreException = false> - class TLegacyFuture; -} +namespace NThreading { + template <typename TR = void, bool IgnoreException = false> + class TLegacyFuture; +} diff --git a/library/cpp/threading/future/legacy_future.h b/library/cpp/threading/future/legacy_future.h index 9bb126e76b..6f1eabad73 100644 --- a/library/cpp/threading/future/legacy_future.h +++ b/library/cpp/threading/future/legacy_future.h @@ -1,6 +1,6 @@ #pragma once -#include "fwd.h" +#include "fwd.h" #include "future.h" #include <util/thread/factory.h> @@ -8,7 +8,7 @@ #include <functional> namespace NThreading { - template <typename TR, bool IgnoreException> + template <typename TR, bool IgnoreException> class TLegacyFuture: public IThreadFactory::IThreadAble, TNonCopyable { public: typedef TR(TFunctionSignature)(); diff --git a/library/cpp/threading/future/legacy_future_ut.cpp b/library/cpp/threading/future/legacy_future_ut.cpp index b0c9dc21aa..ff63db1725 100644 --- a/library/cpp/threading/future/legacy_future_ut.cpp +++ b/library/cpp/threading/future/legacy_future_ut.cpp @@ -3,12 +3,12 @@ #include <library/cpp/testing/unittest/registar.h> namespace NThreading { - Y_UNIT_TEST_SUITE(TLegacyFutureTest) { + Y_UNIT_TEST_SUITE(TLegacyFutureTest) { int intf() { return 17; } - Y_UNIT_TEST(TestIntFunction) { + Y_UNIT_TEST(TestIntFunction) { TLegacyFuture<int> f((&intf)); UNIT_ASSERT_VALUES_EQUAL(17, f.Get()); } @@ -19,7 +19,7 @@ namespace NThreading { r = 18; } - Y_UNIT_TEST(TestVoidFunction) { + Y_UNIT_TEST(TestVoidFunction) { r = 0; TLegacyFuture<> f((&voidf)); f.Get(); @@ -39,7 +39,7 @@ namespace NThreading { } }; - Y_UNIT_TEST(TestMethod) { + Y_UNIT_TEST(TestMethod) { TLegacyFuture<int> f11(std::bind(&TSampleClass::Calc, TSampleClass(3))); UNIT_ASSERT_VALUES_EQUAL(4, f11.Get()); @@ -57,7 +57,7 @@ namespace NThreading { struct TSomeThreadPool: public IThreadFactory {}; - Y_UNIT_TEST(TestFunction) { + Y_UNIT_TEST(TestFunction) { std::function<int()> f((&intf)); UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f).Get()); diff --git a/library/cpp/threading/future/wait/wait.h b/library/cpp/threading/future/wait/wait.h index 6497574cec..6ff7d57baa 100644 --- a/library/cpp/threading/future/wait/wait.h +++ b/library/cpp/threading/future/wait/wait.h @@ -1,7 +1,7 @@ #pragma once -#include "fwd.h" - +#include "fwd.h" + #include <library/cpp/threading/future/core/future.h> #include <library/cpp/threading/future/wait/wait_group.h> diff --git a/library/cpp/threading/future/ya.make b/library/cpp/threading/future/ya.make index d3ad13fa8e..6591031f46 100644 --- a/library/cpp/threading/future/ya.make +++ b/library/cpp/threading/future/ya.make @@ -1,14 +1,14 @@ -OWNER( - g:rtmr -) - +OWNER( + g:rtmr +) + LIBRARY() SRCS( async.cpp core/future.cpp core/fwd.cpp - fwd.cpp + fwd.cpp wait/fwd.cpp wait/wait.cpp wait/wait_group.cpp diff --git a/library/cpp/threading/local_executor/local_executor.cpp b/library/cpp/threading/local_executor/local_executor.cpp index 6e62d09d85..1d3fbb4bf4 100644 --- a/library/cpp/threading/local_executor/local_executor.cpp +++ b/library/cpp/threading/local_executor/local_executor.cpp @@ -1,17 +1,17 @@ #include "local_executor.h" #include <library/cpp/threading/future/future.h> - -#include <util/generic/utility.h> -#include <util/system/atomic.h> -#include <util/system/event.h> + +#include <util/generic/utility.h> +#include <util/system/atomic.h> +#include <util/system/event.h> #include <util/system/thread.h> -#include <util/system/tls.h> +#include <util/system/tls.h> #include <util/system/yield.h> -#include <util/thread/lfqueue.h> +#include <util/thread/lfqueue.h> + +#include <utility> -#include <utility> - #ifdef _win_ static void RegularYield() { } @@ -23,11 +23,11 @@ static void RegularYield() { } #endif -namespace { - struct TFunctionWrapper : NPar::ILocallyExecutable { - NPar::TLocallyExecutableFunction Exec; - TFunctionWrapper(NPar::TLocallyExecutableFunction exec) - : Exec(std::move(exec)) +namespace { + struct TFunctionWrapper : NPar::ILocallyExecutable { + NPar::TLocallyExecutableFunction Exec; + TFunctionWrapper(NPar::TLocallyExecutableFunction exec) + : Exec(std::move(exec)) { } void LocalExec(int id) override { @@ -35,15 +35,15 @@ namespace { } }; - class TFunctionWrapperWithPromise: public NPar::ILocallyExecutable { + class TFunctionWrapperWithPromise: public NPar::ILocallyExecutable { private: - NPar::TLocallyExecutableFunction Exec; + NPar::TLocallyExecutableFunction Exec; int FirstId, LastId; TVector<NThreading::TPromise<void>> Promises; public: - TFunctionWrapperWithPromise(NPar::TLocallyExecutableFunction exec, int firstId, int lastId) - : Exec(std::move(exec)) + TFunctionWrapperWithPromise(NPar::TLocallyExecutableFunction exec, int firstId, int lastId) + : Exec(std::move(exec)) , FirstId(firstId) , LastId(lastId) { @@ -70,300 +70,300 @@ namespace { } }; - struct TSingleJob { - TIntrusivePtr<NPar::ILocallyExecutable> Exec; - int Id{0}; + struct TSingleJob { + TIntrusivePtr<NPar::ILocallyExecutable> Exec; + int Id{0}; - TSingleJob() = default; - TSingleJob(TIntrusivePtr<NPar::ILocallyExecutable> exec, int id) - : Exec(std::move(exec)) - , Id(id) - { + TSingleJob() = default; + TSingleJob(TIntrusivePtr<NPar::ILocallyExecutable> exec, int id) + : Exec(std::move(exec)) + , Id(id) + { } - }; + }; - class TLocalRangeExecutor: public NPar::ILocallyExecutable { - TIntrusivePtr<NPar::ILocallyExecutable> Exec; + class TLocalRangeExecutor: public NPar::ILocallyExecutable { + TIntrusivePtr<NPar::ILocallyExecutable> Exec; alignas(64) TAtomic Counter; alignas(64) TAtomic WorkerCount; - int LastId; - - void LocalExec(int) override { - AtomicAdd(WorkerCount, 1); - for (;;) { - if (!DoSingleOp()) - break; - } - AtomicAdd(WorkerCount, -1); + int LastId; + + void LocalExec(int) override { + AtomicAdd(WorkerCount, 1); + for (;;) { + if (!DoSingleOp()) + break; + } + AtomicAdd(WorkerCount, -1); } - public: - TLocalRangeExecutor(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId) - : Exec(std::move(exec)) - , Counter(firstId) - , WorkerCount(0) - , LastId(lastId) - { + public: + TLocalRangeExecutor(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId) + : Exec(std::move(exec)) + , Counter(firstId) + , WorkerCount(0) + , LastId(lastId) + { } - bool DoSingleOp() { + bool DoSingleOp() { const int id = AtomicAdd(Counter, 1) - 1; - if (id >= LastId) - return false; - Exec->LocalExec(id); - RegularYield(); - return true; + if (id >= LastId) + return false; + Exec->LocalExec(id); + RegularYield(); + return true; } - void WaitComplete() { - while (AtomicGet(WorkerCount) > 0) - RegularYield(); + void WaitComplete() { + while (AtomicGet(WorkerCount) > 0) + RegularYield(); } - int GetRangeSize() const { - return Max<int>(LastId - Counter, 0); + int GetRangeSize() const { + return Max<int>(LastId - Counter, 0); } - }; + }; } - -////////////////////////////////////////////////////////////////////////// -class NPar::TLocalExecutor::TImpl { -public: - TLockFreeQueue<TSingleJob> JobQueue; - TLockFreeQueue<TSingleJob> MedJobQueue; - TLockFreeQueue<TSingleJob> LowJobQueue; + +////////////////////////////////////////////////////////////////////////// +class NPar::TLocalExecutor::TImpl { +public: + TLockFreeQueue<TSingleJob> JobQueue; + TLockFreeQueue<TSingleJob> MedJobQueue; + TLockFreeQueue<TSingleJob> LowJobQueue; alignas(64) TSystemEvent HasJob; - - TAtomic ThreadCount{0}; + + TAtomic ThreadCount{0}; alignas(64) TAtomic QueueSize{0}; - TAtomic MPQueueSize{0}; - TAtomic LPQueueSize{0}; - TAtomic ThreadId{0}; - - Y_THREAD(int) - CurrentTaskPriority; - Y_THREAD(int) - WorkerThreadId; - - static void* HostWorkerThread(void* p); - bool GetJob(TSingleJob* job); - void RunNewThread(); - void LaunchRange(TIntrusivePtr<TLocalRangeExecutor> execRange, int queueSizeLimit, - TAtomic* queueSize, TLockFreeQueue<TSingleJob>* jobQueue); - - TImpl() = default; - ~TImpl(); -}; - -NPar::TLocalExecutor::TImpl::~TImpl() { - AtomicAdd(QueueSize, 1); - JobQueue.Enqueue(TSingleJob(nullptr, 0)); - HasJob.Signal(); - while (AtomicGet(ThreadCount)) { - ThreadYield(); - } -} - -void* NPar::TLocalExecutor::TImpl::HostWorkerThread(void* p) { - static const int FAST_ITERATIONS = 200; - - auto* const ctx = (TImpl*)p; + TAtomic MPQueueSize{0}; + TAtomic LPQueueSize{0}; + TAtomic ThreadId{0}; + + Y_THREAD(int) + CurrentTaskPriority; + Y_THREAD(int) + WorkerThreadId; + + static void* HostWorkerThread(void* p); + bool GetJob(TSingleJob* job); + void RunNewThread(); + void LaunchRange(TIntrusivePtr<TLocalRangeExecutor> execRange, int queueSizeLimit, + TAtomic* queueSize, TLockFreeQueue<TSingleJob>* jobQueue); + + TImpl() = default; + ~TImpl(); +}; + +NPar::TLocalExecutor::TImpl::~TImpl() { + AtomicAdd(QueueSize, 1); + JobQueue.Enqueue(TSingleJob(nullptr, 0)); + HasJob.Signal(); + while (AtomicGet(ThreadCount)) { + ThreadYield(); + } +} + +void* NPar::TLocalExecutor::TImpl::HostWorkerThread(void* p) { + static const int FAST_ITERATIONS = 200; + + auto* const ctx = (TImpl*)p; TThread::SetCurrentThreadName("ParLocalExecutor"); - ctx->WorkerThreadId = AtomicAdd(ctx->ThreadId, 1); - for (bool cont = true; cont;) { - TSingleJob job; - bool gotJob = false; - for (int iter = 0; iter < FAST_ITERATIONS; ++iter) { - if (ctx->GetJob(&job)) { - gotJob = true; - break; - } - } - if (!gotJob) { - ctx->HasJob.Reset(); - if (!ctx->GetJob(&job)) { - ctx->HasJob.Wait(); - continue; - } - } - if (job.Exec.Get()) { - job.Exec->LocalExec(job.Id); - RegularYield(); - } else { - AtomicAdd(ctx->QueueSize, 1); - ctx->JobQueue.Enqueue(job); - ctx->HasJob.Signal(); - cont = false; - } - } - AtomicAdd(ctx->ThreadCount, -1); - return nullptr; -} - -bool NPar::TLocalExecutor::TImpl::GetJob(TSingleJob* job) { - if (JobQueue.Dequeue(job)) { - CurrentTaskPriority = TLocalExecutor::HIGH_PRIORITY; - AtomicAdd(QueueSize, -1); - return true; - } else if (MedJobQueue.Dequeue(job)) { - CurrentTaskPriority = TLocalExecutor::MED_PRIORITY; - AtomicAdd(MPQueueSize, -1); - return true; - } else if (LowJobQueue.Dequeue(job)) { - CurrentTaskPriority = TLocalExecutor::LOW_PRIORITY; - AtomicAdd(LPQueueSize, -1); - return true; - } - return false; -} - -void NPar::TLocalExecutor::TImpl::RunNewThread() { - AtomicAdd(ThreadCount, 1); - TThread thr(HostWorkerThread, this); - thr.Start(); - thr.Detach(); -} - -void NPar::TLocalExecutor::TImpl::LaunchRange(TIntrusivePtr<TLocalRangeExecutor> rangeExec, - int queueSizeLimit, - TAtomic* queueSize, - TLockFreeQueue<TSingleJob>* jobQueue) { - int count = Min<int>(ThreadCount + 1, rangeExec->GetRangeSize()); - if (queueSizeLimit >= 0 && AtomicGet(*queueSize) >= queueSizeLimit) { - return; - } - AtomicAdd(*queueSize, count); + ctx->WorkerThreadId = AtomicAdd(ctx->ThreadId, 1); + for (bool cont = true; cont;) { + TSingleJob job; + bool gotJob = false; + for (int iter = 0; iter < FAST_ITERATIONS; ++iter) { + if (ctx->GetJob(&job)) { + gotJob = true; + break; + } + } + if (!gotJob) { + ctx->HasJob.Reset(); + if (!ctx->GetJob(&job)) { + ctx->HasJob.Wait(); + continue; + } + } + if (job.Exec.Get()) { + job.Exec->LocalExec(job.Id); + RegularYield(); + } else { + AtomicAdd(ctx->QueueSize, 1); + ctx->JobQueue.Enqueue(job); + ctx->HasJob.Signal(); + cont = false; + } + } + AtomicAdd(ctx->ThreadCount, -1); + return nullptr; +} + +bool NPar::TLocalExecutor::TImpl::GetJob(TSingleJob* job) { + if (JobQueue.Dequeue(job)) { + CurrentTaskPriority = TLocalExecutor::HIGH_PRIORITY; + AtomicAdd(QueueSize, -1); + return true; + } else if (MedJobQueue.Dequeue(job)) { + CurrentTaskPriority = TLocalExecutor::MED_PRIORITY; + AtomicAdd(MPQueueSize, -1); + return true; + } else if (LowJobQueue.Dequeue(job)) { + CurrentTaskPriority = TLocalExecutor::LOW_PRIORITY; + AtomicAdd(LPQueueSize, -1); + return true; + } + return false; +} + +void NPar::TLocalExecutor::TImpl::RunNewThread() { + AtomicAdd(ThreadCount, 1); + TThread thr(HostWorkerThread, this); + thr.Start(); + thr.Detach(); +} + +void NPar::TLocalExecutor::TImpl::LaunchRange(TIntrusivePtr<TLocalRangeExecutor> rangeExec, + int queueSizeLimit, + TAtomic* queueSize, + TLockFreeQueue<TSingleJob>* jobQueue) { + int count = Min<int>(ThreadCount + 1, rangeExec->GetRangeSize()); + if (queueSizeLimit >= 0 && AtomicGet(*queueSize) >= queueSizeLimit) { + return; + } + AtomicAdd(*queueSize, count); jobQueue->EnqueueAll(TVector<TSingleJob>{size_t(count), TSingleJob(rangeExec, 0)}); - HasJob.Signal(); -} - -NPar::TLocalExecutor::TLocalExecutor() - : Impl_{MakeHolder<TImpl>()} { -} - -NPar::TLocalExecutor::~TLocalExecutor() = default; - -void NPar::TLocalExecutor::RunAdditionalThreads(int threadCount) { - for (int i = 0; i < threadCount; i++) - Impl_->RunNewThread(); -} - -void NPar::TLocalExecutor::Exec(TIntrusivePtr<ILocallyExecutable> exec, int id, int flags) { - Y_ASSERT((flags & WAIT_COMPLETE) == 0); // unsupported - int prior = Max<int>(Impl_->CurrentTaskPriority, flags & PRIORITY_MASK); - switch (prior) { - case HIGH_PRIORITY: - AtomicAdd(Impl_->QueueSize, 1); - Impl_->JobQueue.Enqueue(TSingleJob(std::move(exec), id)); - break; - case MED_PRIORITY: - AtomicAdd(Impl_->MPQueueSize, 1); - Impl_->MedJobQueue.Enqueue(TSingleJob(std::move(exec), id)); - break; - case LOW_PRIORITY: - AtomicAdd(Impl_->LPQueueSize, 1); - Impl_->LowJobQueue.Enqueue(TSingleJob(std::move(exec), id)); - break; - default: - Y_ASSERT(0); - break; - } - Impl_->HasJob.Signal(); -} - + HasJob.Signal(); +} + +NPar::TLocalExecutor::TLocalExecutor() + : Impl_{MakeHolder<TImpl>()} { +} + +NPar::TLocalExecutor::~TLocalExecutor() = default; + +void NPar::TLocalExecutor::RunAdditionalThreads(int threadCount) { + for (int i = 0; i < threadCount; i++) + Impl_->RunNewThread(); +} + +void NPar::TLocalExecutor::Exec(TIntrusivePtr<ILocallyExecutable> exec, int id, int flags) { + Y_ASSERT((flags & WAIT_COMPLETE) == 0); // unsupported + int prior = Max<int>(Impl_->CurrentTaskPriority, flags & PRIORITY_MASK); + switch (prior) { + case HIGH_PRIORITY: + AtomicAdd(Impl_->QueueSize, 1); + Impl_->JobQueue.Enqueue(TSingleJob(std::move(exec), id)); + break; + case MED_PRIORITY: + AtomicAdd(Impl_->MPQueueSize, 1); + Impl_->MedJobQueue.Enqueue(TSingleJob(std::move(exec), id)); + break; + case LOW_PRIORITY: + AtomicAdd(Impl_->LPQueueSize, 1); + Impl_->LowJobQueue.Enqueue(TSingleJob(std::move(exec), id)); + break; + default: + Y_ASSERT(0); + break; + } + Impl_->HasJob.Signal(); +} + void NPar::ILocalExecutor::Exec(TLocallyExecutableFunction exec, int id, int flags) { - Exec(new TFunctionWrapper(std::move(exec)), id, flags); -} - -void NPar::TLocalExecutor::ExecRange(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId, int flags) { - Y_ASSERT(lastId >= firstId); + Exec(new TFunctionWrapper(std::move(exec)), id, flags); +} + +void NPar::TLocalExecutor::ExecRange(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId, int flags) { + Y_ASSERT(lastId >= firstId); if (TryExecRangeSequentially([=] (int id) { exec->LocalExec(id); }, firstId, lastId, flags)) { - return; - } - auto rangeExec = MakeIntrusive<TLocalRangeExecutor>(std::move(exec), firstId, lastId); - int queueSizeLimit = (flags & WAIT_COMPLETE) ? 10000 : -1; - int prior = Max<int>(Impl_->CurrentTaskPriority, flags & PRIORITY_MASK); - switch (prior) { - case HIGH_PRIORITY: - Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->QueueSize, &Impl_->JobQueue); - break; - case MED_PRIORITY: - Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->MPQueueSize, &Impl_->MedJobQueue); - break; - case LOW_PRIORITY: - Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->LPQueueSize, &Impl_->LowJobQueue); - break; - default: - Y_ASSERT(0); - break; - } - if (flags & WAIT_COMPLETE) { - int keepPrior = Impl_->CurrentTaskPriority; - Impl_->CurrentTaskPriority = prior; - while (rangeExec->DoSingleOp()) { - } - Impl_->CurrentTaskPriority = keepPrior; - rangeExec->WaitComplete(); - } -} - + return; + } + auto rangeExec = MakeIntrusive<TLocalRangeExecutor>(std::move(exec), firstId, lastId); + int queueSizeLimit = (flags & WAIT_COMPLETE) ? 10000 : -1; + int prior = Max<int>(Impl_->CurrentTaskPriority, flags & PRIORITY_MASK); + switch (prior) { + case HIGH_PRIORITY: + Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->QueueSize, &Impl_->JobQueue); + break; + case MED_PRIORITY: + Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->MPQueueSize, &Impl_->MedJobQueue); + break; + case LOW_PRIORITY: + Impl_->LaunchRange(rangeExec, queueSizeLimit, &Impl_->LPQueueSize, &Impl_->LowJobQueue); + break; + default: + Y_ASSERT(0); + break; + } + if (flags & WAIT_COMPLETE) { + int keepPrior = Impl_->CurrentTaskPriority; + Impl_->CurrentTaskPriority = prior; + while (rangeExec->DoSingleOp()) { + } + Impl_->CurrentTaskPriority = keepPrior; + rangeExec->WaitComplete(); + } +} + void NPar::ILocalExecutor::ExecRange(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { if (TryExecRangeSequentially(exec, firstId, lastId, flags)) { return; } - ExecRange(new TFunctionWrapper(exec), firstId, lastId, flags); -} - + ExecRange(new TFunctionWrapper(exec), firstId, lastId, flags); +} + void NPar::ILocalExecutor::ExecRangeWithThrow(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { - Y_VERIFY((flags & WAIT_COMPLETE) != 0, "ExecRangeWithThrow() requires WAIT_COMPLETE to wait if exceptions arise."); + Y_VERIFY((flags & WAIT_COMPLETE) != 0, "ExecRangeWithThrow() requires WAIT_COMPLETE to wait if exceptions arise."); if (TryExecRangeSequentially(exec, firstId, lastId, flags)) { return; } - TVector<NThreading::TFuture<void>> currentRun = ExecRangeWithFutures(exec, firstId, lastId, flags); - for (auto& result : currentRun) { - result.GetValueSync(); // Exception will be rethrown if exists. If several exception - only the one with minimal id is rethrown. - } -} - -TVector<NThreading::TFuture<void>> + TVector<NThreading::TFuture<void>> currentRun = ExecRangeWithFutures(exec, firstId, lastId, flags); + for (auto& result : currentRun) { + result.GetValueSync(); // Exception will be rethrown if exists. If several exception - only the one with minimal id is rethrown. + } +} + +TVector<NThreading::TFuture<void>> NPar::ILocalExecutor::ExecRangeWithFutures(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { - TFunctionWrapperWithPromise* execWrapper = new TFunctionWrapperWithPromise(exec, firstId, lastId); - TVector<NThreading::TFuture<void>> out = execWrapper->GetFutures(); - ExecRange(execWrapper, firstId, lastId, flags); - return out; -} - -void NPar::TLocalExecutor::ClearLPQueue() { - for (bool cont = true; cont;) { - cont = false; - TSingleJob job; - while (Impl_->LowJobQueue.Dequeue(&job)) { - AtomicAdd(Impl_->LPQueueSize, -1); - cont = true; - } - while (Impl_->MedJobQueue.Dequeue(&job)) { - AtomicAdd(Impl_->MPQueueSize, -1); - cont = true; - } - } -} - -int NPar::TLocalExecutor::GetQueueSize() const noexcept { - return AtomicGet(Impl_->QueueSize); -} - -int NPar::TLocalExecutor::GetMPQueueSize() const noexcept { - return AtomicGet(Impl_->MPQueueSize); -} - -int NPar::TLocalExecutor::GetLPQueueSize() const noexcept { - return AtomicGet(Impl_->LPQueueSize); -} - + TFunctionWrapperWithPromise* execWrapper = new TFunctionWrapperWithPromise(exec, firstId, lastId); + TVector<NThreading::TFuture<void>> out = execWrapper->GetFutures(); + ExecRange(execWrapper, firstId, lastId, flags); + return out; +} + +void NPar::TLocalExecutor::ClearLPQueue() { + for (bool cont = true; cont;) { + cont = false; + TSingleJob job; + while (Impl_->LowJobQueue.Dequeue(&job)) { + AtomicAdd(Impl_->LPQueueSize, -1); + cont = true; + } + while (Impl_->MedJobQueue.Dequeue(&job)) { + AtomicAdd(Impl_->MPQueueSize, -1); + cont = true; + } + } +} + +int NPar::TLocalExecutor::GetQueueSize() const noexcept { + return AtomicGet(Impl_->QueueSize); +} + +int NPar::TLocalExecutor::GetMPQueueSize() const noexcept { + return AtomicGet(Impl_->MPQueueSize); +} + +int NPar::TLocalExecutor::GetLPQueueSize() const noexcept { + return AtomicGet(Impl_->LPQueueSize); +} + int NPar::TLocalExecutor::GetWorkerThreadId() const noexcept { - return Impl_->WorkerThreadId; -} - -int NPar::TLocalExecutor::GetThreadCount() const noexcept { - return AtomicGet(Impl_->ThreadCount); -} - -////////////////////////////////////////////////////////////////////////// + return Impl_->WorkerThreadId; +} + +int NPar::TLocalExecutor::GetThreadCount() const noexcept { + return AtomicGet(Impl_->ThreadCount); +} + +////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/threading/local_executor/local_executor.h b/library/cpp/threading/local_executor/local_executor.h index aa500d34d3..c1c824f67c 100644 --- a/library/cpp/threading/local_executor/local_executor.h +++ b/library/cpp/threading/local_executor/local_executor.h @@ -1,23 +1,23 @@ #pragma once #include <library/cpp/threading/future/future.h> - + #include <util/generic/cast.h> -#include <util/generic/fwd.h> -#include <util/generic/noncopyable.h> +#include <util/generic/fwd.h> +#include <util/generic/noncopyable.h> #include <util/generic/ptr.h> -#include <util/generic/singleton.h> +#include <util/generic/singleton.h> #include <util/generic/ymath.h> - + #include <functional> namespace NPar { struct ILocallyExecutable : virtual public TThrRefBase { - // Must be implemented by the end user to define job that will be processed by one of - // executor threads. - // - // @param id Job parameter, typically an index pointing somewhere in array, or just - // some dummy value, e.g. `0`. + // Must be implemented by the end user to define job that will be processed by one of + // executor threads. + // + // @param id Job parameter, typically an index pointing somewhere in array, or just + // some dummy value, e.g. `0`. virtual void LocalExec(int id) = 0; }; @@ -31,7 +31,7 @@ namespace NPar { ILocalExecutor() = default; virtual ~ILocalExecutor() = default; - enum EFlags : int { + enum EFlags : int { HIGH_PRIORITY = 0, MED_PRIORITY = 1, LOW_PRIORITY = 2, @@ -58,8 +58,8 @@ namespace NPar { virtual int GetWorkerThreadId() const noexcept = 0; virtual int GetThreadCount() const noexcept = 0; - // Describes a range of tasks with parameters from integer range [FirstId, LastId). - // + // Describes a range of tasks with parameters from integer range [FirstId, LastId). + // class TExecRangeParams { public: template <typename TFirst, typename TLast> @@ -70,9 +70,9 @@ namespace NPar { Y_ASSERT(LastId >= FirstId); SetBlockSize(1); } - // Partition tasks into `blockCount` blocks of approximately equal size, each of which - // will be executed as a separate bigger task. - // + // Partition tasks into `blockCount` blocks of approximately equal size, each of which + // will be executed as a separate bigger task. + // template <typename TBlockCount> TExecRangeParams& SetBlockCount(TBlockCount blockCount) { Y_ASSERT(SafeIntegerCast<int>(blockCount) > 0 || FirstId == LastId); @@ -81,9 +81,9 @@ namespace NPar { BlockEqualToThreads = false; return *this; } - // Partition tasks into blocks of approximately `blockSize` size, each of which will - // be executed as a separate bigger task. - // + // Partition tasks into blocks of approximately `blockSize` size, each of which will + // be executed as a separate bigger task. + // template <typename TBlockSize> TExecRangeParams& SetBlockSize(TBlockSize blockSize) { Y_ASSERT(SafeIntegerCast<int>(blockSize) > 0 || FirstId == LastId); @@ -92,9 +92,9 @@ namespace NPar { BlockEqualToThreads = false; return *this; } - // Partition tasks into thread count blocks of approximately equal size, each of which - // will be executed as a separate bigger task. - // + // Partition tasks into thread count blocks of approximately equal size, each of which + // will be executed as a separate bigger task. + // TExecRangeParams& SetBlockCountToThreadCount() { BlockEqualToThreads = true; return *this; @@ -107,9 +107,9 @@ namespace NPar { Y_ASSERT(!BlockEqualToThreads); return BlockSize; } - bool GetBlockEqualToThreads() { - return BlockEqualToThreads; - } + bool GetBlockEqualToThreads() { + return BlockEqualToThreads; + } const int FirstId = 0; const int LastId = 0; @@ -120,26 +120,26 @@ namespace NPar { bool BlockEqualToThreads; }; - // `Exec` and `ExecRange` versions that accept functions. - // - void Exec(TLocallyExecutableFunction exec, int id, int flags); - void ExecRange(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); - - // Version of `ExecRange` that throws exception from task with minimal id if at least one of - // task threw an exception. - // - void ExecRangeWithThrow(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); - - // Version of `ExecRange` that returns vector of futures, thus allowing to retry any task if - // it fails. - // - TVector<NThreading::TFuture<void>> ExecRangeWithFutures(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); - + // `Exec` and `ExecRange` versions that accept functions. + // + void Exec(TLocallyExecutableFunction exec, int id, int flags); + void ExecRange(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); + + // Version of `ExecRange` that throws exception from task with minimal id if at least one of + // task threw an exception. + // + void ExecRangeWithThrow(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); + + // Version of `ExecRange` that returns vector of futures, thus allowing to retry any task if + // it fails. + // + TVector<NThreading::TFuture<void>> ExecRangeWithFutures(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); + template <typename TBody> static inline auto BlockedLoopBody(const TExecRangeParams& params, const TBody& body) { return [=](int blockId) { - const int blockFirstId = params.FirstId + blockId * params.GetBlockSize(); - const int blockLastId = Min(params.LastId, blockFirstId + params.GetBlockSize()); + const int blockFirstId = params.FirstId + blockId * params.GetBlockSize(); + const int blockLastId = Min(params.LastId, blockFirstId + params.GetBlockSize()); for (int i = blockFirstId; i < blockLastId; ++i) { body(i); } @@ -151,10 +151,10 @@ namespace NPar { if (TryExecRangeSequentially(body, params.FirstId, params.LastId, flags)) { return; } - if (params.GetBlockEqualToThreads()) { - params.SetBlockCount(GetThreadCount() + ((flags & WAIT_COMPLETE) != 0)); // ThreadCount or ThreadCount+1 depending on WaitFlag + if (params.GetBlockEqualToThreads()) { + params.SetBlockCount(GetThreadCount() + ((flags & WAIT_COMPLETE) != 0)); // ThreadCount or ThreadCount+1 depending on WaitFlag } - ExecRange(BlockedLoopBody(params, body), 0, params.GetBlockCount(), flags); + ExecRange(BlockedLoopBody(params, body), 0, params.GetBlockCount(), flags); } template <typename TBody> @@ -269,7 +269,7 @@ namespace NPar { THolder<TImpl> Impl_; }; - static inline TLocalExecutor& LocalExecutor() { + static inline TLocalExecutor& LocalExecutor() { return *Singleton<TLocalExecutor>(); } diff --git a/library/cpp/threading/local_executor/ut/local_executor_ut.cpp b/library/cpp/threading/local_executor/ut/local_executor_ut.cpp index fe7dab0899..ac5737717c 100644 --- a/library/cpp/threading/local_executor/ut/local_executor_ut.cpp +++ b/library/cpp/threading/local_executor/ut/local_executor_ut.cpp @@ -1,10 +1,10 @@ #include <library/cpp/threading/local_executor/local_executor.h> #include <library/cpp/threading/future/future.h> - + #include <library/cpp/testing/unittest/registar.h> #include <util/system/mutex.h> #include <util/system/rwlock.h> -#include <util/generic/algorithm.h> +#include <util/generic/algorithm.h> using namespace NPar; @@ -14,7 +14,7 @@ class TTestException: public yexception { static const int DefaultThreadsCount = 41; static const int DefaultRangeSize = 999; -Y_UNIT_TEST_SUITE(ExecRangeWithFutures){ +Y_UNIT_TEST_SUITE(ExecRangeWithFutures){ bool AllOf(const TVector<int>& vec, int value){ return AllOf(vec, [value](int element) { return value == element; }); } @@ -41,23 +41,23 @@ void AsyncRunAndWaitFuturesReady(int rangeSize, int threads) { UNIT_ASSERT(AllOf(data, 1)); } -Y_UNIT_TEST(AsyncRunRangeAndWaitFuturesReady) { +Y_UNIT_TEST(AsyncRunRangeAndWaitFuturesReady) { AsyncRunAndWaitFuturesReady(DefaultRangeSize, DefaultThreadsCount); } -Y_UNIT_TEST(AsyncRunOneTaskAndWaitFuturesReady) { +Y_UNIT_TEST(AsyncRunOneTaskAndWaitFuturesReady) { AsyncRunAndWaitFuturesReady(1, DefaultThreadsCount); } -Y_UNIT_TEST(AsyncRunRangeAndWaitFuturesReadyOneExtraThread) { +Y_UNIT_TEST(AsyncRunRangeAndWaitFuturesReadyOneExtraThread) { AsyncRunAndWaitFuturesReady(DefaultRangeSize, 1); } -Y_UNIT_TEST(AsyncRunOneThreadAndWaitFuturesReadyOneExtraThread) { +Y_UNIT_TEST(AsyncRunOneThreadAndWaitFuturesReadyOneExtraThread) { AsyncRunAndWaitFuturesReady(1, 1); } -Y_UNIT_TEST(AsyncRunTwoRangesAndWaitFuturesReady) { +Y_UNIT_TEST(AsyncRunTwoRangesAndWaitFuturesReady) { TLocalExecutor localExecutor; localExecutor.RunAdditionalThreads(DefaultThreadsCount); TAtomic signal = 0; @@ -118,23 +118,23 @@ void AsyncRunRangeAndWaitExceptions(int rangeSize, int threadsCount) { UNIT_ASSERT(AllOf(data, 1)); } -Y_UNIT_TEST(AsyncRunRangeAndWaitExceptions) { +Y_UNIT_TEST(AsyncRunRangeAndWaitExceptions) { AsyncRunRangeAndWaitExceptions(DefaultRangeSize, DefaultThreadsCount); } -Y_UNIT_TEST(AsyncRunOneTaskAndWaitExceptions) { +Y_UNIT_TEST(AsyncRunOneTaskAndWaitExceptions) { AsyncRunRangeAndWaitExceptions(1, DefaultThreadsCount); } -Y_UNIT_TEST(AsyncRunRangeAndWaitExceptionsOneExtraThread) { +Y_UNIT_TEST(AsyncRunRangeAndWaitExceptionsOneExtraThread) { AsyncRunRangeAndWaitExceptions(DefaultRangeSize, 1); } -Y_UNIT_TEST(AsyncRunOneTaskAndWaitExceptionsOneExtraThread) { +Y_UNIT_TEST(AsyncRunOneTaskAndWaitExceptionsOneExtraThread) { AsyncRunRangeAndWaitExceptions(1, 1); } -Y_UNIT_TEST(AsyncRunTwoRangesAndWaitExceptions) { +Y_UNIT_TEST(AsyncRunTwoRangesAndWaitExceptions) { TLocalExecutor localExecutor; localExecutor.RunAdditionalThreads(DefaultThreadsCount); TAtomic signal = 0; @@ -209,33 +209,33 @@ void RunRangeAndCheckExceptionsWithWaitComplete(int rangeSize, int threadsCount) UNIT_ASSERT(AllOf(data, 1)); } -Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitComplete) { +Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitComplete) { RunRangeAndCheckExceptionsWithWaitComplete(DefaultRangeSize, DefaultThreadsCount); } -Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitComplete) { +Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitComplete) { RunRangeAndCheckExceptionsWithWaitComplete(1, DefaultThreadsCount); } -Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitCompleteOneExtraThread) { +Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitCompleteOneExtraThread) { RunRangeAndCheckExceptionsWithWaitComplete(DefaultRangeSize, 1); } -Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitCompleteOneExtraThread) { +Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitCompleteOneExtraThread) { RunRangeAndCheckExceptionsWithWaitComplete(1, 1); } -Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitCompleteZeroExtraThreads) { +Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitCompleteZeroExtraThreads) { RunRangeAndCheckExceptionsWithWaitComplete(DefaultRangeSize, 0); } -Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitCompleteZeroExtraThreads) { +Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitCompleteZeroExtraThreads) { RunRangeAndCheckExceptionsWithWaitComplete(1, 0); } } ; -Y_UNIT_TEST_SUITE(ExecRangeWithThrow){ +Y_UNIT_TEST_SUITE(ExecRangeWithThrow){ void RunParallelWhichThrowsTTestException(int rangeStart, int rangeSize, int threadsCount, int flags, TAtomic& processed){ AtomicSet(processed, 0); TLocalExecutor localExecutor; @@ -247,7 +247,7 @@ localExecutor.ExecRangeWithThrow([&processed](int) { rangeStart, rangeStart + rangeSize, flags); } -Y_UNIT_TEST(RunParallelWhichThrowsTTestException) { +Y_UNIT_TEST(RunParallelWhichThrowsTTestException) { TAtomic processed = 0; UNIT_ASSERT_EXCEPTION( RunParallelWhichThrowsTTestException(10, 40, DefaultThreadsCount, @@ -264,32 +264,32 @@ void ThrowAndCatchTTestException(int rangeSize, int threadsCount, int flags) { UNIT_ASSERT(AtomicGet(processed) == rangeSize); } -Y_UNIT_TEST(ThrowAndCatchTTestExceptionLowPriority) { +Y_UNIT_TEST(ThrowAndCatchTTestExceptionLowPriority) { ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount, TLocalExecutor::EFlags::WAIT_COMPLETE | TLocalExecutor::EFlags::LOW_PRIORITY); } -Y_UNIT_TEST(ThrowAndCatchTTestExceptionMedPriority) { +Y_UNIT_TEST(ThrowAndCatchTTestExceptionMedPriority) { ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount, TLocalExecutor::EFlags::WAIT_COMPLETE | TLocalExecutor::EFlags::MED_PRIORITY); } -Y_UNIT_TEST(ThrowAndCatchTTestExceptionHighPriority) { +Y_UNIT_TEST(ThrowAndCatchTTestExceptionHighPriority) { ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount, TLocalExecutor::EFlags::WAIT_COMPLETE | TLocalExecutor::EFlags::HIGH_PRIORITY); } -Y_UNIT_TEST(ThrowAndCatchTTestExceptionWaitComplete) { +Y_UNIT_TEST(ThrowAndCatchTTestExceptionWaitComplete) { ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount, TLocalExecutor::EFlags::WAIT_COMPLETE); } -Y_UNIT_TEST(RethrowExeptionSequentialWaitComplete) { +Y_UNIT_TEST(RethrowExeptionSequentialWaitComplete) { ThrowAndCatchTTestException(DefaultRangeSize, 0, TLocalExecutor::EFlags::WAIT_COMPLETE); } -Y_UNIT_TEST(RethrowExeptionOneExtraThreadWaitComplete) { +Y_UNIT_TEST(RethrowExeptionOneExtraThreadWaitComplete) { ThrowAndCatchTTestException(DefaultRangeSize, 1, TLocalExecutor::EFlags::WAIT_COMPLETE); } @@ -314,7 +314,7 @@ void CatchTTestExceptionFromNested(TAtomic& processed1, TAtomic& processed2) { 0, DefaultRangeSize, TLocalExecutor::EFlags::WAIT_COMPLETE); } -Y_UNIT_TEST(NestedParallelExceptionsDoNotLeak) { +Y_UNIT_TEST(NestedParallelExceptionsDoNotLeak) { TAtomic processed1 = 0; TAtomic processed2 = 0; UNIT_ASSERT_NO_EXCEPTION( diff --git a/library/cpp/threading/local_executor/ut/ya.make b/library/cpp/threading/local_executor/ut/ya.make index 2983c4f466..be579a5ca0 100644 --- a/library/cpp/threading/local_executor/ut/ya.make +++ b/library/cpp/threading/local_executor/ut/ya.make @@ -1,10 +1,10 @@ OWNER( g:matrixnet - gulin -) + gulin +) UNITTEST_FOR(library/cpp/threading/local_executor) - + SRCS( local_executor_ut.cpp ) diff --git a/library/cpp/threading/local_executor/ya.make b/library/cpp/threading/local_executor/ya.make index 516be66703..df210f92bb 100644 --- a/library/cpp/threading/local_executor/ya.make +++ b/library/cpp/threading/local_executor/ya.make @@ -5,8 +5,8 @@ OWNER( espetrov ) -LIBRARY() - +LIBRARY() + SRCS( local_executor.cpp tbb_local_executor.cpp diff --git a/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp b/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp index 0f91c1ce4a..7417636864 100644 --- a/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp +++ b/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp @@ -5,8 +5,8 @@ #include <util/generic/string.h> #include <util/generic/yexception.h> -Y_UNIT_TEST_SUITE(TestMP) { - Y_UNIT_TEST(TestErr) { +Y_UNIT_TEST_SUITE(TestMP) { + Y_UNIT_TEST(TestErr) { std::function<void(int)> f = [](int x) { if (x == 5) { ythrow yexception() << "oops"; diff --git a/library/cpp/threading/queue/basic_ut.cpp b/library/cpp/threading/queue/basic_ut.cpp index a52b46c8a6..5f56f8583e 100644 --- a/library/cpp/threading/queue/basic_ut.cpp +++ b/library/cpp/threading/queue/basic_ut.cpp @@ -51,7 +51,7 @@ public: template <size_t NUMBER_OF_THREADS> void RepeatPush1Pop1_InManyThreads() { - class TCycleThread: public ISimpleThread { + class TCycleThread: public ISimpleThread { public: void* ThreadProc() override { TQueueType queue; diff --git a/library/cpp/threading/queue/queue_ut.cpp b/library/cpp/threading/queue/queue_ut.cpp index eb77e51e19..80eca147da 100644 --- a/library/cpp/threading/queue/queue_ut.cpp +++ b/library/cpp/threading/queue/queue_ut.cpp @@ -43,7 +43,7 @@ public: void Threads2_Push1M_Threads1_Pop2M() { TQueueType queue; - class TPusherThread: public ISimpleThread { + class TPusherThread: public ISimpleThread { public: TPusherThread(TQueueType& theQueue, char* start) : Queue(theQueue) @@ -81,7 +81,7 @@ public: void Threads4_Push1M_Threads1_Pop4M() { TQueueType queue; - class TPusherThread: public ISimpleThread { + class TPusherThread: public ISimpleThread { public: TPusherThread(TQueueType& theQueue, char* start) : Queue(theQueue) @@ -124,7 +124,7 @@ public: void ManyRndPush100K_ManyQueues() { TQueueType queue[NUMBER_OF_QUEUES]; - class TPusherThread: public ISimpleThread { + class TPusherThread: public ISimpleThread { public: TPusherThread(TQueueType* queues, char* start) : Queues(queues) @@ -155,7 +155,7 @@ public: } }; - class TPopperThread: public ISimpleThread { + class TPopperThread: public ISimpleThread { public: TPopperThread(TQueueType* theQueue, char* base) : Queue(theQueue) diff --git a/library/cpp/threading/queue/tune_ut.cpp b/library/cpp/threading/queue/tune_ut.cpp index 34086ccf0f..7e980d3e27 100644 --- a/library/cpp/threading/queue/tune_ut.cpp +++ b/library/cpp/threading/queue/tune_ut.cpp @@ -19,8 +19,8 @@ DeclareTuneTypeParam(TweakStructB, TStructB); DeclareTuneValueParam(TweakParam1, ui32, Param1); DeclareTuneValueParam(TweakParam2, ui32, Param2); -Y_UNIT_TEST_SUITE(TestTuning) { - Y_UNIT_TEST(Defaults) { +Y_UNIT_TEST_SUITE(TestTuning) { + Y_UNIT_TEST(Defaults) { using TTuned = TTune<TDefaults>; using TunedA = TTuned::TStructA; using TunedB = TTuned::TStructB; @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TestTuning) { UNIT_ASSERT_EQUAL(param2, 42); } - Y_UNIT_TEST(TuneStructA) { + Y_UNIT_TEST(TuneStructA) { struct TMyStruct { }; @@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TestTuning) { UNIT_ASSERT_EQUAL(param2, 42); } - Y_UNIT_TEST(TuneParam1) { + Y_UNIT_TEST(TuneParam1) { using TTuned = TTune<TDefaults, TweakParam1<24>>; using TunedA = TTuned::TStructA; @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(TestTuning) { UNIT_ASSERT_EQUAL(param2, 42); } - Y_UNIT_TEST(TuneStructAAndParam1) { + Y_UNIT_TEST(TuneStructAAndParam1) { struct TMyStruct { }; @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TestTuning) { UNIT_ASSERT_EQUAL(param2, 42); } - Y_UNIT_TEST(TuneParam1AndStructA) { + Y_UNIT_TEST(TuneParam1AndStructA) { struct TMyStruct { }; diff --git a/library/cpp/threading/queue/unordered_ut.cpp b/library/cpp/threading/queue/unordered_ut.cpp index 1310559c46..a43b7f520e 100644 --- a/library/cpp/threading/queue/unordered_ut.cpp +++ b/library/cpp/threading/queue/unordered_ut.cpp @@ -56,7 +56,7 @@ public: void ManyThreadsRndExchange() { TQueueType queues[COUNT]; - class TWorker: public ISimpleThread { + class TWorker: public ISimpleThread { public: TWorker( TQueueType* queues_, diff --git a/library/cpp/threading/skip_list/skiplist_ut.cpp b/library/cpp/threading/skip_list/skiplist_ut.cpp index 9c483de136..52fcffda66 100644 --- a/library/cpp/threading/skip_list/skiplist_ut.cpp +++ b/library/cpp/threading/skip_list/skiplist_ut.cpp @@ -35,15 +35,15 @@ namespace NThreading { //////////////////////////////////////////////////////////////////////////////// - Y_UNIT_TEST_SUITE(TSkipListTest) { - Y_UNIT_TEST(ShouldBeEmptyAfterCreation) { + Y_UNIT_TEST_SUITE(TSkipListTest) { + Y_UNIT_TEST(ShouldBeEmptyAfterCreation) { TMemoryPool pool(1024); TSkipList<int> list(pool); UNIT_ASSERT_EQUAL(list.GetSize(), 0); } - Y_UNIT_TEST(ShouldAllowInsertion) { + Y_UNIT_TEST(ShouldAllowInsertion) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -51,7 +51,7 @@ namespace NThreading { UNIT_ASSERT_EQUAL(list.GetSize(), 1); } - Y_UNIT_TEST(ShouldNotAllowDuplicates) { + Y_UNIT_TEST(ShouldNotAllowDuplicates) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -62,7 +62,7 @@ namespace NThreading { UNIT_ASSERT_EQUAL(list.GetSize(), 1); } - Y_UNIT_TEST(ShouldContainInsertedItem) { + Y_UNIT_TEST(ShouldContainInsertedItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -70,7 +70,7 @@ namespace NThreading { UNIT_ASSERT(list.Contains(12345678)); } - Y_UNIT_TEST(ShouldNotContainNotInsertedItem) { + Y_UNIT_TEST(ShouldNotContainNotInsertedItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -78,7 +78,7 @@ namespace NThreading { UNIT_ASSERT(!list.Contains(87654321)); } - Y_UNIT_TEST(ShouldIterateAllItems) { + Y_UNIT_TEST(ShouldIterateAllItems) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -95,7 +95,7 @@ namespace NThreading { UNIT_ASSERT(!it.IsValid()); } - Y_UNIT_TEST(ShouldIterateAllItemsInReverseDirection) { + Y_UNIT_TEST(ShouldIterateAllItemsInReverseDirection) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -112,7 +112,7 @@ namespace NThreading { UNIT_ASSERT(!it.IsValid()); } - Y_UNIT_TEST(ShouldSeekToFirstItem) { + Y_UNIT_TEST(ShouldSeekToFirstItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -125,7 +125,7 @@ namespace NThreading { UNIT_ASSERT_EQUAL(it.GetValue(), 1); } - Y_UNIT_TEST(ShouldSeekToLastItem) { + Y_UNIT_TEST(ShouldSeekToLastItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -138,7 +138,7 @@ namespace NThreading { UNIT_ASSERT_EQUAL(it.GetValue(), 9); } - Y_UNIT_TEST(ShouldSeekToExistingItem) { + Y_UNIT_TEST(ShouldSeekToExistingItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -148,7 +148,7 @@ namespace NThreading { UNIT_ASSERT(it.IsValid()); } - Y_UNIT_TEST(ShouldSeekAfterMissedItem) { + Y_UNIT_TEST(ShouldSeekAfterMissedItem) { TMemoryPool pool(1024); TSkipList<int> list(pool); @@ -164,7 +164,7 @@ namespace NThreading { UNIT_ASSERT_EQUAL(it.GetValue(), 100); } - Y_UNIT_TEST(ShouldCallDtorsOfNonPodTypes) { + Y_UNIT_TEST(ShouldCallDtorsOfNonPodTypes) { UNIT_ASSERT(!TTypeTraits<TTestObject>::IsPod); UNIT_ASSERT_EQUAL(TTestObject::Count, 0); diff --git a/library/cpp/threading/task_scheduler/task_scheduler.cpp b/library/cpp/threading/task_scheduler/task_scheduler.cpp index 95bd27d7cf..174dde4bf7 100644 --- a/library/cpp/threading/task_scheduler/task_scheduler.cpp +++ b/library/cpp/threading/task_scheduler/task_scheduler.cpp @@ -2,7 +2,7 @@ #include <util/system/thread.h> #include <util/string/cast.h> -#include <util/stream/output.h> +#include <util/stream/output.h> TTaskScheduler::ITask::~ITask() {} TTaskScheduler::IRepeatedTask::~IRepeatedTask() {} @@ -10,7 +10,7 @@ TTaskScheduler::IRepeatedTask::~IRepeatedTask() {} class TTaskScheduler::TWorkerThread - : public ISimpleThread + : public ISimpleThread { public: TWorkerThread(TTaskScheduler& state) @@ -152,8 +152,8 @@ const bool debugOutput = false; void TTaskScheduler::ChangeDebugState(TWorkerThread* thread, const TString& state) { if (!debugOutput) { - Y_UNUSED(thread); - Y_UNUSED(state); + Y_UNUSED(thread); + Y_UNUSED(state); return; } diff --git a/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp b/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp index 8f21984b77..3b5203194a 100644 --- a/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp +++ b/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp @@ -1,7 +1,7 @@ #include <algorithm> #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/system/atomic.h> #include <util/generic/vector.h> diff --git a/library/cpp/timezone_conversion/README.md b/library/cpp/timezone_conversion/README.md index 66ee7ca440..828f1880bc 100644 --- a/library/cpp/timezone_conversion/README.md +++ b/library/cpp/timezone_conversion/README.md @@ -1,16 +1,16 @@ -A library for translating between absolute times (i.e., `TInstant`) and civil times (i.e., -`NDatetime::TSimpleTM`) using the rules defined by a time zone (i.e., `NDatetime::TTimeZone`). +A library for translating between absolute times (i.e., `TInstant`) and civil times (i.e., +`NDatetime::TSimpleTM`) using the rules defined by a time zone (i.e., `NDatetime::TTimeZone`). -(the terms `absolute` and `civil` come from [cctz#fundamental-concepts][cctz-fundamental-concepts]) +(the terms `absolute` and `civil` come from [cctz#fundamental-concepts][cctz-fundamental-concepts]) -This is basically a wrapper around [CCTZ][cctz] with one important change: the time zone database is -in Arcadia and is compiled with the library (which means your executable will end up ~2MB larger). +This is basically a wrapper around [CCTZ][cctz] with one important change: the time zone database is +in Arcadia and is compiled with the library (which means your executable will end up ~2MB larger). + +See [contrib/libs/cctz/README][update] if you think zone database is outdated. -See [contrib/libs/cctz/README][update] if you think zone database is outdated. - Quick start: ============ -``` +``` #include <library/cpp/timezone_conversion/convert.h> // NDatetime::{GetLocalTimeZone(),GetUtcTimeZone()} are also available. @@ -20,8 +20,8 @@ NDatetime::TSimpleTM civil = NDatetime::ToCivilTime(now, msk); Cout << "Local time in Moscow is " << civil.ToString() << Endl; TInstant absolute = NDatetime::ToAbsoluteTime(civil, msk); Cout << "The current UNIX time is " << absolute.Seconds() << Endl; -``` - -[cctz-fundamental-concepts]: https://github.com/google/cctz#fundamental-concepts -[cctz]: https://github.com/google/cctz -[update]: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/cctz/tzdata/README?rev=2286180 +``` + +[cctz-fundamental-concepts]: https://github.com/google/cctz#fundamental-concepts +[cctz]: https://github.com/google/cctz +[update]: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/cctz/tzdata/README?rev=2286180 diff --git a/library/cpp/timezone_conversion/civil.cpp b/library/cpp/timezone_conversion/civil.cpp index 4d3d0454d1..5986318b9a 100644 --- a/library/cpp/timezone_conversion/civil.cpp +++ b/library/cpp/timezone_conversion/civil.cpp @@ -176,37 +176,37 @@ namespace NDatetime { } template <> -void Out<NDatetime::TCivilYear>(IOutputStream& out, const NDatetime::TCivilYear& y) { +void Out<NDatetime::TCivilYear>(IOutputStream& out, const NDatetime::TCivilYear& y) { out << y.year(); } template <> -void Out<NDatetime::TCivilMonth>(IOutputStream& out, const NDatetime::TCivilMonth& m) { +void Out<NDatetime::TCivilMonth>(IOutputStream& out, const NDatetime::TCivilMonth& m) { out << NDatetime::TCivilYear(m) << '-' << LeftPad(m.month(), 2, '0'); } template <> -void Out<NDatetime::TCivilDay>(IOutputStream& out, const NDatetime::TCivilDay& d) { +void Out<NDatetime::TCivilDay>(IOutputStream& out, const NDatetime::TCivilDay& d) { out << NDatetime::TCivilMonth(d) << '-' << LeftPad(d.day(), 2, '0'); } template <> -void Out<NDatetime::TCivilHour>(IOutputStream& out, const NDatetime::TCivilHour& h) { +void Out<NDatetime::TCivilHour>(IOutputStream& out, const NDatetime::TCivilHour& h) { out << NDatetime::TCivilDay(h) << 'T' << LeftPad(h.hour(), 2, '0'); } template <> -void Out<NDatetime::TCivilMinute>(IOutputStream& out, const NDatetime::TCivilMinute& m) { +void Out<NDatetime::TCivilMinute>(IOutputStream& out, const NDatetime::TCivilMinute& m) { out << NDatetime::TCivilHour(m) << ':' << LeftPad(m.minute(), 2, '0'); } template <> -void Out<NDatetime::TCivilSecond>(IOutputStream& out, const NDatetime::TCivilSecond& s) { +void Out<NDatetime::TCivilSecond>(IOutputStream& out, const NDatetime::TCivilSecond& s) { out << NDatetime::TCivilMinute(s) << ':' << LeftPad(s.second(), 2, '0'); } template <> -void Out<NDatetime::TWeekday>(IOutputStream& out, NDatetime::TWeekday wd) { +void Out<NDatetime::TWeekday>(IOutputStream& out, NDatetime::TWeekday wd) { using namespace cctz; switch (wd) { case weekday::monday: diff --git a/library/cpp/timezone_conversion/ut/civil_ut.cpp b/library/cpp/timezone_conversion/ut/civil_ut.cpp index 4f46dbb91f..a21bd4bd7d 100644 --- a/library/cpp/timezone_conversion/ut/civil_ut.cpp +++ b/library/cpp/timezone_conversion/ut/civil_ut.cpp @@ -15,20 +15,20 @@ inline void Out<NDatetime::TCivilDiff>(IOutputStream& out, const NDatetime::TCiv out << "(" << diff.Value << "," << diff.Unit << ")"; } -Y_UNIT_TEST_SUITE(DateTime) { - Y_UNIT_TEST(Calc) { +Y_UNIT_TEST_SUITE(DateTime) { + Y_UNIT_TEST(Calc) { NDatetime::TCivilSecond s(2017, 2, 1, 10, 12, 9); UNIT_ASSERT_VALUES_EQUAL(NDatetime::Calc<NDatetime::TCivilDay>(s, 2), NDatetime::TCivilDay(2017, 2, 3)); UNIT_ASSERT_VALUES_EQUAL(NDatetime::Calc<NDatetime::TCivilDay>(s, -2), NDatetime::TCivilDay(2017, 1, 30)); } - Y_UNIT_TEST(Adds) { + Y_UNIT_TEST(Adds) { NDatetime::TCivilSecond s(2017, 2, 1, 10, 12, 9); UNIT_ASSERT_VALUES_EQUAL(NDatetime::AddDays(s, 2), NDatetime::TCivilSecond(2017, 2, 3, 10, 12, 9)); UNIT_ASSERT_VALUES_EQUAL(NDatetime::AddMonths(s, -2), NDatetime::TCivilSecond(2016, 12, 1, 10, 12, 9)); UNIT_ASSERT_VALUES_EQUAL(NDatetime::AddYears(s, -55), NDatetime::TCivilSecond(1962, 2, 1, 10, 12, 9)); UNIT_ASSERT_VALUES_EQUAL(NDatetime::AddHours(s, 40), NDatetime::TCivilSecond(2017, 2, 3, 2, 12, 9)); } - Y_UNIT_TEST(Convert) { + Y_UNIT_TEST(Convert) { TInstant absTime = TInstant::Seconds(1500299239); NDatetime::TTimeZone lax = NDatetime::GetTimeZone("America/Los_Angeles"); NDatetime::TCivilSecond dt1 = NDatetime::Convert(absTime, lax); @@ -66,13 +66,13 @@ Y_UNIT_TEST_SUITE(DateTime) { UNIT_ASSERT_EXCEPTION(NDatetime::GetTimeZone("UTC+20:60"), NDatetime::TInvalidTimezone); UNIT_ASSERT_EXCEPTION(NDatetime::GetTimeZone("UTC+20:30:"), NDatetime::TInvalidTimezone); } - Y_UNIT_TEST(Format) { + Y_UNIT_TEST(Format) { NDatetime::TTimeZone lax = NDatetime::GetTimeZone("America/Los_Angeles"); NDatetime::TCivilSecond tp(2013, 1, 2, 3, 4, 5); UNIT_ASSERT_VALUES_EQUAL(NDatetime::Format("%H:%M:%S", tp, lax), "03:04:05"); UNIT_ASSERT_VALUES_EQUAL(NDatetime::Format("%H:%M:%E3S", tp, lax), "03:04:05.000"); } - Y_UNIT_TEST(Weekday) { + Y_UNIT_TEST(Weekday) { NDatetime::TCivilDay d(2013, 1, 2); NDatetime::TWeekday wd = NDatetime::GetWeekday(d); UNIT_ASSERT_VALUES_EQUAL(wd, NDatetime::TWeekday::wednesday); @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(DateTime) { UNIT_ASSERT_VALUES_EQUAL(NDatetime::WeekdayOnTheWeek(d, NDatetime::TWeekday::wednesday), NDatetime::TCivilDay(2013, 1, 2)); UNIT_ASSERT_VALUES_EQUAL(NDatetime::WeekdayOnTheWeek(d, NDatetime::TWeekday::friday), NDatetime::TCivilDay(2013, 1, 4)); } - Y_UNIT_TEST(CivilUnit) { + Y_UNIT_TEST(CivilUnit) { using namespace NDatetime; UNIT_ASSERT_VALUES_EQUAL(GetCivilUnit<TCivilMonth>(), ECivilUnit::Month); diff --git a/library/cpp/timezone_conversion/ut/convert_ut.cpp b/library/cpp/timezone_conversion/ut/convert_ut.cpp index cf25cbaefe..bbf9e9b826 100644 --- a/library/cpp/timezone_conversion/ut/convert_ut.cpp +++ b/library/cpp/timezone_conversion/ut/convert_ut.cpp @@ -4,7 +4,7 @@ using namespace NDatetime; template <> -void Out<TSimpleTM>(IOutputStream& os, TTypeTraits<TSimpleTM>::TFuncParam value) { +void Out<TSimpleTM>(IOutputStream& os, TTypeTraits<TSimpleTM>::TFuncParam value) { os << value.ToString() << ", dst: " << int(value.IsDst); } diff --git a/library/cpp/tld/tld_ut.cpp b/library/cpp/tld/tld_ut.cpp index ee4c1541d8..733200f2b5 100644 --- a/library/cpp/tld/tld_ut.cpp +++ b/library/cpp/tld/tld_ut.cpp @@ -6,8 +6,8 @@ using namespace NTld; -Y_UNIT_TEST_SUITE(TTldTest) { - Y_UNIT_TEST(TestFindTld) { +Y_UNIT_TEST_SUITE(TTldTest) { + Y_UNIT_TEST(TestFindTld) { UNIT_ASSERT(FindTld("yandex.ru") == "ru"); UNIT_ASSERT(FindTld("YandeX.Ru") == "Ru"); UNIT_ASSERT(FindTld("yandex.com.tr") == "tr"); @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TTldTest) { UNIT_ASSERT(FindTld("") == ""); } - Y_UNIT_TEST(TestTLDs) { + Y_UNIT_TEST(TestTLDs) { UNIT_ASSERT(IsTld("ru")); UNIT_ASSERT(IsTld("Ru")); UNIT_ASSERT(IsTld("BMW")); @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(TTldTest) { UNIT_ASSERT(!InTld("ru.xn")); } - Y_UNIT_TEST(TestVeryGoodTlds) { + Y_UNIT_TEST(TestVeryGoodTlds) { UNIT_ASSERT(IsVeryGoodTld("ru")); UNIT_ASSERT(IsVeryGoodTld("Ru")); UNIT_ASSERT(!IsVeryGoodTld("BMW")); diff --git a/library/cpp/tvmauth/client/ut/checker_ut.cpp b/library/cpp/tvmauth/client/ut/checker_ut.cpp index bec6fb1ec7..54a25974c1 100644 --- a/library/cpp/tvmauth/client/ut/checker_ut.cpp +++ b/library/cpp/tvmauth/client/ut/checker_ut.cpp @@ -11,7 +11,7 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ClientChecker) { +Y_UNIT_TEST_SUITE(ClientChecker) { static const TTvmId OK_CLIENT = 100500; static const TString PROD_TICKET = "3:user:CAsQ__________9_Gg4KAgh7EHsg0oXYzAQoAA:N8PvrDNLh-5JywinxJntLeQGDEHBUxfzjuvB8-_BEUv1x9CALU7do8irDlDYVeVVDr4AIpR087YPZVzWPAqmnBuRJS0tJXekmDDvrivLnbRrzY4IUXZ_fImB0fJhTyVetKv6RD11bGqnAJeDpIukBwPTbJc_EMvKDt8V490CJFw"; static const TString TEST_TICKET = "3:user:CA0Q__________9_Gg4KAgh7EHsg0oXYzAQoAQ:FSADps3wNGm92Vyb1E9IVq5M6ZygdGdt1vafWWEhfDDeCLoVA-sJesxMl2pGW4OxJ8J1r_MfpG3ZoBk8rLVMHUFrPa6HheTbeXFAWl8quEniauXvKQe4VyrpA1SPgtRoFqi5upSDIJzEAe1YRJjq1EClQ_slMt8R0kA_JjKUX54"; @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(ClientChecker) { static const TString STRESS_TICKET = "3:user:CA8Q__________9_Gg4KAgh7EHsg0oXYzAQoBA:GBuG_TLo6SL2OYFxp7Zly04HPNzmAF7Fu2E8E9SnwQDoxq9rf7VThSPtTmnBSAl5UVRRPkMsRtzzHZ87qtj6l-PvF0K7PrDu7-yS_xiFTgAl9sEfXAIHJVzZLoksGRgpoBtpBUg9vVaJsPns0kWFKJgq8M-Mk9agrSk7sb2VUeQ"; static const TString SRV_TICKET = "3:serv:CBAQ__________9_IgYIexCUkQY:GioCM49Ob6_f80y6FY0XBVN4hLXuMlFeyMvIMiDuQnZkbkLpRpQOuQo5YjWoBjM0Vf-XqOm8B7xtrvxSYHDD7Q4OatN2l-Iwg7i71lE3scUeD36x47st3nd0OThvtjrFx_D8mw_c0GT5KcniZlqq1SjhLyAk1b_zJsx8viRAhCU"; - Y_UNIT_TEST(User) { + Y_UNIT_TEST(User) { NTvmApi::TClientSettings s; s.SetSelfTvmId(OK_CLIENT); s.EnableServiceTicketChecking(); @@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(ClientChecker) { } } - Y_UNIT_TEST(Service) { + Y_UNIT_TEST(Service) { NTvmApi::TClientSettings s; s.EnableUserTicketChecking(EBlackboxEnv::Stress); s.SetSelfTvmId(OK_CLIENT); @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(ClientChecker) { UNIT_ASSERT_C(l->Stream.Str().find("was successfully fetched") == TString::npos, l->Stream.Str()); } - Y_UNIT_TEST(Tickets) { + Y_UNIT_TEST(Tickets) { NTvmApi::TClientSettings s; s.SetSelfTvmId(OK_CLIENT); s.EnableServiceTicketsFetchOptions("qwerty", {{"blackbox", 19}}); diff --git a/library/cpp/tvmauth/client/ut/disk_cache_ut.cpp b/library/cpp/tvmauth/client/ut/disk_cache_ut.cpp index 48f4877a52..7dd851c9b3 100644 --- a/library/cpp/tvmauth/client/ut/disk_cache_ut.cpp +++ b/library/cpp/tvmauth/client/ut/disk_cache_ut.cpp @@ -16,15 +16,15 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ClientDisk) { - Y_UNIT_TEST(Hash) { +Y_UNIT_TEST_SUITE(ClientDisk) { + Y_UNIT_TEST(Hash) { TString hash = TDiskReader::GetHash("asd"); UNIT_ASSERT(hash); UNIT_ASSERT_VALUES_EQUAL(32, hash.size()); UNIT_ASSERT_VALUES_EQUAL("Zj5_qYg31bPlqjBW76z8IV0rCsHmv-iN-McV6ybS1-g", NUtils::Bin2base64url(hash)); } - Y_UNIT_TEST(Timestamp) { + Y_UNIT_TEST(Timestamp) { time_t t = 100500; TString s = TDiskWriter::WriteTimestamp(t); @@ -44,7 +44,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { const TInstant TIME = TInstant::Seconds(100500); const TString DATA = "oiweuhn \n vw3ut hweoi uhgewproritjhwequtherwoiughfdsv 8ty34q01u 34 1=3"; - Y_UNIT_TEST(ParseData_Ok) { + Y_UNIT_TEST(ParseData_Ok) { TLogger l; const TInstant time = TInstant::Seconds(1523446554789); @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { l.Stream.Str()); } - Y_UNIT_TEST(ParseData_SmallFile) { + Y_UNIT_TEST(ParseData_SmallFile) { TLogger l; TString toFile = TDiskWriter::PrepareData(TIME, DATA); @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { l.Stream.Str()); } - Y_UNIT_TEST(ParseData_Changed) { + Y_UNIT_TEST(ParseData_Changed) { TLogger l; TString toFile = TDiskWriter::PrepareData(TIME, DATA); @@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { l.Stream.Str()); } - Y_UNIT_TEST(Read_Ok) { + Y_UNIT_TEST(Read_Ok) { TLogger l; TDiskReader r(GetFilePath("ok.cache"), &l); @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { UNIT_ASSERT_C(l.Stream.Str().find("was successfully read") != TString::npos, l.Stream.Str()); } - Y_UNIT_TEST(Read_NoFile) { + Y_UNIT_TEST(Read_NoFile) { TLogger l; TDiskReader r("missing", &l); @@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { } #ifdef _unix_ - Y_UNIT_TEST(Read_NoPermitions) { + Y_UNIT_TEST(Read_NoPermitions) { TLogger l; const TString path = GetWorkPath() + "/123"; @@ -121,7 +121,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { } #endif - Y_UNIT_TEST(Write_Ok) { + Y_UNIT_TEST(Write_Ok) { TLogger l; const TString path = "./tmp_file"; @@ -139,7 +139,7 @@ Y_UNIT_TEST_SUITE(ClientDisk) { NFs::Remove(path); } - Y_UNIT_TEST(Write_NoPermitions) { + Y_UNIT_TEST(Write_NoPermitions) { TLogger l; TDiskWriter w("/some_file", &l); diff --git a/library/cpp/tvmauth/client/ut/facade_ut.cpp b/library/cpp/tvmauth/client/ut/facade_ut.cpp index d839aa4669..62e8e6c731 100644 --- a/library/cpp/tvmauth/client/ut/facade_ut.cpp +++ b/library/cpp/tvmauth/client/ut/facade_ut.cpp @@ -9,7 +9,7 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ClientFacade) { +Y_UNIT_TEST_SUITE(ClientFacade) { static const TTvmId OK_CLIENT = 100500; static const TString SRV_TICKET_123 = "3:serv:CBAQ__________9_IgYIexCUkQY:GioCM49Ob6_f80y6FY0XBVN4hLXuMlFeyMvIMiDuQnZkbkLpRpQOuQo5YjWoBjM0Vf-XqOm8B7xtrvxSYHDD7Q4OatN2l-Iwg7i71lE3scUeD36x47st3nd0OThvtjrFx_D8mw_c0GT5KcniZlqq1SjhLyAk1b_zJsx8viRAhCU"; static const TString SRV_TICKET_456 = "3:serv:CBAQ__________9_IgcIyAMQlJEG:VrnqRhpoiDnJeAQbySJluJ1moQ5Kemic99iWzOrHLGfuh7iTw_xMT7KewRAmZMUwDKzE6otj7V86Xsnxbv5xZl8746wbvNcyUXu-nGWmbByZjO7xpSIcY07sISqEhP9n9C_yMSvqDP7ho_PRIfpGCDMXxKlFZ_BhBLLp0kHEvw4"; @@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(ClientFacade) { return f; } - Y_UNIT_TEST(Service) { + Y_UNIT_TEST(Service) { NTvmApi::TClientSettings s; s.SetSelfTvmId(OK_CLIENT); s.EnableServiceTicketChecking(); @@ -44,7 +44,7 @@ Y_UNIT_TEST_SUITE(ClientFacade) { UNIT_ASSERT_EXCEPTION(f.CheckUserTicket(TEST_TICKET), yexception); } - Y_UNIT_TEST(User) { + Y_UNIT_TEST(User) { NTvmApi::TClientSettings s; s.EnableUserTicketChecking(EBlackboxEnv::Prod); s.SetDiskCacheDir(GetCachePath()); @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(ClientFacade) { UNIT_ASSERT(!f.CheckUserTicket(TEST_TICKET)); } - Y_UNIT_TEST(Ctors) { + Y_UNIT_TEST(Ctors) { NTvmApi::TClientSettings s; s.EnableUserTicketChecking(EBlackboxEnv::Prod); s.SetDiskCacheDir(GetCachePath()); @@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(ClientFacade) { v.front() = std::move(*v.begin()); } - Y_UNIT_TEST(Tickets) { + Y_UNIT_TEST(Tickets) { NTvmApi::TClientSettings s; s.SetSelfTvmId(OK_CLIENT); s.EnableServiceTicketsFetchOptions("qwerty", {{"blackbox", 19}}); diff --git a/library/cpp/tvmauth/client/ut/logger_ut.cpp b/library/cpp/tvmauth/client/ut/logger_ut.cpp index eded8528df..76236e8913 100644 --- a/library/cpp/tvmauth/client/ut/logger_ut.cpp +++ b/library/cpp/tvmauth/client/ut/logger_ut.cpp @@ -6,35 +6,35 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ClientLogger) { +Y_UNIT_TEST_SUITE(ClientLogger) { int i = 0; - Y_UNIT_TEST(Debug) { + Y_UNIT_TEST(Debug) { TLogger l; l.Debug("qwerty"); UNIT_ASSERT_VALUES_EQUAL("7: qwerty\n", l.Stream.Str()); } - Y_UNIT_TEST(Info) { + Y_UNIT_TEST(Info) { TLogger l; l.Info("qwerty"); UNIT_ASSERT_VALUES_EQUAL("6: qwerty\n", l.Stream.Str()); } - Y_UNIT_TEST(Warning) { + Y_UNIT_TEST(Warning) { TLogger l; l.Warning("qwerty"); UNIT_ASSERT_VALUES_EQUAL("4: qwerty\n", l.Stream.Str()); } - Y_UNIT_TEST(Error) { + Y_UNIT_TEST(Error) { TLogger l; l.Error("qwerty"); UNIT_ASSERT_VALUES_EQUAL("3: qwerty\n", l.Stream.Str()); } #ifdef _unix_ - Y_UNIT_TEST(Cerr_) { + Y_UNIT_TEST(Cerr_) { TCerrLogger l(5); l.Error("hit"); l.Debug("miss"); diff --git a/library/cpp/tvmauth/client/ut/settings_ut.cpp b/library/cpp/tvmauth/client/ut/settings_ut.cpp index 47554dd73d..76c9542442 100644 --- a/library/cpp/tvmauth/client/ut/settings_ut.cpp +++ b/library/cpp/tvmauth/client/ut/settings_ut.cpp @@ -6,7 +6,7 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ClientSettings) { +Y_UNIT_TEST_SUITE(ClientSettings) { #if !defined(_win_) Y_UNIT_TEST(CheckValid) { struct TTestCase { diff --git a/library/cpp/tvmauth/src/rw/ut/rw_ut.cpp b/library/cpp/tvmauth/src/rw/ut/rw_ut.cpp index 94f58b3332..73f1b1d769 100644 --- a/library/cpp/tvmauth/src/rw/ut/rw_ut.cpp +++ b/library/cpp/tvmauth/src/rw/ut/rw_ut.cpp @@ -127,14 +127,14 @@ namespace NTvmAuth { } using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(Rw) { - Y_UNIT_TEST(SignVerify) { +Y_UNIT_TEST_SUITE(Rw) { + Y_UNIT_TEST(SignVerify) { for (int i = 1; i < 10; ++i) { UNIT_ASSERT_VALUES_EQUAL(1, TestSignVerify()); } } - Y_UNIT_TEST(TKeysPriv) { + Y_UNIT_TEST(TKeysPriv) { NRw::TRwPrivateKey priv(Base64Decode("MIIEmwKCAQBwsRd4frsVARIVSfj_vCdfvA3Q9SsGhSybdBDhbm8L6rPqxdoSNLCdNXzDWj7Ppf0o8uWHMxC-5Lfw0I18ri68nhm9-ndixcnbn6ti1uetgkc28eiEP6Q8ILD_JmkynbUl1aKDNAa5XsK2vFSEX402uydRomsTn46kRY23hfqcIi0ohh5VxIrpclRsRZus0JFu-RJzhqTbKYV4y4dglWPGHh5BuTv9k_Oh0_Ra8Xp5Rith5vjaKZUQ5Hyh9UtBYTkNWdvXP9OpmbiLVeRLuMzBm4HEFHDwMZ1h6LSVP-wB_spJPaMLTn3Q3JIHe-wGBYRWzU51RRYDqv4O_H12w5C1AoGBALAwCQ7fdAPG1lGclL7iWFjUofwPCFwPyDjicDT_MRRu6_Ta4GjqOGO9zuOp0o_ePgvR-7nA0fbaspM4LZNrPZwmoYBCJMtKXetg68ylu2DO-RRSN2SSh1AIZSA_8UTABk69bPzNL31j4PyZWxrgZ3zP9uZvzggveuKt5ZhCMoB7AoGBAKO9oC2AZjLdh2RaEFotTL_dY6lVcm38VA6PnigB8gB_TMuSrd4xtRw5BxvHpOCnBcUAJE0dN4_DDe5mrotKYMD2_3_lcq9PaLZadrPDCSDL89wtoVxNQNAJTqFjBFXYNu4Ze63lrsqg45TF5XmVRemyBHzXw3erd0pJaeoUDaSPAoGAJhGoHx_nVw8sDoLzeRkOJ1_6-uh_wVmVr6407_LPjrrySEq-GiYu43M3-QDp8J_J9e3S1Rpm4nQX2bEf5Gx9n4wKz7Hp0cwkOqBOWhvrAu6YLpv59wslEtkx0LYcJy6yQk5mpU8l29rPO7b50NyLnfnE2za-9DyK038FKlr5VgICgYAUd7QFsAzGW7Dsi0ILRamX-6x1Kq5Nv4qB0fPFAD5AD-mZclW7xjajhyDjePScFOC4oASJo6bx-GG9zNXRaUwYHt_v_K5V6e0Wy07WeGEkGX57hbQriagaASnULGCKuwbdwy91vLXZVBxymLyvMqi9NkCPmvhu9W7pSS09QoG0kgKBgBYGASHb7oB42sozkpfcSwsalD-B4QuB-QccTgaf5iKN3X6bXA0dRwx3udx1OlH7x8F6P3c4Gj7bVlJnBbJtZ7OE1DAIRJlpS71sHXmUt2wZ3yKKRuySUOoBDKQH_iiYAMnXrZ-Zpe-sfB-TK2NcDO-Z_tzN-cEF71xVvLMIRlAPAoGAdeikZPh1O57RxnVY72asiMRZheMBhK-9uSNPyYEZv3bUnIjg4XdMYStF2yTHNu014XvkDSQTe-drv2BDs9ExKplM4xFOtDtPQQ3mMB3GoK1qVhM_9n1QEElreurMicahkalnPo6tU4Z6PFL7PTpjRnCN67lJp0J0fxNDL13YSagCgYBA9VJrMtPjzcAx5ZCIYJjrYUPqEG_ttQN2RJIHN3MVpdpLAMIgX3tnlfyLwQFVKK45D1JgFa_1HHcxTWGtdIX4nsIjPWt-cWCCCkkw9rM5_Iqcb-YLSood6IP2OK0w0XLD1STnFRy_BRwdjPbGOYmp6YrJDZAlajDkFSdRvsz9Vg=="), 0); NRw::TRwPrivateKey priv2(Base64Decode("MIIEnAKCAQEA4RATOfumLD1n6ICrW5biaAl9VldinczmkNPjpUWwc3gs8PnkCrtdnPFmpBwW3gjHdSNU1OuEg5A6K1o1xiGv9sU-jd88zQBOdK6E2zwnJnkK6bNusKE2H2CLqg3aMWCmTa9JbzSy1uO7wa-xCqqNUuCko-2lyv12HhL1ICIH951SHDa4qO1U5xZhhlUAnqWi9R4tYDeMiF41WdOjwT2fg8UkbusThmxa3yjCXjD7OyjshPtukN8Tl3UyGtV_s2CLnE3f28VAi-AVW8FtgL22xbGhuyEplXRrtF1E5oV7NSqxH1FS0SYROA8ffYQGV5tfx5WDFHiXDEP6BzoVfeBDRQKBgQDzidelKZNFMWar_yj-r_cniMkZXNaNVEQbMg1A401blGjkU1r-ufGH5mkdNx4IgEoCEYBTM834Z88fYV1lOVfdT0OqtiVoC9NkLu3xhQ1r9_r6RMaAenwsV7leH8jWMOKvhkB0KNI49oznTGDqLp0AbDbtP66xdNH4dr3rw3WFywKBgQDslDdv4sdnRKN27h2drhn4Pp_Lgw2U-6MfHiyjp6BKR8Qtlld3hdb-ZjU9F0h38DqECmFIEe35_flKfd7X21CBQs9EuKR8EdaF3OAgzA-TRWeQhyHmaV7Fas1RlNqZHm8lckaZT8dX9Ygsxn0I_vUbm9pkFivwGvQnnwNQ7Te5LwKBgCVMYOzLHW911l6EbCZE6XU2HUrTKEd1bdqWCgtxPEmDl3BZcXpnyKpqSHmlH1F7s65WBfejxDM2hjin3OnXSog_x35ql_-Azu93-79QAzbQc6Z13BuWPpQxV8iw4ijqRRhzjD2pcvXlIxgebp5-H0eDt-Md2Y8rkrzyhm8EH7mwAoGAHZKG7fxY7OiUbt3Ds7XDPwfT-XBhsp90Y-PFlHT0CUj4hbLK7vC638zGp6LpDv4HUIFMKQI9vz-_KU-72vtqEChZ6JcUj4I60LucBBmB8mis8hDkPM0r2K1ZqjKbUyPN5K5I0yn46v6xBZjPoR_eo3N7TILFfgNehPPgah2m9yYCgYAecTr0pTJopizVf-Uf1f7k8RkjK5rRqoiDZkGoHGmrco0cimtf1z4w_M0jpuPBEAlAQjAKZnm_DPnj7Cuspyr7qeh1VsStAXpshd2-MKGtfv9fSJjQD0-Fivcrw_kaxhxV8MgOhRpHHtGc6YwdRdOgDYbdp_XWLpo_Dte9eG6wuQKBgDzo0e8d8pTyvCP23825rVzvrSHBZkliGkCEu0iggDnfKOreejFhQN9JeBo8sYdQFCRBptEU6k4b5O6J3NQ1Sspiez15ddqmFMD4uhJY6VsV-JFnL9YhLqVd355xZCyU4b07mReU9-LuqK2m2chjxH_HDAgUoEvO_yzR9EDYqHbNAoGAf529Ah9HIT5aG6IGTlwQdk-M7guy63U4vj4uC7z98qgvFEsV6cr4miT6RE8Aw5yAeN5pW59rZNjBNr9i-8n8kouasho2xNMTPKP8YuSNg2PNNS5T1Ou56mgsBCY5i10TIHKNIm2RVSUgzJ97BMEOZY6jQRytFfwgYkvnFzbuA9c="), @@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(Rw) { UNIT_ASSERT(!priv.SignTicket("").empty()); } - Y_UNIT_TEST(TKeysPub) { + Y_UNIT_TEST(TKeysPub) { NRw::TRwPublicKey pub(Base64Decode("MIIBBAKCAQBwsRd4frsVARIVSfj_vCdfvA3Q9SsGhSybdBDhbm8L6rPqxdoSNLCdNXzDWj7Ppf0o8uWHMxC-5Lfw0I18ri68nhm9-ndixcnbn6ti1uetgkc28eiEP6Q8ILD_JmkynbUl1aKDNAa5XsK2vFSEX402uydRomsTn46kRY23hfqcIi0ohh5VxIrpclRsRZus0JFu-RJzhqTbKYV4y4dglWPGHh5BuTv9k_Oh0_Ra8Xp5Rith5vjaKZUQ5Hyh9UtBYTkNWdvXP9OpmbiLVeRLuMzBm4HEFHDwMZ1h6LSVP-wB_spJPaMLTn3Q3JIHe-wGBYRWzU51RRYDqv4O_H12w5C1")); NRw::TRwPublicKey pub2(Base64Decode("MIIBBQKCAQEA4RATOfumLD1n6ICrW5biaAl9VldinczmkNPjpUWwc3gs8PnkCrtdnPFmpBwW3gjHdSNU1OuEg5A6K1o1xiGv9sU-jd88zQBOdK6E2zwnJnkK6bNusKE2H2CLqg3aMWCmTa9JbzSy1uO7wa-xCqqNUuCko-2lyv12HhL1ICIH951SHDa4qO1U5xZhhlUAnqWi9R4tYDeMiF41WdOjwT2fg8UkbusThmxa3yjCXjD7OyjshPtukN8Tl3UyGtV_s2CLnE3f28VAi-AVW8FtgL22xbGhuyEplXRrtF1E5oV7NSqxH1FS0SYROA8ffYQGV5tfx5WDFHiXDEP6BzoVfeBDRQ==")); NRw::TRwPublicKey pub3(Base64Decode("MIGDAoGAX23ZgkYAmRFEWrp9aGLebVMVbVQ4TR_pmt9iEcCSmoaUqWHRBV95M0-l4mGLvnFfMJ7qhF5FSb7QNuoM2FNKELu4ZS_Ug1idEFBYfoT7kVzletsMVK4ZDDYRiM18fL8d58clfFAoCo-_EEMowqQeBXnxa0zqsLyNGL2x1f-KDY0=")); @@ -161,7 +161,7 @@ Y_UNIT_TEST_SUITE(Rw) { UNIT_ASSERT(!pub.CheckSign("~~~", "~~~")); } - Y_UNIT_TEST(TKeys) { + Y_UNIT_TEST(TKeys) { NRw::TRwPrivateKey priv(Base64Decode("MIIEmwKCAQBwsRd4frsVARIVSfj_vCdfvA3Q9SsGhSybdBDhbm8L6rPqxdoSNLCdNXzDWj7Ppf0o8uWHMxC-5Lfw0I18ri68nhm9-ndixcnbn6ti1uetgkc28eiEP6Q8ILD_JmkynbUl1aKDNAa5XsK2vFSEX402uydRomsTn46kRY23hfqcIi0ohh5VxIrpclRsRZus0JFu-RJzhqTbKYV4y4dglWPGHh5BuTv9k_Oh0_Ra8Xp5Rith5vjaKZUQ5Hyh9UtBYTkNWdvXP9OpmbiLVeRLuMzBm4HEFHDwMZ1h6LSVP-wB_spJPaMLTn3Q3JIHe-wGBYRWzU51RRYDqv4O_H12w5C1AoGBALAwCQ7fdAPG1lGclL7iWFjUofwPCFwPyDjicDT_MRRu6_Ta4GjqOGO9zuOp0o_ePgvR-7nA0fbaspM4LZNrPZwmoYBCJMtKXetg68ylu2DO-RRSN2SSh1AIZSA_8UTABk69bPzNL31j4PyZWxrgZ3zP9uZvzggveuKt5ZhCMoB7AoGBAKO9oC2AZjLdh2RaEFotTL_dY6lVcm38VA6PnigB8gB_TMuSrd4xtRw5BxvHpOCnBcUAJE0dN4_DDe5mrotKYMD2_3_lcq9PaLZadrPDCSDL89wtoVxNQNAJTqFjBFXYNu4Ze63lrsqg45TF5XmVRemyBHzXw3erd0pJaeoUDaSPAoGAJhGoHx_nVw8sDoLzeRkOJ1_6-uh_wVmVr6407_LPjrrySEq-GiYu43M3-QDp8J_J9e3S1Rpm4nQX2bEf5Gx9n4wKz7Hp0cwkOqBOWhvrAu6YLpv59wslEtkx0LYcJy6yQk5mpU8l29rPO7b50NyLnfnE2za-9DyK038FKlr5VgICgYAUd7QFsAzGW7Dsi0ILRamX-6x1Kq5Nv4qB0fPFAD5AD-mZclW7xjajhyDjePScFOC4oASJo6bx-GG9zNXRaUwYHt_v_K5V6e0Wy07WeGEkGX57hbQriagaASnULGCKuwbdwy91vLXZVBxymLyvMqi9NkCPmvhu9W7pSS09QoG0kgKBgBYGASHb7oB42sozkpfcSwsalD-B4QuB-QccTgaf5iKN3X6bXA0dRwx3udx1OlH7x8F6P3c4Gj7bVlJnBbJtZ7OE1DAIRJlpS71sHXmUt2wZ3yKKRuySUOoBDKQH_iiYAMnXrZ-Zpe-sfB-TK2NcDO-Z_tzN-cEF71xVvLMIRlAPAoGAdeikZPh1O57RxnVY72asiMRZheMBhK-9uSNPyYEZv3bUnIjg4XdMYStF2yTHNu014XvkDSQTe-drv2BDs9ExKplM4xFOtDtPQQ3mMB3GoK1qVhM_9n1QEElreurMicahkalnPo6tU4Z6PFL7PTpjRnCN67lJp0J0fxNDL13YSagCgYBA9VJrMtPjzcAx5ZCIYJjrYUPqEG_ttQN2RJIHN3MVpdpLAMIgX3tnlfyLwQFVKK45D1JgFa_1HHcxTWGtdIX4nsIjPWt-cWCCCkkw9rM5_Iqcb-YLSood6IP2OK0w0XLD1STnFRy_BRwdjPbGOYmp6YrJDZAlajDkFSdRvsz9Vg=="), 0); NRw::TRwPublicKey pub(Base64Decode("MIIBBAKCAQBwsRd4frsVARIVSfj_vCdfvA3Q9SsGhSybdBDhbm8L6rPqxdoSNLCdNXzDWj7Ppf0o8uWHMxC-5Lfw0I18ri68nhm9-ndixcnbn6ti1uetgkc28eiEP6Q8ILD_JmkynbUl1aKDNAa5XsK2vFSEX402uydRomsTn46kRY23hfqcIi0ohh5VxIrpclRsRZus0JFu-RJzhqTbKYV4y4dglWPGHh5BuTv9k_Oh0_Ra8Xp5Rith5vjaKZUQ5Hyh9UtBYTkNWdvXP9OpmbiLVeRLuMzBm4HEFHDwMZ1h6LSVP-wB_spJPaMLTn3Q3JIHe-wGBYRWzU51RRYDqv4O_H12w5C1")); @@ -180,7 +180,7 @@ Y_UNIT_TEST_SUITE(Rw) { Base64Decode("FeMZtDP-yuoNqK2HYw3JxTV9v7p8IoQEuRMtuHddafh4bq1ZOeEqg7g7Su6M3iq_kN9DZ_fVhuhuVcbZmNYPIvJ8oL5DE80KI3d1Qbs9mS8_X4Oq2TJpZgNfFG-z_LPRZSNRP9Q8sQhlAoSZHOSZkBFcYj1EuqEp6nSSSbX8Ji4Se-TfhIh3YFQkr-Ivk_3NmSXhDXUaW7CHo2rVm58QJ2cgSEuxzBH-Q8E8tGDCEmk4p3_iot9XY8RRN-_j0yi15etmXCUIKFbpDogtHdT8CyAEVHMYvsLqkLux9pzy3RdvNQmoPjol3wIm-H0wMtF_pMw4G2QLNev6he6xWeckxw=="))); } - Y_UNIT_TEST(Keygen) { + Y_UNIT_TEST(Keygen) { for (size_t idx = 0; idx < 100; ++idx) { NRw::TKeyPair pair = NRw::GenKeyPair(1024); NRw::TRwPrivateKey priv(pair.Private, 0); diff --git a/library/cpp/tvmauth/src/ut/parser_ut.cpp b/library/cpp/tvmauth/src/ut/parser_ut.cpp index e5c892c6d9..530f45331a 100644 --- a/library/cpp/tvmauth/src/ut/parser_ut.cpp +++ b/library/cpp/tvmauth/src/ut/parser_ut.cpp @@ -6,10 +6,10 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(ParserTestSuite) { +Y_UNIT_TEST_SUITE(ParserTestSuite) { using namespace NTvmAuth; - Y_UNIT_TEST(Keys) { + Y_UNIT_TEST(Keys) { UNIT_ASSERT_EXCEPTION(TParserTvmKeys::ParseStrV1("2:asds"), TMalformedTvmKeysException); UNIT_ASSERT_EXCEPTION(TParserTvmKeys::ParseStrV1("3:asds"), TMalformedTvmKeysException); UNIT_ASSERT_EXCEPTION(TParserTvmKeys::ParseStrV1("1:+a/sds"), TMalformedTvmKeysException); @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(ParserTestSuite) { UNIT_ASSERT_VALUES_EQUAL("sdsd", NUtils::Bin2base64url(TParserTvmKeys::ParseStrV1("1:sdsd"))); } - Y_UNIT_TEST(TicketsStrV3) { + Y_UNIT_TEST(TicketsStrV3) { UNIT_ASSERT_EQUAL(TParserTickets::TStrRes({ETicketStatus::Ok, NUtils::Base64url2bin("CgYIDRCUkQYQDBgcIgdiYjpzZXNzIghiYjpzZXNzMg"), NUtils::Base64url2bin("ERmeH_yzC7K_QsoHTyw7llCsyExEz3CoEopPIuivA0ZAtTaFq_Pa0l9Fhhx_NX9WpOp2CPyY5cFc4PXhcO83jCB7-EGvHNxGN-j2NQalERzPiKqkDCO0Q5etLzSzrfTlvMz7sXDvELNBHyA0PkAQnbz4supY0l-0Q6JBYSEF3zOVMjjE-HeQIFL3ats3_PakaUMWRvgQQ88pVdYZqAtbDw9PlTla7ommygVZQjcfNFXV1pJKRgOCLs-YyCjOJHLKL04zYj0X6KsOCTUeqhj7ml96wLZ-g1X9tyOR2WAr2Ctq7wIEHwqhxOLgOSKqm05xH6Vi3E_hekf50oe2jPfKEA"), @@ -88,7 +88,7 @@ Y_UNIT_TEST_SUITE(ParserTestSuite) { TParserTickets::ServiceFlag())); } - Y_UNIT_TEST(TicketsV3) { + Y_UNIT_TEST(TicketsV3) { NRw::TPublicKeys pub; UNIT_ASSERT_EQUAL(ETicketStatus::Malformed, diff --git a/library/cpp/tvmauth/src/ut/public_ut.cpp b/library/cpp/tvmauth/src/ut/public_ut.cpp index ffecee5b47..74a483d57b 100644 --- a/library/cpp/tvmauth/src/ut/public_ut.cpp +++ b/library/cpp/tvmauth/src/ut/public_ut.cpp @@ -10,8 +10,8 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(CommonPublicInterfaceTestSuite){ - Y_UNIT_TEST(StatusTest){ +Y_UNIT_TEST_SUITE(CommonPublicInterfaceTestSuite){ + Y_UNIT_TEST(StatusTest){ UNIT_ASSERT_VALUES_EQUAL("OK", StatusToString(ETicketStatus::Ok)); UNIT_ASSERT_VALUES_EQUAL("Expired ticket", @@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(CommonPublicInterfaceTestSuite){ } } -Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { +Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { static const TString EMPTY_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAE"; static const TString EXPIRED_SERVICE_TICKET = "3:serv:CBAQACIZCOUBEBwaCGJiOnNlc3MxGghiYjpzZXNzMg:IwfMNJYEqStY_SixwqJnyHOMCPR7-3HHk4uylB2oVRkthtezq-OOA7QizDvx7VABLs_iTlXuD1r5IjufNei_EiV145eaa3HIg4xCdJXCojMexf2UYJz8mF2b0YzFAy6_KWagU7xo13CyKAqzJuQf5MJcSUf0ecY9hVh36cJ51aw"; static const TString MALFORMED_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAEEpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQYSlQEKkgEIEBAAGocBMIGEAoGBALhrihbf3EpjDQS2sCQHazoFgN0nBbE9eesnnFTfzQELXb2gnJU9enmV_aDqaHKjgtLIPpCgn40lHrn5k6mvH5OdedyI6cCzE-N-GFp3nAq0NDJyMe0fhtIRD__CbT0ulcvkeow65ubXWfw6dBC2gR_34rdMe_L_TGRLMWjDULbNIJ"; @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { UNIT_ASSERT_VALUES_EQUAL("239", NBlackboxTvmId::Mimino); } - Y_UNIT_TEST(Case1Test) { + Y_UNIT_TEST(Case1Test) { TServiceContext context1(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); TServiceContext context2 = std::move(context1); TServiceContext context3(std::move(context2)); @@ -69,20 +69,20 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket3.GetStatus()); } - Y_UNIT_TEST(ContextExceptionsTest) { + Y_UNIT_TEST(ContextExceptionsTest) { UNIT_ASSERT_EXCEPTION(TServiceContext(SECRET, OUR_ID, MALFORMED_TVM_KEYS), TMalformedTvmKeysException); UNIT_ASSERT_EXCEPTION(TServiceContext(SECRET, OUR_ID, EMPTY_TVM_KEYS), TEmptyTvmKeysException); UNIT_ASSERT_EXCEPTION(TServiceContext(MALFORMED_TVM_SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS), TMalformedTvmSecretException); } - Y_UNIT_TEST(ContextSignTest) { + Y_UNIT_TEST(ContextSignTest) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_VALUES_EQUAL( "NsPTYak4Cfk-4vgau5lab3W4GPiTtb2etuj3y4MDPrk", context.SignCgiParamsForTvm(IntToString<10>(std::numeric_limits<time_t>::max()), "13,28", "")); } - Y_UNIT_TEST(ContextSignExceptionTest) { + Y_UNIT_TEST(ContextSignExceptionTest) { TServiceContext context = TServiceContext::CheckingFactory(OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_EXCEPTION( context.SignCgiParamsForTvm(IntToString<10>(std::numeric_limits<time_t>::max()), "13,28", ""), @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { ); } - Y_UNIT_TEST(ContextCheckExceptionTest) { + Y_UNIT_TEST(ContextCheckExceptionTest) { TServiceContext context = TServiceContext::CheckingFactory(OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_NO_EXCEPTION( context.Check("ABCDE") @@ -109,12 +109,12 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { } - Y_UNIT_TEST(ContextTest) { + Y_UNIT_TEST(ContextTest) { TServiceContext context1(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); TServiceContext context2 = TServiceContext::CheckingFactory(OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); } - Y_UNIT_TEST(Ticket1Test) { + Y_UNIT_TEST(Ticket1Test) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); @@ -122,28 +122,28 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { UNIT_ASSERT_EQUAL("ticket_type=serv;expiration_time=9223372036854775807;src=229;dst=28;scope=bb:sess1;scope=bb:sess2;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(Ticket2Test) { + Y_UNIT_TEST(Ticket2Test) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_2); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=serv;expiration_time=9223372036854775807;src=229;dst=28;scope=bb:sess1;scope=bb:sess10;scope=bb:sess100;scope=bb:sess11;scope=bb:sess12;scope=bb:sess13;scope=bb:sess14;scope=bb:sess15;scope=bb:sess16;scope=bb:sess17;scope=bb:sess18;scope=bb:sess19;scope=bb:sess2;scope=bb:sess20;scope=bb:sess21;scope=bb:sess22;scope=bb:sess23;scope=bb:sess24;scope=bb:sess25;scope=bb:sess26;scope=bb:sess27;scope=bb:sess28;scope=bb:sess29;scope=bb:sess3;scope=bb:sess30;scope=bb:sess31;scope=bb:sess32;scope=bb:sess33;scope=bb:sess34;scope=bb:sess35;scope=bb:sess36;scope=bb:sess37;scope=bb:sess38;scope=bb:sess39;scope=bb:sess4;scope=bb:sess40;scope=bb:sess41;scope=bb:sess42;scope=bb:sess43;scope=bb:sess44;scope=bb:sess45;scope=bb:sess46;scope=bb:sess47;scope=bb:sess48;scope=bb:sess49;scope=bb:sess5;scope=bb:sess50;scope=bb:sess51;scope=bb:sess52;scope=bb:sess53;scope=bb:sess54;scope=bb:sess55;scope=bb:sess56;scope=bb:sess57;scope=bb:sess58;scope=bb:sess59;scope=bb:sess6;scope=bb:sess60;scope=bb:sess61;scope=bb:sess62;scope=bb:sess63;scope=bb:sess64;scope=bb:sess65;scope=bb:sess66;scope=bb:sess67;scope=bb:sess68;scope=bb:sess69;scope=bb:sess7;scope=bb:sess70;scope=bb:sess71;scope=bb:sess72;scope=bb:sess73;scope=bb:sess74;scope=bb:sess75;scope=bb:sess76;scope=bb:sess77;scope=bb:sess78;scope=bb:sess79;scope=bb:sess8;scope=bb:sess80;scope=bb:sess81;scope=bb:sess82;scope=bb:sess83;scope=bb:sess84;scope=bb:sess85;scope=bb:sess86;scope=bb:sess87;scope=bb:sess88;scope=bb:sess89;scope=bb:sess9;scope=bb:sess90;scope=bb:sess91;scope=bb:sess92;scope=bb:sess93;scope=bb:sess94;scope=bb:sess95;scope=bb:sess96;scope=bb:sess97;scope=bb:sess98;scope=bb:sess99;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(Ticket3Test) { + Y_UNIT_TEST(Ticket3Test) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_3); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=serv;expiration_time=9223372036854775807;src=229;dst=28;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(TicketCheckingTest) { + Y_UNIT_TEST(TicketCheckingTest) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto ticket = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, ticket.GetStatus()); UNIT_ASSERT_EQUAL(SRC_ID, ticket.GetSrc()); } - Y_UNIT_TEST(TicketErrorsTest) { + Y_UNIT_TEST(TicketErrorsTest) { TServiceContext context(SECRET, NOT_OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket1 = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::InvalidDst, checkedTicket1.GetStatus()); @@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { UNIT_ASSERT_EQUAL(ETicketStatus::Expired, checkedTicket3.GetStatus()); } - Y_UNIT_TEST(TicketExceptionsTest) { + Y_UNIT_TEST(TicketExceptionsTest) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(EXPIRED_SERVICE_TICKET); UNIT_ASSERT_EQUAL(ETicketStatus::Expired, checkedTicket.GetStatus()); @@ -167,7 +167,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { UNIT_ASSERT_NO_EXCEPTION(checkedTicket.GetStatus()); } - Y_UNIT_TEST(RemoveSignatureTest) { + Y_UNIT_TEST(RemoveSignatureTest) { UNIT_ASSERT_VALUES_EQUAL("1:serv:ASDkljbjhsdbfLJHABFJHBslfbsfjs:asdxcvbxcvniueliuweklsvds", NUtils::RemoveTicketSignature("1:serv:ASDkljbjhsdbfLJHABFJHBslfbsfjs:asdxcvbxcvniueliuweklsvds")); UNIT_ASSERT_VALUES_EQUAL("2:serv:ASDkljbjhsdbfLJHABFJHBslfbsfjs:asdxcvbxcvniueliuweklsvds", @@ -186,14 +186,14 @@ Y_UNIT_TEST_SUITE(PublicInterfaceServiceTestSuite) { NUtils::RemoveTicketSignature("asdxcbvfgdsgfasdfxczvdsgfxcdvbcbvf")); } - Y_UNIT_TEST(ResetKeysTest) { + Y_UNIT_TEST(ResetKeysTest) { TServiceContext context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); TCheckedServiceTicket checkedTicket = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); } } -Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { +Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { static const TString EMPTY_TVM_KEYS = "1:EpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQY"; static const TString EXPIRED_USER_TICKET = "3:user:CA0QABokCgMIyAMKAgh7EMgDGghiYjpzZXNzMRoIYmI6c2VzczIgEigB:D0CmYVwWg91LDYejjeQ2UP8AeiA_mr1q1CUD_lfJ9zQSEYEOYGDTafg4Um2rwOOvQnsD1JHM4zHyMUJ6Jtp9GAm5pmhbXBBZqaCcJpyxLTEC8a81MhJFCCJRvu_G1FiAgRgB25gI3HIbkvHFUEqAIC_nANy7NFQnbKk2S-EQPGY"; static const TString MALFORMED_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAEEpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQYSlQEKkgEIEBAAGocBMIGEAoGBALhrihbf3EpjDQS2sCQHazoFgN0nBbE9eesnnFTfzQELXb2gnJU9enmV_aDqaHKjgtLIPpCgn40lHrn5k6mvH5OdedyI6cCzE-N-GFp3nAq0NDJyMe0fhtIRD__CbT0ulcvkeow65ubXWfw6dBC2gR_34rdMe_L_TGRLMWjDULbNIJ"; @@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { static const TString VALID_USER_TICKET_2 = "3:user:CA0Q__________9_GhAKAwjIAwoCCHsQyAMgEigB:KRibGYTJUA2ns0Fn7VYqeMZ1-GdscB1o9pRzELyr7QJrJsfsE8Y_HoVvB8Npr-oalv6AXOpagSc8HpZjAQz8zKMAVE_tI0tL-9DEsHirpawEbpy7OWV7-k18o1m-RaDaKeTlIB45KHbBul1-9aeKkortBfbbXtz_Qy9r_mfFPiQ"; static const TString VALID_USER_TICKET_3 = "3:user:CA0Q__________9_Go8bCgIIAAoCCAEKAggCCgIIAwoCCAQKAggFCgIIBgoCCAcKAggICgIICQoCCAoKAggLCgIIDAoCCA0KAggOCgIIDwoCCBAKAggRCgIIEgoCCBMKAggUCgIIFQoCCBYKAggXCgIIGAoCCBkKAggaCgIIGwoCCBwKAggdCgIIHgoCCB8KAgggCgIIIQoCCCIKAggjCgIIJAoCCCUKAggmCgIIJwoCCCgKAggpCgIIKgoCCCsKAggsCgIILQoCCC4KAggvCgIIMAoCCDEKAggyCgIIMwoCCDQKAgg1CgIINgoCCDcKAgg4CgIIOQoCCDoKAgg7CgIIPAoCCD0KAgg-CgIIPwoCCEAKAghBCgIIQgoCCEMKAghECgIIRQoCCEYKAghHCgIISAoCCEkKAghKCgIISwoCCEwKAghNCgIITgoCCE8KAghQCgIIUQoCCFIKAghTCgIIVAoCCFUKAghWCgIIVwoCCFgKAghZCgIIWgoCCFsKAghcCgIIXQoCCF4KAghfCgIIYAoCCGEKAghiCgIIYwoCCGQKAghlCgIIZgoCCGcKAghoCgIIaQoCCGoKAghrCgIIbAoCCG0KAghuCgIIbwoCCHAKAghxCgIIcgoCCHMKAgh0CgIIdQoCCHYKAgh3CgIIeAoCCHkKAgh6CgIIewoCCHwKAgh9CgIIfgoCCH8KAwiAAQoDCIEBCgMIggEKAwiDAQoDCIQBCgMIhQEKAwiGAQoDCIcBCgMIiAEKAwiJAQoDCIoBCgMIiwEKAwiMAQoDCI0BCgMIjgEKAwiPAQoDCJABCgMIkQEKAwiSAQoDCJMBCgMIlAEKAwiVAQoDCJYBCgMIlwEKAwiYAQoDCJkBCgMImgEKAwibAQoDCJwBCgMInQEKAwieAQoDCJ8BCgMIoAEKAwihAQoDCKIBCgMIowEKAwikAQoDCKUBCgMIpgEKAwinAQoDCKgBCgMIqQEKAwiqAQoDCKsBCgMIrAEKAwitAQoDCK4BCgMIrwEKAwiwAQoDCLEBCgMIsgEKAwizAQoDCLQBCgMItQEKAwi2AQoDCLcBCgMIuAEKAwi5AQoDCLoBCgMIuwEKAwi8AQoDCL0BCgMIvgEKAwi_AQoDCMABCgMIwQEKAwjCAQoDCMMBCgMIxAEKAwjFAQoDCMYBCgMIxwEKAwjIAQoDCMkBCgMIygEKAwjLAQoDCMwBCgMIzQEKAwjOAQoDCM8BCgMI0AEKAwjRAQoDCNIBCgMI0wEKAwjUAQoDCNUBCgMI1gEKAwjXAQoDCNgBCgMI2QEKAwjaAQoDCNsBCgMI3AEKAwjdAQoDCN4BCgMI3wEKAwjgAQoDCOEBCgMI4gEKAwjjAQoDCOQBCgMI5QEKAwjmAQoDCOcBCgMI6AEKAwjpAQoDCOoBCgMI6wEKAwjsAQoDCO0BCgMI7gEKAwjvAQoDCPABCgMI8QEKAwjyAQoDCPMBCgMI9AEKAwj1AQoDCPYBCgMI9wEKAwj4AQoDCPkBCgMI-gEKAwj7AQoDCPwBCgMI_QEKAwj-AQoDCP8BCgMIgAIKAwiBAgoDCIICCgMIgwIKAwiEAgoDCIUCCgMIhgIKAwiHAgoDCIgCCgMIiQIKAwiKAgoDCIsCCgMIjAIKAwiNAgoDCI4CCgMIjwIKAwiQAgoDCJECCgMIkgIKAwiTAgoDCJQCCgMIlQIKAwiWAgoDCJcCCgMImAIKAwiZAgoDCJoCCgMImwIKAwicAgoDCJ0CCgMIngIKAwifAgoDCKACCgMIoQIKAwiiAgoDCKMCCgMIpAIKAwilAgoDCKYCCgMIpwIKAwioAgoDCKkCCgMIqgIKAwirAgoDCKwCCgMIrQIKAwiuAgoDCK8CCgMIsAIKAwixAgoDCLICCgMIswIKAwi0AgoDCLUCCgMItgIKAwi3AgoDCLgCCgMIuQIKAwi6AgoDCLsCCgMIvAIKAwi9AgoDCL4CCgMIvwIKAwjAAgoDCMECCgMIwgIKAwjDAgoDCMQCCgMIxQIKAwjGAgoDCMcCCgMIyAIKAwjJAgoDCMoCCgMIywIKAwjMAgoDCM0CCgMIzgIKAwjPAgoDCNACCgMI0QIKAwjSAgoDCNMCCgMI1AIKAwjVAgoDCNYCCgMI1wIKAwjYAgoDCNkCCgMI2gIKAwjbAgoDCNwCCgMI3QIKAwjeAgoDCN8CCgMI4AIKAwjhAgoDCOICCgMI4wIKAwjkAgoDCOUCCgMI5gIKAwjnAgoDCOgCCgMI6QIKAwjqAgoDCOsCCgMI7AIKAwjtAgoDCO4CCgMI7wIKAwjwAgoDCPECCgMI8gIKAwjzAgoDCPQCCgMI9QIKAwj2AgoDCPcCCgMI-AIKAwj5AgoDCPoCCgMI-wIKAwj8AgoDCP0CCgMI_gIKAwj_AgoDCIADCgMIgQMKAwiCAwoDCIMDCgMIhAMKAwiFAwoDCIYDCgMIhwMKAwiIAwoDCIkDCgMIigMKAwiLAwoDCIwDCgMIjQMKAwiOAwoDCI8DCgMIkAMKAwiRAwoDCJIDCgMIkwMKAwiUAwoDCJUDCgMIlgMKAwiXAwoDCJgDCgMImQMKAwiaAwoDCJsDCgMInAMKAwidAwoDCJ4DCgMInwMKAwigAwoDCKEDCgMIogMKAwijAwoDCKQDCgMIpQMKAwimAwoDCKcDCgMIqAMKAwipAwoDCKoDCgMIqwMKAwisAwoDCK0DCgMIrgMKAwivAwoDCLADCgMIsQMKAwiyAwoDCLMDCgMItAMKAwi1AwoDCLYDCgMItwMKAwi4AwoDCLkDCgMIugMKAwi7AwoDCLwDCgMIvQMKAwi-AwoDCL8DCgMIwAMKAwjBAwoDCMIDCgMIwwMKAwjEAwoDCMUDCgMIxgMKAwjHAwoDCMgDCgMIyQMKAwjKAwoDCMsDCgMIzAMKAwjNAwoDCM4DCgMIzwMKAwjQAwoDCNEDCgMI0gMKAwjTAwoDCNQDCgMI1QMKAwjWAwoDCNcDCgMI2AMKAwjZAwoDCNoDCgMI2wMKAwjcAwoDCN0DCgMI3gMKAwjfAwoDCOADCgMI4QMKAwjiAwoDCOMDCgMI5AMKAwjlAwoDCOYDCgMI5wMKAwjoAwoDCOkDCgMI6gMKAwjrAwoDCOwDCgMI7QMKAwjuAwoDCO8DCgMI8AMKAwjxAwoDCPIDCgMI8wMQyAMaCGJiOnNlc3MxGgliYjpzZXNzMTAaCmJiOnNlc3MxMDAaCWJiOnNlc3MxMRoJYmI6c2VzczEyGgliYjpzZXNzMTMaCWJiOnNlc3MxNBoJYmI6c2VzczE1GgliYjpzZXNzMTYaCWJiOnNlc3MxNxoJYmI6c2VzczE4GgliYjpzZXNzMTkaCGJiOnNlc3MyGgliYjpzZXNzMjAaCWJiOnNlc3MyMRoJYmI6c2VzczIyGgliYjpzZXNzMjMaCWJiOnNlc3MyNBoJYmI6c2VzczI1GgliYjpzZXNzMjYaCWJiOnNlc3MyNxoJYmI6c2VzczI4GgliYjpzZXNzMjkaCGJiOnNlc3MzGgliYjpzZXNzMzAaCWJiOnNlc3MzMRoJYmI6c2VzczMyGgliYjpzZXNzMzMaCWJiOnNlc3MzNBoJYmI6c2VzczM1GgliYjpzZXNzMzYaCWJiOnNlc3MzNxoJYmI6c2VzczM4GgliYjpzZXNzMzkaCGJiOnNlc3M0GgliYjpzZXNzNDAaCWJiOnNlc3M0MRoJYmI6c2VzczQyGgliYjpzZXNzNDMaCWJiOnNlc3M0NBoJYmI6c2VzczQ1GgliYjpzZXNzNDYaCWJiOnNlc3M0NxoJYmI6c2VzczQ4GgliYjpzZXNzNDkaCGJiOnNlc3M1GgliYjpzZXNzNTAaCWJiOnNlc3M1MRoJYmI6c2VzczUyGgliYjpzZXNzNTMaCWJiOnNlc3M1NBoJYmI6c2VzczU1GgliYjpzZXNzNTYaCWJiOnNlc3M1NxoJYmI6c2VzczU4GgliYjpzZXNzNTkaCGJiOnNlc3M2GgliYjpzZXNzNjAaCWJiOnNlc3M2MRoJYmI6c2VzczYyGgliYjpzZXNzNjMaCWJiOnNlc3M2NBoJYmI6c2VzczY1GgliYjpzZXNzNjYaCWJiOnNlc3M2NxoJYmI6c2VzczY4GgliYjpzZXNzNjkaCGJiOnNlc3M3GgliYjpzZXNzNzAaCWJiOnNlc3M3MRoJYmI6c2VzczcyGgliYjpzZXNzNzMaCWJiOnNlc3M3NBoJYmI6c2Vzczc1GgliYjpzZXNzNzYaCWJiOnNlc3M3NxoJYmI6c2Vzczc4GgliYjpzZXNzNzkaCGJiOnNlc3M4GgliYjpzZXNzODAaCWJiOnNlc3M4MRoJYmI6c2VzczgyGgliYjpzZXNzODMaCWJiOnNlc3M4NBoJYmI6c2Vzczg1GgliYjpzZXNzODYaCWJiOnNlc3M4NxoJYmI6c2Vzczg4GgliYjpzZXNzODkaCGJiOnNlc3M5GgliYjpzZXNzOTAaCWJiOnNlc3M5MRoJYmI6c2VzczkyGgliYjpzZXNzOTMaCWJiOnNlc3M5NBoJYmI6c2Vzczk1GgliYjpzZXNzOTYaCWJiOnNlc3M5NxoJYmI6c2Vzczk4GgliYjpzZXNzOTkgEigB:CX8PIOrxJnQqFXl7wAsiHJ_1VGjoI-asNlCXb8SE8jtI2vdh9x6CqbAurSgIlAAEgotVP-nuUR38x_a9YJuXzmG5AvJ458apWQtODHIDIX6ZaIwMxjS02R7S5LNqXa0gAuU_R6bCWpZdWe2uLMkdpu5KHbDgW08g-uaP_nceDOk"; - Y_UNIT_TEST(Case1Test) { + Y_UNIT_TEST(Case1Test) { TUserContext context1(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); TCheckedUserTicket checkedTicket1 = context1.Check("2:serv:CgYIDRCUkQYQDBgcIgdiYjpzZXNzIghiYjpzZXNzMg:ERmeH_yzC7K_QsoHTyw7llCsyExEz3CoEopPIuivA0ZAtTaFq_Pa0l9Fhhx_NX9WpOp2CPyY5cFc4PXhcO83jCB7-EGvHNxGN-j2NQalERzPiKqkDCO0Q5etLzSzrfTlvMz7sXDvELNBHyA0PkAQnbz4supY0l-0Q6JBYSEF3zOVMjjE-HeQIFL3ats3_PakaUMWRvgQQ88pVdYZqAtbDw9PlTla7ommygVZQjcfNFXV1pJKRgOCLs-YyCjOJHLKL04zYj0X6KsOCTUeqhj7ml96wLZ-g1X9tyOR2WAr2Ctq7wIEHwqhxOLgOSKqm05xH6Vi3E_hekf50oe2jPfKEA"); @@ -219,16 +219,16 @@ Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket4.GetStatus()); } - Y_UNIT_TEST(ContextTest) { + Y_UNIT_TEST(ContextTest) { TUserContext context(EBlackboxEnv::Prod, NUnittest::TVMKNIFE_PUBLIC_KEYS); } - Y_UNIT_TEST(ContextExceptionsTest) { + Y_UNIT_TEST(ContextExceptionsTest) { UNIT_ASSERT_EXCEPTION(TUserContext(EBlackboxEnv::Prod, EMPTY_TVM_KEYS), TEmptyTvmKeysException); UNIT_ASSERT_EXCEPTION(TUserContext(EBlackboxEnv::Prod, MALFORMED_TVM_KEYS), TMalformedTvmKeysException); } - Y_UNIT_TEST(Ticket1Test) { + Y_UNIT_TEST(Ticket1Test) { TUserContext context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); @@ -241,21 +241,21 @@ Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { UNIT_ASSERT_EQUAL("ticket_type=user;expiration_time=9223372036854775807;scope=bb:sess1;scope=bb:sess2;default_uid=456;uid=456;uid=123;env=Test;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(Ticket2Test) { + Y_UNIT_TEST(Ticket2Test) { TUserContext context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_2); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=user;expiration_time=9223372036854775807;default_uid=456;uid=456;uid=123;env=Test;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(Ticket3Test) { + Y_UNIT_TEST(Ticket3Test) { TUserContext context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_3); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=user;expiration_time=9223372036854775807;scope=bb:sess1;scope=bb:sess10;scope=bb:sess100;scope=bb:sess11;scope=bb:sess12;scope=bb:sess13;scope=bb:sess14;scope=bb:sess15;scope=bb:sess16;scope=bb:sess17;scope=bb:sess18;scope=bb:sess19;scope=bb:sess2;scope=bb:sess20;scope=bb:sess21;scope=bb:sess22;scope=bb:sess23;scope=bb:sess24;scope=bb:sess25;scope=bb:sess26;scope=bb:sess27;scope=bb:sess28;scope=bb:sess29;scope=bb:sess3;scope=bb:sess30;scope=bb:sess31;scope=bb:sess32;scope=bb:sess33;scope=bb:sess34;scope=bb:sess35;scope=bb:sess36;scope=bb:sess37;scope=bb:sess38;scope=bb:sess39;scope=bb:sess4;scope=bb:sess40;scope=bb:sess41;scope=bb:sess42;scope=bb:sess43;scope=bb:sess44;scope=bb:sess45;scope=bb:sess46;scope=bb:sess47;scope=bb:sess48;scope=bb:sess49;scope=bb:sess5;scope=bb:sess50;scope=bb:sess51;scope=bb:sess52;scope=bb:sess53;scope=bb:sess54;scope=bb:sess55;scope=bb:sess56;scope=bb:sess57;scope=bb:sess58;scope=bb:sess59;scope=bb:sess6;scope=bb:sess60;scope=bb:sess61;scope=bb:sess62;scope=bb:sess63;scope=bb:sess64;scope=bb:sess65;scope=bb:sess66;scope=bb:sess67;scope=bb:sess68;scope=bb:sess69;scope=bb:sess7;scope=bb:sess70;scope=bb:sess71;scope=bb:sess72;scope=bb:sess73;scope=bb:sess74;scope=bb:sess75;scope=bb:sess76;scope=bb:sess77;scope=bb:sess78;scope=bb:sess79;scope=bb:sess8;scope=bb:sess80;scope=bb:sess81;scope=bb:sess82;scope=bb:sess83;scope=bb:sess84;scope=bb:sess85;scope=bb:sess86;scope=bb:sess87;scope=bb:sess88;scope=bb:sess89;scope=bb:sess9;scope=bb:sess90;scope=bb:sess91;scope=bb:sess92;scope=bb:sess93;scope=bb:sess94;scope=bb:sess95;scope=bb:sess96;scope=bb:sess97;scope=bb:sess98;scope=bb:sess99;default_uid=456;uid=0;uid=1;uid=2;uid=3;uid=4;uid=5;uid=6;uid=7;uid=8;uid=9;uid=10;uid=11;uid=12;uid=13;uid=14;uid=15;uid=16;uid=17;uid=18;uid=19;uid=20;uid=21;uid=22;uid=23;uid=24;uid=25;uid=26;uid=27;uid=28;uid=29;uid=30;uid=31;uid=32;uid=33;uid=34;uid=35;uid=36;uid=37;uid=38;uid=39;uid=40;uid=41;uid=42;uid=43;uid=44;uid=45;uid=46;uid=47;uid=48;uid=49;uid=50;uid=51;uid=52;uid=53;uid=54;uid=55;uid=56;uid=57;uid=58;uid=59;uid=60;uid=61;uid=62;uid=63;uid=64;uid=65;uid=66;uid=67;uid=68;uid=69;uid=70;uid=71;uid=72;uid=73;uid=74;uid=75;uid=76;uid=77;uid=78;uid=79;uid=80;uid=81;uid=82;uid=83;uid=84;uid=85;uid=86;uid=87;uid=88;uid=89;uid=90;uid=91;uid=92;uid=93;uid=94;uid=95;uid=96;uid=97;uid=98;uid=99;uid=100;uid=101;uid=102;uid=103;uid=104;uid=105;uid=106;uid=107;uid=108;uid=109;uid=110;uid=111;uid=112;uid=113;uid=114;uid=115;uid=116;uid=117;uid=118;uid=119;uid=120;uid=121;uid=122;uid=123;uid=124;uid=125;uid=126;uid=127;uid=128;uid=129;uid=130;uid=131;uid=132;uid=133;uid=134;uid=135;uid=136;uid=137;uid=138;uid=139;uid=140;uid=141;uid=142;uid=143;uid=144;uid=145;uid=146;uid=147;uid=148;uid=149;uid=150;uid=151;uid=152;uid=153;uid=154;uid=155;uid=156;uid=157;uid=158;uid=159;uid=160;uid=161;uid=162;uid=163;uid=164;uid=165;uid=166;uid=167;uid=168;uid=169;uid=170;uid=171;uid=172;uid=173;uid=174;uid=175;uid=176;uid=177;uid=178;uid=179;uid=180;uid=181;uid=182;uid=183;uid=184;uid=185;uid=186;uid=187;uid=188;uid=189;uid=190;uid=191;uid=192;uid=193;uid=194;uid=195;uid=196;uid=197;uid=198;uid=199;uid=200;uid=201;uid=202;uid=203;uid=204;uid=205;uid=206;uid=207;uid=208;uid=209;uid=210;uid=211;uid=212;uid=213;uid=214;uid=215;uid=216;uid=217;uid=218;uid=219;uid=220;uid=221;uid=222;uid=223;uid=224;uid=225;uid=226;uid=227;uid=228;uid=229;uid=230;uid=231;uid=232;uid=233;uid=234;uid=235;uid=236;uid=237;uid=238;uid=239;uid=240;uid=241;uid=242;uid=243;uid=244;uid=245;uid=246;uid=247;uid=248;uid=249;uid=250;uid=251;uid=252;uid=253;uid=254;uid=255;uid=256;uid=257;uid=258;uid=259;uid=260;uid=261;uid=262;uid=263;uid=264;uid=265;uid=266;uid=267;uid=268;uid=269;uid=270;uid=271;uid=272;uid=273;uid=274;uid=275;uid=276;uid=277;uid=278;uid=279;uid=280;uid=281;uid=282;uid=283;uid=284;uid=285;uid=286;uid=287;uid=288;uid=289;uid=290;uid=291;uid=292;uid=293;uid=294;uid=295;uid=296;uid=297;uid=298;uid=299;uid=300;uid=301;uid=302;uid=303;uid=304;uid=305;uid=306;uid=307;uid=308;uid=309;uid=310;uid=311;uid=312;uid=313;uid=314;uid=315;uid=316;uid=317;uid=318;uid=319;uid=320;uid=321;uid=322;uid=323;uid=324;uid=325;uid=326;uid=327;uid=328;uid=329;uid=330;uid=331;uid=332;uid=333;uid=334;uid=335;uid=336;uid=337;uid=338;uid=339;uid=340;uid=341;uid=342;uid=343;uid=344;uid=345;uid=346;uid=347;uid=348;uid=349;uid=350;uid=351;uid=352;uid=353;uid=354;uid=355;uid=356;uid=357;uid=358;uid=359;uid=360;uid=361;uid=362;uid=363;uid=364;uid=365;uid=366;uid=367;uid=368;uid=369;uid=370;uid=371;uid=372;uid=373;uid=374;uid=375;uid=376;uid=377;uid=378;uid=379;uid=380;uid=381;uid=382;uid=383;uid=384;uid=385;uid=386;uid=387;uid=388;uid=389;uid=390;uid=391;uid=392;uid=393;uid=394;uid=395;uid=396;uid=397;uid=398;uid=399;uid=400;uid=401;uid=402;uid=403;uid=404;uid=405;uid=406;uid=407;uid=408;uid=409;uid=410;uid=411;uid=412;uid=413;uid=414;uid=415;uid=416;uid=417;uid=418;uid=419;uid=420;uid=421;uid=422;uid=423;uid=424;uid=425;uid=426;uid=427;uid=428;uid=429;uid=430;uid=431;uid=432;uid=433;uid=434;uid=435;uid=436;uid=437;uid=438;uid=439;uid=440;uid=441;uid=442;uid=443;uid=444;uid=445;uid=446;uid=447;uid=448;uid=449;uid=450;uid=451;uid=452;uid=453;uid=454;uid=455;uid=456;uid=457;uid=458;uid=459;uid=460;uid=461;uid=462;uid=463;uid=464;uid=465;uid=466;uid=467;uid=468;uid=469;uid=470;uid=471;uid=472;uid=473;uid=474;uid=475;uid=476;uid=477;uid=478;uid=479;uid=480;uid=481;uid=482;uid=483;uid=484;uid=485;uid=486;uid=487;uid=488;uid=489;uid=490;uid=491;uid=492;uid=493;uid=494;uid=495;uid=496;uid=497;uid=498;uid=499;env=Test;", checkedTicket.DebugInfo()); } - Y_UNIT_TEST(TicketErrorsTest) { + Y_UNIT_TEST(TicketErrorsTest) { TUserContext contextTest(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket1 = contextTest.Check(UNSUPPORTED_VERSION_USER_TICKET); UNIT_ASSERT_EQUAL(ETicketStatus::UnsupportedVersion, checkedTicket1.GetStatus()); @@ -268,7 +268,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { UNIT_ASSERT_EQUAL(ETicketStatus::InvalidBlackboxEnv, checkedTicket3.GetStatus()); } - Y_UNIT_TEST(TicketExceptionsTest) { + Y_UNIT_TEST(TicketExceptionsTest) { TUserContext contextTest(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = contextTest.Check(EXPIRED_USER_TICKET); UNIT_ASSERT_EQUAL(ETicketStatus::Expired, checkedTicket.GetStatus()); @@ -282,7 +282,7 @@ Y_UNIT_TEST_SUITE(PublicInterfaceUserTestSuite) { UNIT_ASSERT_NO_EXCEPTION(checkedTicket.GetStatus()); } - Y_UNIT_TEST(ResetKeysTest) { + Y_UNIT_TEST(ResetKeysTest) { TUserContext context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket.GetStatus()); diff --git a/library/cpp/tvmauth/src/ut/service_ut.cpp b/library/cpp/tvmauth/src/ut/service_ut.cpp index e20cdcc65e..5b6b5143bd 100644 --- a/library/cpp/tvmauth/src/ut/service_ut.cpp +++ b/library/cpp/tvmauth/src/ut/service_ut.cpp @@ -10,16 +10,16 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(ServiceTestSuite) { - Y_UNIT_TEST_DECLARE(TicketProtoTest); +Y_UNIT_TEST_SUITE(ServiceTestSuite) { + Y_UNIT_TEST_DECLARE(TicketProtoTest); } class TTestServiceTicketImpl: public TCheckedServiceTicket::TImpl { using TCheckedServiceTicket::TImpl::TImpl; - Y_UNIT_TEST_FRIEND(ServiceTestSuite, TicketProtoTest); + Y_UNIT_TEST_FRIEND(ServiceTestSuite, TicketProtoTest); }; -Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { +Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { static const TString EMPTY_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAE"; static const TString EXPIRED_SERVICE_TICKET = "3:serv:CBAQACIZCOUBEBwaCGJiOnNlc3MxGghiYjpzZXNzMg:IwfMNJYEqStY_SixwqJnyHOMCPR7-3HHk4uylB2oVRkthtezq-OOA7QizDvx7VABLs_iTlXuD1r5IjufNei_EiV145eaa3HIg4xCdJXCojMexf2UYJz8mF2b0YzFAy6_KWagU7xo13CyKAqzJuQf5MJcSUf0ecY9hVh36cJ51aw"; static const TString MALFORMED_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAEEpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQYSlQEKkgEIEBAAGocBMIGEAoGBALhrihbf3EpjDQS2sCQHazoFgN0nBbE9eesnnFTfzQELXb2gnJU9enmV_aDqaHKjgtLIPpCgn40lHrn5k6mvH5OdedyI6cCzE-N-GFp3nAq0NDJyMe0fhtIRD__CbT0ulcvkeow65ubXWfw6dBC2gR_34rdMe_L_TGRLMWjDULbNIJ"; @@ -35,20 +35,20 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { static const TString VALID_SERVICE_TICKET_3 = "3:serv:CBAQ__________9_IgUI5QEQHA:Sd6tmA1CNy2Nf7XevC3x7zr2DrGNRmcl-TxUsDtDW2xI3YXyCxBltWeg0-KtDlqyYuPOP5Jd_-XXNA12KlOPnNzrz3jm-5z8uQl6CjCcrVHUHJ75pGC8r9UOlS8cOgeXQB5dYP-fOWyo5CNadlozx1S2meCIxncbQRV1kCBi4KU"; static const TString VALID_SERVICE_TICKET_ISSUER = "3:serv:CBAQ__________9_IgsI5QEQHCDr1MT4Ag:Gu66XJT_nKnIRJjFy1561wFhIqkJItcSTGftLo7Yvi7i5wIdV-QuKT_-IMPpgjxnnGbt1Dy3Ys2TEoeJAb0TdaCYG1uy3vpoLONmTx9AenN5dx1HHf46cypLK5D3OdiTjxvqI9uGmSIKrSdRxU8gprpu5QiBDPZqVCWhM60FVSY"; - Y_UNIT_TEST(ContextExceptionsTest) { + Y_UNIT_TEST(ContextExceptionsTest) { UNIT_ASSERT_EXCEPTION(TServiceContext::TImpl(SECRET, OUR_ID, MALFORMED_TVM_KEYS), TMalformedTvmKeysException); UNIT_ASSERT_EXCEPTION(TServiceContext::TImpl(SECRET, OUR_ID, EMPTY_TVM_KEYS), TEmptyTvmKeysException); UNIT_ASSERT_EXCEPTION(TServiceContext::TImpl(MALFORMED_TVM_SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS), TMalformedTvmSecretException); } - Y_UNIT_TEST(ContextSignTest) { + Y_UNIT_TEST(ContextSignTest) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_VALUES_EQUAL( "NsPTYak4Cfk-4vgau5lab3W4GPiTtb2etuj3y4MDPrk", context.SignCgiParamsForTvm(IntToString<10>(std::numeric_limits<time_t>::max()), "13,28", "")); } - Y_UNIT_TEST(Ticket1Test) { + Y_UNIT_TEST(Ticket1Test) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); @@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT(!checkedTicket->GetIssuerUid()); } - Y_UNIT_TEST(Ticket2Test) { + Y_UNIT_TEST(Ticket2Test) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_2); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT(!checkedTicket->GetIssuerUid()); } - Y_UNIT_TEST(Ticket3Test) { + Y_UNIT_TEST(Ticket3Test) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_3); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); @@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT(!checkedTicket->GetIssuerUid()); } - Y_UNIT_TEST(TicketIssuerTest) { + Y_UNIT_TEST(TicketIssuerTest) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_ISSUER); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); @@ -88,7 +88,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT_VALUES_EQUAL(789654123, *checkedTicket->GetIssuerUid()); } - Y_UNIT_TEST(TicketErrorsTest) { + Y_UNIT_TEST(TicketErrorsTest) { TServiceContext::TImpl context(SECRET, NOT_OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket1 = context.Check(VALID_SERVICE_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::InvalidDst, checkedTicket1->GetStatus()); @@ -100,7 +100,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT_EQUAL(ETicketStatus::Expired, checkedTicket3->GetStatus()); } - Y_UNIT_TEST(TicketExceptionTest) { + Y_UNIT_TEST(TicketExceptionTest) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(EXPIRED_SERVICE_TICKET); @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT_NO_EXCEPTION(checkedTicket->DebugInfo()); } - Y_UNIT_TEST(TicketProtoTest) { + Y_UNIT_TEST(TicketProtoTest) { ticket2::Ticket protobufTicket; UNIT_ASSERT(protobufTicket.ParseFromString(NUtils::Base64url2bin(SERVICE_TICKET_PROTOBUF))); TTestServiceTicketImpl checkedTicket(ETicketStatus::Ok, std::move(protobufTicket)); @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(ServiceTestSuite) { UNIT_ASSERT_EQUAL(SRC_ID, checkedTicket.GetSrc()); } - Y_UNIT_TEST(ResetKeysTest) { + Y_UNIT_TEST(ResetKeysTest) { TServiceContext::TImpl context(SECRET, OUR_ID, NUnittest::TVMKNIFE_PUBLIC_KEYS); context.ResetKeys(NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_SERVICE_TICKET_1); diff --git a/library/cpp/tvmauth/src/ut/user_ut.cpp b/library/cpp/tvmauth/src/ut/user_ut.cpp index 706df2df8d..c040e94974 100644 --- a/library/cpp/tvmauth/src/ut/user_ut.cpp +++ b/library/cpp/tvmauth/src/ut/user_ut.cpp @@ -8,16 +8,16 @@ using namespace NTvmAuth; -Y_UNIT_TEST_SUITE(UserTestSuite) { - Y_UNIT_TEST_DECLARE(TicketProtoTest); +Y_UNIT_TEST_SUITE(UserTestSuite) { + Y_UNIT_TEST_DECLARE(TicketProtoTest); } class TTestUserTicketImpl: TCheckedUserTicket::TImpl { using TCheckedUserTicket::TImpl::TImpl; - Y_UNIT_TEST_FRIEND(UserTestSuite, TicketProtoTest); + Y_UNIT_TEST_FRIEND(UserTestSuite, TicketProtoTest); }; -Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { +Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { static const TString EMPTY_TVM_KEYS = "1:EpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQY"; static const TString EXPIRED_USER_TICKET = "3:user:CA0QABokCgMIyAMKAgh7EMgDGghiYjpzZXNzMRoIYmI6c2VzczIgEigB:D0CmYVwWg91LDYejjeQ2UP8AeiA_mr1q1CUD_lfJ9zQSEYEOYGDTafg4Um2rwOOvQnsD1JHM4zHyMUJ6Jtp9GAm5pmhbXBBZqaCcJpyxLTEC8a81MhJFCCJRvu_G1FiAgRgB25gI3HIbkvHFUEqAIC_nANy7NFQnbKk2S-EQPGY"; static const TString MALFORMED_TVM_KEYS = "1:CpgCCpMCCAEQABqIAjCCAQQCggEAcLEXeH67FQESFUn4_7wnX7wN0PUrBoUsm3QQ4W5vC-qz6sXaEjSwnTV8w1o-z6X9KPLlhzMQvuS38NCNfK4uvJ4Zvfp3YsXJ25-rYtbnrYJHNvHohD-kPCCw_yZpMp21JdWigzQGuV7CtrxUhF-NNrsnUaJrE5-OpEWNt4X6nCItKIYeVcSK6XJUbEWbrNCRbvkSc4ak2ymFeMuHYJVjxh4eQbk7_ZPzodP0WvF6eUYrYeb42imVEOR8ofVLQWE5DVnb1z_TqZm4i1XkS7jMwZuBxBRw8DGdYei0lT_sAf7KST2jC0590NySB3vsBgWEVs1OdUUWA6r-Dvx9dsOQtSCVkQYQAAqZAgqUAggCEAAaiQIwggEFAoIBAQDhEBM5-6YsPWfogKtbluJoCX1WV2KdzOaQ0-OlRbBzeCzw-eQKu12c8WakHBbeCMd1I1TU64SDkDorWjXGIa_2xT6N3zzNAE50roTbPCcmeQrps26woTYfYIuqDdoxYKZNr0lvNLLW47vBr7EKqo1S4KSj7aXK_XYeEvUgIgf3nVIcNrio7VTnFmGGVQCepaL1Hi1gN4yIXjVZ06PBPZ-DxSRu6xOGbFrfKMJeMPs7KOyE-26Q3xOXdTIa1X-zYIucTd_bxUCL4BVbwW2AvbbFsaG7ISmVdGu0XUTmhXs1KrEfUVLRJhE4Dx99hAZXm1_HlYMUeJcMQ_oHOhV94ENFIJaRBhACCpYBCpEBCAMQABqGATCBgwKBgF9t2YJGAJkRRFq6fWhi3m1TFW1UOE0f6ZrfYhHAkpqGlKlh0QVfeTNPpeJhi75xXzCe6oReRUm-0DbqDNhTShC7uGUv1INYnRBQWH6E-5Fc5XrbDFSuGQw2EYjNfHy_HefHJXxQKAqPvxBDKMKkHgV58WtM6rC8jRi9sdX_ig2NIJeRBhABCpYBCpEBCAQQABqGATCBgwKBgGB4d6eLGUBv-Q6EPLehC4S-yuE2HB-_rJ7WkeYwyp-xIPolPrd-PQme2utHB4ZgpXHIu_OFksDe_0bPgZniNRSVRbl7W49DgS5Ya3kMfrYB4DnF5Fta5tn1oV6EwxYD4JONpFTenOJALPGTPawxXEfon_peiHOSBuQMu3_Vn-l1IJiRBhADCpcBCpIBCAUQABqHATCBhAKBgQCTJMKIfmfeZpaI7Q9rnsc29gdWawK7TnpVKRHws1iY7EUlYROeVcMdAwEqVM6f8BVCKLGgzQ7Gar_uuxfUGKwqEQzoppDraw4F75J464-7D5f6_oJQuGIBHZxqbMONtLjBCXRUhQW5szBLmTQ_R3qaJb5vf-h0APZfkYhq1cTttSCZkQYQBAqWAQqRAQgLEAAahgEwgYMCgYBvvGVH_M2H8qxxv94yaDYUTWbRnJ1uiIYc59KIQlfFimMPhSS7x2tqUa2-hI55JiII0Xym6GNkwLhyc1xtWChpVuIdSnbvttbrt4weDMLHqTwNOF6qAsVKGKT1Yh8yf-qb-DSmicgvFc74mBQm_6gAY1iQsf33YX8578ClhKBWHSCVkQYQAAqXAQqSAQgMEAAahwEwgYQCgYEAkuzFcd5TJu7lYWYe2hQLFfUWIIj91BvQQLa_Thln4YtGCO8gG1KJqJm-YlmJOWQG0B7H_5RVhxUxV9KpmFnsDVkzUFKOsCBaYGXc12xPVioawUlAwp5qp3QQtZyx_se97YIoLzuLr46UkLcLnkIrp-Jo46QzYi_QHq45WTm8MQ0glpEGEAIKlwEKkgEIDRAAGocBMIGEAoGBAIUzbxOknXf_rNt17_ir8JlWvrtnCWsQd1MAnl5mgArvavDtKeBYHzi5_Ak7DHlLzuA6YE8W175FxLFKpN2hkz-l-M7ltUSd8N1BvJRhK4t6WffWfC_1wPyoAbeSN2Yb1jygtZJQ8wGoXHcJQUXiMit3eFNyylwsJFj1gzAR4JCdIJeRBhABCpYBCpEBCA4QABqGATCBgwKBgFMcbEpl9ukVR6AO_R6sMyiU11I8b8MBSUCEC15iKsrVO8v_m47_TRRjWPYtQ9eZ7o1ocNJHaGUU7qqInFqtFaVnIceP6NmCsXhjs3MLrWPS8IRAy4Zf4FKmGOx3N9O2vemjUygZ9vUiSkULdVrecinRaT8JQ5RG4bUMY04XGIwFIJiRBhADCpYBCpEBCA8QABqGATCBgwKBgGpCkW-NR3li8GlRvqpq2YZGSIgm_PTyDI2Zwfw69grsBmPpVFW48Vw7xoMN35zcrojEpialB_uQzlpLYOvsMl634CRIuj-n1QE3-gaZTTTE8mg-AR4mcxnTKThPnRQpbuOlYAnriwiasWiQEMbGjq_HmWioYYxFo9USlklQn4-9IJmRBhAEEpUBCpIBCAYQABqHATCBhAKBgQCoZkFGm9oLTqjeXZAq6j5S6i7K20V0lNdBBLqfmFBIRuTkYxhs4vUYnWjZrKRAd5bp6_py0csmFmpl_5Yh0b-2pdo_E5PNP7LGRzKyKSiFddyykKKzVOazH8YYldDAfE8Z5HoS9e48an5JsPg0jr-TPu34DnJq3yv2a6dqiKL9zSCakQYSlQEKkgEIEBAAGocBMIGEAoGBALhrihbf3EpjDQS2sCQHazoFgN0nBbE9eesnnFTfzQELXb2gnJU9enmV_aDqaHKjgtLIPpCgn40lHrn5k6mvH5OdedyI6cCzE-N-GFp3nAq0NDJyMe0fhtIRD__CbT0ulcvkeow65ubXWfw6dBC2gR_34rdMe_L_TGRLMWjDULbNIJ"; @@ -27,14 +27,14 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { static const TString VALID_USER_TICKET_2 = "3:user:CA0Q__________9_GhAKAwjIAwoCCHsQyAMgEigB:KRibGYTJUA2ns0Fn7VYqeMZ1-GdscB1o9pRzELyr7QJrJsfsE8Y_HoVvB8Npr-oalv6AXOpagSc8HpZjAQz8zKMAVE_tI0tL-9DEsHirpawEbpy7OWV7-k18o1m-RaDaKeTlIB45KHbBul1-9aeKkortBfbbXtz_Qy9r_mfFPiQ"; static const TString VALID_USER_TICKET_3 = "3:user:CA0Q__________9_Go8bCgIIAAoCCAEKAggCCgIIAwoCCAQKAggFCgIIBgoCCAcKAggICgIICQoCCAoKAggLCgIIDAoCCA0KAggOCgIIDwoCCBAKAggRCgIIEgoCCBMKAggUCgIIFQoCCBYKAggXCgIIGAoCCBkKAggaCgIIGwoCCBwKAggdCgIIHgoCCB8KAgggCgIIIQoCCCIKAggjCgIIJAoCCCUKAggmCgIIJwoCCCgKAggpCgIIKgoCCCsKAggsCgIILQoCCC4KAggvCgIIMAoCCDEKAggyCgIIMwoCCDQKAgg1CgIINgoCCDcKAgg4CgIIOQoCCDoKAgg7CgIIPAoCCD0KAgg-CgIIPwoCCEAKAghBCgIIQgoCCEMKAghECgIIRQoCCEYKAghHCgIISAoCCEkKAghKCgIISwoCCEwKAghNCgIITgoCCE8KAghQCgIIUQoCCFIKAghTCgIIVAoCCFUKAghWCgIIVwoCCFgKAghZCgIIWgoCCFsKAghcCgIIXQoCCF4KAghfCgIIYAoCCGEKAghiCgIIYwoCCGQKAghlCgIIZgoCCGcKAghoCgIIaQoCCGoKAghrCgIIbAoCCG0KAghuCgIIbwoCCHAKAghxCgIIcgoCCHMKAgh0CgIIdQoCCHYKAgh3CgIIeAoCCHkKAgh6CgIIewoCCHwKAgh9CgIIfgoCCH8KAwiAAQoDCIEBCgMIggEKAwiDAQoDCIQBCgMIhQEKAwiGAQoDCIcBCgMIiAEKAwiJAQoDCIoBCgMIiwEKAwiMAQoDCI0BCgMIjgEKAwiPAQoDCJABCgMIkQEKAwiSAQoDCJMBCgMIlAEKAwiVAQoDCJYBCgMIlwEKAwiYAQoDCJkBCgMImgEKAwibAQoDCJwBCgMInQEKAwieAQoDCJ8BCgMIoAEKAwihAQoDCKIBCgMIowEKAwikAQoDCKUBCgMIpgEKAwinAQoDCKgBCgMIqQEKAwiqAQoDCKsBCgMIrAEKAwitAQoDCK4BCgMIrwEKAwiwAQoDCLEBCgMIsgEKAwizAQoDCLQBCgMItQEKAwi2AQoDCLcBCgMIuAEKAwi5AQoDCLoBCgMIuwEKAwi8AQoDCL0BCgMIvgEKAwi_AQoDCMABCgMIwQEKAwjCAQoDCMMBCgMIxAEKAwjFAQoDCMYBCgMIxwEKAwjIAQoDCMkBCgMIygEKAwjLAQoDCMwBCgMIzQEKAwjOAQoDCM8BCgMI0AEKAwjRAQoDCNIBCgMI0wEKAwjUAQoDCNUBCgMI1gEKAwjXAQoDCNgBCgMI2QEKAwjaAQoDCNsBCgMI3AEKAwjdAQoDCN4BCgMI3wEKAwjgAQoDCOEBCgMI4gEKAwjjAQoDCOQBCgMI5QEKAwjmAQoDCOcBCgMI6AEKAwjpAQoDCOoBCgMI6wEKAwjsAQoDCO0BCgMI7gEKAwjvAQoDCPABCgMI8QEKAwjyAQoDCPMBCgMI9AEKAwj1AQoDCPYBCgMI9wEKAwj4AQoDCPkBCgMI-gEKAwj7AQoDCPwBCgMI_QEKAwj-AQoDCP8BCgMIgAIKAwiBAgoDCIICCgMIgwIKAwiEAgoDCIUCCgMIhgIKAwiHAgoDCIgCCgMIiQIKAwiKAgoDCIsCCgMIjAIKAwiNAgoDCI4CCgMIjwIKAwiQAgoDCJECCgMIkgIKAwiTAgoDCJQCCgMIlQIKAwiWAgoDCJcCCgMImAIKAwiZAgoDCJoCCgMImwIKAwicAgoDCJ0CCgMIngIKAwifAgoDCKACCgMIoQIKAwiiAgoDCKMCCgMIpAIKAwilAgoDCKYCCgMIpwIKAwioAgoDCKkCCgMIqgIKAwirAgoDCKwCCgMIrQIKAwiuAgoDCK8CCgMIsAIKAwixAgoDCLICCgMIswIKAwi0AgoDCLUCCgMItgIKAwi3AgoDCLgCCgMIuQIKAwi6AgoDCLsCCgMIvAIKAwi9AgoDCL4CCgMIvwIKAwjAAgoDCMECCgMIwgIKAwjDAgoDCMQCCgMIxQIKAwjGAgoDCMcCCgMIyAIKAwjJAgoDCMoCCgMIywIKAwjMAgoDCM0CCgMIzgIKAwjPAgoDCNACCgMI0QIKAwjSAgoDCNMCCgMI1AIKAwjVAgoDCNYCCgMI1wIKAwjYAgoDCNkCCgMI2gIKAwjbAgoDCNwCCgMI3QIKAwjeAgoDCN8CCgMI4AIKAwjhAgoDCOICCgMI4wIKAwjkAgoDCOUCCgMI5gIKAwjnAgoDCOgCCgMI6QIKAwjqAgoDCOsCCgMI7AIKAwjtAgoDCO4CCgMI7wIKAwjwAgoDCPECCgMI8gIKAwjzAgoDCPQCCgMI9QIKAwj2AgoDCPcCCgMI-AIKAwj5AgoDCPoCCgMI-wIKAwj8AgoDCP0CCgMI_gIKAwj_AgoDCIADCgMIgQMKAwiCAwoDCIMDCgMIhAMKAwiFAwoDCIYDCgMIhwMKAwiIAwoDCIkDCgMIigMKAwiLAwoDCIwDCgMIjQMKAwiOAwoDCI8DCgMIkAMKAwiRAwoDCJIDCgMIkwMKAwiUAwoDCJUDCgMIlgMKAwiXAwoDCJgDCgMImQMKAwiaAwoDCJsDCgMInAMKAwidAwoDCJ4DCgMInwMKAwigAwoDCKEDCgMIogMKAwijAwoDCKQDCgMIpQMKAwimAwoDCKcDCgMIqAMKAwipAwoDCKoDCgMIqwMKAwisAwoDCK0DCgMIrgMKAwivAwoDCLADCgMIsQMKAwiyAwoDCLMDCgMItAMKAwi1AwoDCLYDCgMItwMKAwi4AwoDCLkDCgMIugMKAwi7AwoDCLwDCgMIvQMKAwi-AwoDCL8DCgMIwAMKAwjBAwoDCMIDCgMIwwMKAwjEAwoDCMUDCgMIxgMKAwjHAwoDCMgDCgMIyQMKAwjKAwoDCMsDCgMIzAMKAwjNAwoDCM4DCgMIzwMKAwjQAwoDCNEDCgMI0gMKAwjTAwoDCNQDCgMI1QMKAwjWAwoDCNcDCgMI2AMKAwjZAwoDCNoDCgMI2wMKAwjcAwoDCN0DCgMI3gMKAwjfAwoDCOADCgMI4QMKAwjiAwoDCOMDCgMI5AMKAwjlAwoDCOYDCgMI5wMKAwjoAwoDCOkDCgMI6gMKAwjrAwoDCOwDCgMI7QMKAwjuAwoDCO8DCgMI8AMKAwjxAwoDCPIDCgMI8wMQyAMaCGJiOnNlc3MxGgliYjpzZXNzMTAaCmJiOnNlc3MxMDAaCWJiOnNlc3MxMRoJYmI6c2VzczEyGgliYjpzZXNzMTMaCWJiOnNlc3MxNBoJYmI6c2VzczE1GgliYjpzZXNzMTYaCWJiOnNlc3MxNxoJYmI6c2VzczE4GgliYjpzZXNzMTkaCGJiOnNlc3MyGgliYjpzZXNzMjAaCWJiOnNlc3MyMRoJYmI6c2VzczIyGgliYjpzZXNzMjMaCWJiOnNlc3MyNBoJYmI6c2VzczI1GgliYjpzZXNzMjYaCWJiOnNlc3MyNxoJYmI6c2VzczI4GgliYjpzZXNzMjkaCGJiOnNlc3MzGgliYjpzZXNzMzAaCWJiOnNlc3MzMRoJYmI6c2VzczMyGgliYjpzZXNzMzMaCWJiOnNlc3MzNBoJYmI6c2VzczM1GgliYjpzZXNzMzYaCWJiOnNlc3MzNxoJYmI6c2VzczM4GgliYjpzZXNzMzkaCGJiOnNlc3M0GgliYjpzZXNzNDAaCWJiOnNlc3M0MRoJYmI6c2VzczQyGgliYjpzZXNzNDMaCWJiOnNlc3M0NBoJYmI6c2VzczQ1GgliYjpzZXNzNDYaCWJiOnNlc3M0NxoJYmI6c2VzczQ4GgliYjpzZXNzNDkaCGJiOnNlc3M1GgliYjpzZXNzNTAaCWJiOnNlc3M1MRoJYmI6c2VzczUyGgliYjpzZXNzNTMaCWJiOnNlc3M1NBoJYmI6c2VzczU1GgliYjpzZXNzNTYaCWJiOnNlc3M1NxoJYmI6c2VzczU4GgliYjpzZXNzNTkaCGJiOnNlc3M2GgliYjpzZXNzNjAaCWJiOnNlc3M2MRoJYmI6c2VzczYyGgliYjpzZXNzNjMaCWJiOnNlc3M2NBoJYmI6c2VzczY1GgliYjpzZXNzNjYaCWJiOnNlc3M2NxoJYmI6c2VzczY4GgliYjpzZXNzNjkaCGJiOnNlc3M3GgliYjpzZXNzNzAaCWJiOnNlc3M3MRoJYmI6c2VzczcyGgliYjpzZXNzNzMaCWJiOnNlc3M3NBoJYmI6c2Vzczc1GgliYjpzZXNzNzYaCWJiOnNlc3M3NxoJYmI6c2Vzczc4GgliYjpzZXNzNzkaCGJiOnNlc3M4GgliYjpzZXNzODAaCWJiOnNlc3M4MRoJYmI6c2VzczgyGgliYjpzZXNzODMaCWJiOnNlc3M4NBoJYmI6c2Vzczg1GgliYjpzZXNzODYaCWJiOnNlc3M4NxoJYmI6c2Vzczg4GgliYjpzZXNzODkaCGJiOnNlc3M5GgliYjpzZXNzOTAaCWJiOnNlc3M5MRoJYmI6c2VzczkyGgliYjpzZXNzOTMaCWJiOnNlc3M5NBoJYmI6c2Vzczk1GgliYjpzZXNzOTYaCWJiOnNlc3M5NxoJYmI6c2Vzczk4GgliYjpzZXNzOTkgEigB:CX8PIOrxJnQqFXl7wAsiHJ_1VGjoI-asNlCXb8SE8jtI2vdh9x6CqbAurSgIlAAEgotVP-nuUR38x_a9YJuXzmG5AvJ458apWQtODHIDIX6ZaIwMxjS02R7S5LNqXa0gAuU_R6bCWpZdWe2uLMkdpu5KHbDgW08g-uaP_nceDOk"; - Y_UNIT_TEST(ContextText) { + Y_UNIT_TEST(ContextText) { TUserContext::TImpl context(EBlackboxEnv::Prod, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_EQUAL(2, context.GetKeys().size()); UNIT_ASSERT_NO_EXCEPTION(context.ResetKeys(NUnittest::TVMKNIFE_PUBLIC_KEYS)); UNIT_ASSERT_EQUAL(2, context.GetKeys().size()); } - Y_UNIT_TEST(ContextEnvTest) { + Y_UNIT_TEST(ContextEnvTest) { TUserContext::TImpl p(EBlackboxEnv::Prod, NUnittest::TVMKNIFE_PUBLIC_KEYS); UNIT_ASSERT_EQUAL(2, p.GetKeys().size()); UNIT_ASSERT(p.IsAllowed(tvm_keys::Prod)); @@ -76,13 +76,13 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { UNIT_ASSERT(s.IsAllowed(tvm_keys::Stress)); } - Y_UNIT_TEST(ContextExceptionsText) { + Y_UNIT_TEST(ContextExceptionsText) { UNIT_ASSERT_EXCEPTION(TUserContext::TImpl(EBlackboxEnv::Prod, EMPTY_TVM_KEYS), TEmptyTvmKeysException); UNIT_ASSERT_EXCEPTION(TUserContext::TImpl(EBlackboxEnv::Prod, MALFORMED_TVM_KEYS), TMalformedTvmKeysException); UNIT_ASSERT_EXCEPTION(TUserContext::TImpl(EBlackboxEnv::Prod, "adcvxcv./-+"), TMalformedTvmKeysException); } - Y_UNIT_TEST(Ticket1Test) { + Y_UNIT_TEST(Ticket1Test) { TUserContext::TImpl context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_1); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); @@ -96,21 +96,21 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { UNIT_ASSERT_EQUAL("ticket_type=user;expiration_time=9223372036854775807;scope=bb:sess1;scope=bb:sess2;default_uid=456;uid=456;uid=123;env=Test;", checkedTicket->DebugInfo()); } - Y_UNIT_TEST(Ticket2Test) { + Y_UNIT_TEST(Ticket2Test) { TUserContext::TImpl context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_2); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=user;expiration_time=9223372036854775807;default_uid=456;uid=456;uid=123;env=Test;", checkedTicket->DebugInfo()); } - Y_UNIT_TEST(Ticket3Test) { + Y_UNIT_TEST(Ticket3Test) { TUserContext::TImpl context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_3); UNIT_ASSERT_EQUAL(ETicketStatus::Ok, checkedTicket->GetStatus()); UNIT_ASSERT_VALUES_EQUAL("ticket_type=user;expiration_time=9223372036854775807;scope=bb:sess1;scope=bb:sess10;scope=bb:sess100;scope=bb:sess11;scope=bb:sess12;scope=bb:sess13;scope=bb:sess14;scope=bb:sess15;scope=bb:sess16;scope=bb:sess17;scope=bb:sess18;scope=bb:sess19;scope=bb:sess2;scope=bb:sess20;scope=bb:sess21;scope=bb:sess22;scope=bb:sess23;scope=bb:sess24;scope=bb:sess25;scope=bb:sess26;scope=bb:sess27;scope=bb:sess28;scope=bb:sess29;scope=bb:sess3;scope=bb:sess30;scope=bb:sess31;scope=bb:sess32;scope=bb:sess33;scope=bb:sess34;scope=bb:sess35;scope=bb:sess36;scope=bb:sess37;scope=bb:sess38;scope=bb:sess39;scope=bb:sess4;scope=bb:sess40;scope=bb:sess41;scope=bb:sess42;scope=bb:sess43;scope=bb:sess44;scope=bb:sess45;scope=bb:sess46;scope=bb:sess47;scope=bb:sess48;scope=bb:sess49;scope=bb:sess5;scope=bb:sess50;scope=bb:sess51;scope=bb:sess52;scope=bb:sess53;scope=bb:sess54;scope=bb:sess55;scope=bb:sess56;scope=bb:sess57;scope=bb:sess58;scope=bb:sess59;scope=bb:sess6;scope=bb:sess60;scope=bb:sess61;scope=bb:sess62;scope=bb:sess63;scope=bb:sess64;scope=bb:sess65;scope=bb:sess66;scope=bb:sess67;scope=bb:sess68;scope=bb:sess69;scope=bb:sess7;scope=bb:sess70;scope=bb:sess71;scope=bb:sess72;scope=bb:sess73;scope=bb:sess74;scope=bb:sess75;scope=bb:sess76;scope=bb:sess77;scope=bb:sess78;scope=bb:sess79;scope=bb:sess8;scope=bb:sess80;scope=bb:sess81;scope=bb:sess82;scope=bb:sess83;scope=bb:sess84;scope=bb:sess85;scope=bb:sess86;scope=bb:sess87;scope=bb:sess88;scope=bb:sess89;scope=bb:sess9;scope=bb:sess90;scope=bb:sess91;scope=bb:sess92;scope=bb:sess93;scope=bb:sess94;scope=bb:sess95;scope=bb:sess96;scope=bb:sess97;scope=bb:sess98;scope=bb:sess99;default_uid=456;uid=0;uid=1;uid=2;uid=3;uid=4;uid=5;uid=6;uid=7;uid=8;uid=9;uid=10;uid=11;uid=12;uid=13;uid=14;uid=15;uid=16;uid=17;uid=18;uid=19;uid=20;uid=21;uid=22;uid=23;uid=24;uid=25;uid=26;uid=27;uid=28;uid=29;uid=30;uid=31;uid=32;uid=33;uid=34;uid=35;uid=36;uid=37;uid=38;uid=39;uid=40;uid=41;uid=42;uid=43;uid=44;uid=45;uid=46;uid=47;uid=48;uid=49;uid=50;uid=51;uid=52;uid=53;uid=54;uid=55;uid=56;uid=57;uid=58;uid=59;uid=60;uid=61;uid=62;uid=63;uid=64;uid=65;uid=66;uid=67;uid=68;uid=69;uid=70;uid=71;uid=72;uid=73;uid=74;uid=75;uid=76;uid=77;uid=78;uid=79;uid=80;uid=81;uid=82;uid=83;uid=84;uid=85;uid=86;uid=87;uid=88;uid=89;uid=90;uid=91;uid=92;uid=93;uid=94;uid=95;uid=96;uid=97;uid=98;uid=99;uid=100;uid=101;uid=102;uid=103;uid=104;uid=105;uid=106;uid=107;uid=108;uid=109;uid=110;uid=111;uid=112;uid=113;uid=114;uid=115;uid=116;uid=117;uid=118;uid=119;uid=120;uid=121;uid=122;uid=123;uid=124;uid=125;uid=126;uid=127;uid=128;uid=129;uid=130;uid=131;uid=132;uid=133;uid=134;uid=135;uid=136;uid=137;uid=138;uid=139;uid=140;uid=141;uid=142;uid=143;uid=144;uid=145;uid=146;uid=147;uid=148;uid=149;uid=150;uid=151;uid=152;uid=153;uid=154;uid=155;uid=156;uid=157;uid=158;uid=159;uid=160;uid=161;uid=162;uid=163;uid=164;uid=165;uid=166;uid=167;uid=168;uid=169;uid=170;uid=171;uid=172;uid=173;uid=174;uid=175;uid=176;uid=177;uid=178;uid=179;uid=180;uid=181;uid=182;uid=183;uid=184;uid=185;uid=186;uid=187;uid=188;uid=189;uid=190;uid=191;uid=192;uid=193;uid=194;uid=195;uid=196;uid=197;uid=198;uid=199;uid=200;uid=201;uid=202;uid=203;uid=204;uid=205;uid=206;uid=207;uid=208;uid=209;uid=210;uid=211;uid=212;uid=213;uid=214;uid=215;uid=216;uid=217;uid=218;uid=219;uid=220;uid=221;uid=222;uid=223;uid=224;uid=225;uid=226;uid=227;uid=228;uid=229;uid=230;uid=231;uid=232;uid=233;uid=234;uid=235;uid=236;uid=237;uid=238;uid=239;uid=240;uid=241;uid=242;uid=243;uid=244;uid=245;uid=246;uid=247;uid=248;uid=249;uid=250;uid=251;uid=252;uid=253;uid=254;uid=255;uid=256;uid=257;uid=258;uid=259;uid=260;uid=261;uid=262;uid=263;uid=264;uid=265;uid=266;uid=267;uid=268;uid=269;uid=270;uid=271;uid=272;uid=273;uid=274;uid=275;uid=276;uid=277;uid=278;uid=279;uid=280;uid=281;uid=282;uid=283;uid=284;uid=285;uid=286;uid=287;uid=288;uid=289;uid=290;uid=291;uid=292;uid=293;uid=294;uid=295;uid=296;uid=297;uid=298;uid=299;uid=300;uid=301;uid=302;uid=303;uid=304;uid=305;uid=306;uid=307;uid=308;uid=309;uid=310;uid=311;uid=312;uid=313;uid=314;uid=315;uid=316;uid=317;uid=318;uid=319;uid=320;uid=321;uid=322;uid=323;uid=324;uid=325;uid=326;uid=327;uid=328;uid=329;uid=330;uid=331;uid=332;uid=333;uid=334;uid=335;uid=336;uid=337;uid=338;uid=339;uid=340;uid=341;uid=342;uid=343;uid=344;uid=345;uid=346;uid=347;uid=348;uid=349;uid=350;uid=351;uid=352;uid=353;uid=354;uid=355;uid=356;uid=357;uid=358;uid=359;uid=360;uid=361;uid=362;uid=363;uid=364;uid=365;uid=366;uid=367;uid=368;uid=369;uid=370;uid=371;uid=372;uid=373;uid=374;uid=375;uid=376;uid=377;uid=378;uid=379;uid=380;uid=381;uid=382;uid=383;uid=384;uid=385;uid=386;uid=387;uid=388;uid=389;uid=390;uid=391;uid=392;uid=393;uid=394;uid=395;uid=396;uid=397;uid=398;uid=399;uid=400;uid=401;uid=402;uid=403;uid=404;uid=405;uid=406;uid=407;uid=408;uid=409;uid=410;uid=411;uid=412;uid=413;uid=414;uid=415;uid=416;uid=417;uid=418;uid=419;uid=420;uid=421;uid=422;uid=423;uid=424;uid=425;uid=426;uid=427;uid=428;uid=429;uid=430;uid=431;uid=432;uid=433;uid=434;uid=435;uid=436;uid=437;uid=438;uid=439;uid=440;uid=441;uid=442;uid=443;uid=444;uid=445;uid=446;uid=447;uid=448;uid=449;uid=450;uid=451;uid=452;uid=453;uid=454;uid=455;uid=456;uid=457;uid=458;uid=459;uid=460;uid=461;uid=462;uid=463;uid=464;uid=465;uid=466;uid=467;uid=468;uid=469;uid=470;uid=471;uid=472;uid=473;uid=474;uid=475;uid=476;uid=477;uid=478;uid=479;uid=480;uid=481;uid=482;uid=483;uid=484;uid=485;uid=486;uid=487;uid=488;uid=489;uid=490;uid=491;uid=492;uid=493;uid=494;uid=495;uid=496;uid=497;uid=498;uid=499;env=Test;", checkedTicket->DebugInfo()); } - Y_UNIT_TEST(TicketExceptionsTest) { + Y_UNIT_TEST(TicketExceptionsTest) { TUserContext::TImpl contextTest(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket1 = contextTest.Check(UNSUPPORTED_VERSION_USER_TICKET); UNIT_ASSERT_EQUAL(ETicketStatus::UnsupportedVersion, checkedTicket1->GetStatus()); @@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { UNIT_ASSERT_NO_EXCEPTION(checkedTicket3->GetStatus()); } - Y_UNIT_TEST(TicketProtoTest) { + Y_UNIT_TEST(TicketProtoTest) { ticket2::Ticket protobufTicket; UNIT_ASSERT(protobufTicket.ParseFromString(NUtils::Base64url2bin(USER_TICKET_PROTOBUF))); TTestUserTicketImpl userTicket(ETicketStatus::Ok, std::move(protobufTicket)); @@ -145,7 +145,7 @@ Y_UNIT_TEST_SUITE_IMPLEMENTATION(UserTestSuite) { UNIT_ASSERT(!userTicket.HasScope("bb:sess3")); } - Y_UNIT_TEST(ResetKeysTest) { + Y_UNIT_TEST(ResetKeysTest) { TUserContext::TImpl context(EBlackboxEnv::Test, NUnittest::TVMKNIFE_PUBLIC_KEYS); context.ResetKeys(NUnittest::TVMKNIFE_PUBLIC_KEYS); auto checkedTicket = context.Check(VALID_USER_TICKET_1); diff --git a/library/cpp/tvmauth/src/ut/utils_ut.cpp b/library/cpp/tvmauth/src/ut/utils_ut.cpp index 676804ce7d..c9cb81c36f 100644 --- a/library/cpp/tvmauth/src/ut/utils_ut.cpp +++ b/library/cpp/tvmauth/src/ut/utils_ut.cpp @@ -4,12 +4,12 @@ #include <util/generic/maybe.h> -Y_UNIT_TEST_SUITE(UtilsTestSuite) { +Y_UNIT_TEST_SUITE(UtilsTestSuite) { static const TString VALID_SERVICE_TICKET_1 = "3:serv:CBAQ__________9_IhkI5QEQHBoIYmI6c2VzczEaCGJiOnNlc3My:WUPx1cTf05fjD1exB35T5j2DCHWH1YaLJon_a4rN-D7JfXHK1Ai4wM4uSfboHD9xmGQH7extqtlEk1tCTCGm5qbRVloJwWzCZBXo3zKX6i1oBYP_89WcjCNPVe1e8jwGdLsnu6PpxL5cn0xCksiStILH5UmDR6xfkJdnmMG94o8"; static const TString EXPIRED_SERVICE_TICKET = "3:serv:CBAQACIZCOUBEBwaCGJiOnNlc3MxGghiYjpzZXNzMg:IwfMNJYEqStY_SixwqJnyHOMCPR7-3HHk4uylB2oVRkthtezq-OOA7QizDvx7VABLs_iTlXuD1r5IjufNei_EiV145eaa3HIg4xCdJXCojMexf2UYJz8mF2b0YzFAy6_KWagU7xo13CyKAqzJuQf5MJcSUf0ecY9hVh36cJ51aw"; using namespace NTvmAuth; - Y_UNIT_TEST(base64Test) { + Y_UNIT_TEST(base64Test) { UNIT_ASSERT_VALUES_EQUAL("-hHx", NUtils::Bin2base64url("\xfa\x11\xf1")); UNIT_ASSERT_VALUES_EQUAL("-hHx_g", NUtils::Bin2base64url("\xfa\x11\xf1\xfe")); UNIT_ASSERT_VALUES_EQUAL("-hHx_v8", NUtils::Bin2base64url("\xfa\x11\xf1\xfe\xff")); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(UtilsTestSuite) { NUtils::Base64url2bin(("VGhlIE1hZ2ljIFdvcmRzIGFyZSBTcXVlYW1pc2ggT3NzaWZyYWdl"))); } - Y_UNIT_TEST(sign) { + Y_UNIT_TEST(sign) { UNIT_ASSERT_VALUES_EQUAL("wkGfeuopf709ozPAeGcDMqtZXPzsWvuNJ1BL586dSug", NUtils::SignCgiParamsForTvm(NUtils::Base64url2bin("GRMJrKnj4fOVnvOqe-WyD1"), "1490000000", diff --git a/library/cpp/unicode/normalization/custom_encoder.cpp b/library/cpp/unicode/normalization/custom_encoder.cpp index 7227902791..c6f186405f 100644 --- a/library/cpp/unicode/normalization/custom_encoder.cpp +++ b/library/cpp/unicode/normalization/custom_encoder.cpp @@ -15,7 +15,7 @@ void TCustomEncoder::addToTable(wchar32 ucode, unsigned char code, const CodePag if (Table[plane][pos] == 0) { Table[plane][pos] = code; } else { - Y_ASSERT(target && *target->Names); + Y_ASSERT(target && *target->Names); if (static_cast<unsigned char>(Table[plane][pos]) > 127 && code) { Cerr << "WARNING: Only lower part of ASCII should have duplicate encodings " << target->Names[0] @@ -37,7 +37,7 @@ bool isGoodDecomp(wchar32 rune, wchar32 decomp) { } void TCustomEncoder::Create(const CodePage* target, bool extended) { - Y_ASSERT(target); + Y_ASSERT(target); DefaultChar = (const char*)target->DefaultChar; @@ -61,7 +61,7 @@ void TCustomEncoder::Create(const CodePage* target, bool extended) { wchar32 dw = w; while (IsComposed(dw) && Code(dw) == 0) { const wchar32* decomp_p = NUnicode::Decomposition<true>(dw); - Y_ASSERT(decomp_p != nullptr); + Y_ASSERT(decomp_p != nullptr); dw = decomp_p[0]; if (std::char_traits<wchar32>::length(decomp_p) > 1 && (dw == (wchar32)' ' || dw == (wchar32)'(')) diff --git a/library/cpp/unicode/normalization/generated/composition.cpp b/library/cpp/unicode/normalization/generated/composition.cpp index 8a93147d09..7cc4dc7b75 100644 --- a/library/cpp/unicode/normalization/generated/composition.cpp +++ b/library/cpp/unicode/normalization/generated/composition.cpp @@ -947,4 +947,4 @@ const NUnicode::NPrivate::TComposition::TRawData NUnicode::NPrivate::TCompositio { 0x115B9, 0x115AF, 0x115BB }, }; // TRawData -const size_t NUnicode::NPrivate::TComposition::RawDataSize = Y_ARRAY_SIZE(NUnicode::NPrivate::TComposition::RawData); +const size_t NUnicode::NPrivate::TComposition::RawDataSize = Y_ARRAY_SIZE(NUnicode::NPrivate::TComposition::RawData); diff --git a/library/cpp/unicode/normalization/normalization.cpp b/library/cpp/unicode/normalization/normalization.cpp index de7625abea..7da7211514 100644 --- a/library/cpp/unicode/normalization/normalization.cpp +++ b/library/cpp/unicode/normalization/normalization.cpp @@ -56,7 +56,7 @@ NUnicode::NPrivate::TComposition::TComposition() { while (*decompBegin) { wchar32 tail = *(decompBegin++); wchar32 comp = ComposeHangul(lead, tail); - Y_ASSERT(comp != 0); + Y_ASSERT(comp != 0); Data[TKey(lead, tail)] = comp; diff --git a/library/cpp/unicode/normalization/normalization.h b/library/cpp/unicode/normalization/normalization.h index f458e85b7e..4f5f57881c 100644 --- a/library/cpp/unicode/normalization/normalization.h +++ b/library/cpp/unicode/normalization/normalization.h @@ -136,7 +136,7 @@ namespace NUnicode { class TCompositor<false> { public: inline void DoComposition(TBuffer& buffer) { - Y_UNUSED(buffer); + Y_UNUSED(buffer); } }; @@ -182,7 +182,7 @@ namespace NUnicode { } } while (oneMoreTurnPlease); - Y_ASSERT(DecompositionCombining(lead) == 0); + Y_ASSERT(DecompositionCombining(lead) == 0); buffer[0] = TSymbol(lead, 0); } }; @@ -280,7 +280,7 @@ namespace NUnicode { const wchar32* decompBegin = Decompositor.Decomposition(c); if (decompBegin) { while (*decompBegin) { - Y_ASSERT(Decompositor.Decomposition(*decompBegin) == nullptr); + Y_ASSERT(Decompositor.Decomposition(*decompBegin) == nullptr); AddCharNoDecomposition(*(decompBegin++), out); } return; @@ -377,8 +377,8 @@ inline TBasicString<TCharType> Normalize(const TBasicString<TCharType>& str) { ::NUnicode::TNormalizer<N> dec; return dec.Normalize(str); } - + template <NUnicode::ENormalization N, typename TCharType> inline TBasicString<TCharType> Normalize(const TBasicStringBuf<TCharType> str) { - return Normalize<N>(str.data(), str.size()); -} + return Normalize<N>(str.data(), str.size()); +} diff --git a/library/cpp/unicode/normalization/ut/normalization_ut.cpp b/library/cpp/unicode/normalization/ut/normalization_ut.cpp index 6f9eb3ef6c..54d4940a26 100644 --- a/library/cpp/unicode/normalization/ut/normalization_ut.cpp +++ b/library/cpp/unicode/normalization/ut/normalization_ut.cpp @@ -4,7 +4,7 @@ #include <library/cpp/unicode/normalization/normalization.h> -Y_UNIT_TEST_SUITE(TUnicodeNormalizationTest) { +Y_UNIT_TEST_SUITE(TUnicodeNormalizationTest) { template <NUnicode::ENormalization NormType> void TestInit() { NUnicode::TNormalizer<NormType> normalizer; @@ -14,19 +14,19 @@ Y_UNIT_TEST_SUITE(TUnicodeNormalizationTest) { normalizer.Normalize(w); } - Y_UNIT_TEST(TestInitNFD) { + Y_UNIT_TEST(TestInitNFD) { TestInit<NUnicode::NFD>(); } - Y_UNIT_TEST(TestInitNFC) { + Y_UNIT_TEST(TestInitNFC) { TestInit<NUnicode::NFC>(); } - Y_UNIT_TEST(TestInitNFKD) { + Y_UNIT_TEST(TestInitNFKD) { TestInit<NUnicode::NFKD>(); } - Y_UNIT_TEST(TestInitNFKC) { + Y_UNIT_TEST(TestInitNFKC) { TestInit<NUnicode::NFKC>(); } } diff --git a/library/cpp/unicode/punycode/punycode.cpp b/library/cpp/unicode/punycode/punycode.cpp index e2b9bab2a2..800d1f19fe 100644 --- a/library/cpp/unicode/punycode/punycode.cpp +++ b/library/cpp/unicode/punycode/punycode.cpp @@ -135,7 +135,7 @@ bool CanBePunycodeHostName(const TStringBuf& host) { TStringBuf tail(host); while (tail) { const TStringBuf label = tail.NextTok('.'); - if (label.StartsWith(ACE)) + if (label.StartsWith(ACE)) return true; } diff --git a/library/cpp/unicode/punycode/punycode_ut.cpp b/library/cpp/unicode/punycode/punycode_ut.cpp index 1423e540a5..97271cf0d8 100644 --- a/library/cpp/unicode/punycode/punycode_ut.cpp +++ b/library/cpp/unicode/punycode/punycode_ut.cpp @@ -10,7 +10,7 @@ namespace { } } -Y_UNIT_TEST_SUITE(TPunycodeTest) { +Y_UNIT_TEST_SUITE(TPunycodeTest) { static bool TestRaw(const TString& utf8, const TString& punycode) { TUtf16String unicode = UTF8ToWide(utf8); TString buf1; @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TPunycodeTest) { return HasSameBuffer(WideToPunycode(unicode, buf1), buf1) && buf1 == punycode && HasSameBuffer(PunycodeToWide(punycode, buf2), buf2) && buf2 == unicode && WideToPunycode(unicode) == punycode && PunycodeToWide(punycode) == unicode; } - Y_UNIT_TEST(RawEncodeDecode) { + Y_UNIT_TEST(RawEncodeDecode) { UNIT_ASSERT(TestRaw("", "")); UNIT_ASSERT(TestRaw(" ", " -")); UNIT_ASSERT(TestRaw("-", "--")); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TPunycodeTest) { return ForceHostNameToPunycode(UTF8ToWide(bad)) == bad && ForcePunycodeToHostName(bad) == UTF8ToWide(bad); } - Y_UNIT_TEST(HostNameEncodeDecode) { + Y_UNIT_TEST(HostNameEncodeDecode) { UNIT_ASSERT(TestHostName("президент.рф", "xn--d1abbgf6aiiy.xn--p1ai", true)); UNIT_ASSERT(TestHostName("яндекс.ru", "xn--d1acpjx3f.ru", true)); UNIT_ASSERT(TestHostName("пример", "xn--e1afmkfd", true)); diff --git a/library/cpp/uri/location_ut.cpp b/library/cpp/uri/location_ut.cpp index 9c997f41ac..26a0f64471 100644 --- a/library/cpp/uri/location_ut.cpp +++ b/library/cpp/uri/location_ut.cpp @@ -2,36 +2,36 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TResolveRedirectTests) { - Y_UNIT_TEST(Absolute) { +Y_UNIT_TEST_SUITE(TResolveRedirectTests) { + Y_UNIT_TEST(Absolute) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", "http://redir-example.com/sub"), "http://redir-example.com/sub"); } - Y_UNIT_TEST(AbsWithFragment) { + Y_UNIT_TEST(AbsWithFragment) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", "http://redir-example.com/sub#Hello"), "http://redir-example.com/sub#Hello"); UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com/#Hello", "http://redir-example.com/sub"), "http://redir-example.com/sub#Hello"); } - Y_UNIT_TEST(Rel) { + Y_UNIT_TEST(Rel) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", "/sub"), "http://example.com/sub"); } - Y_UNIT_TEST(RelWithFragment) { + Y_UNIT_TEST(RelWithFragment) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", "/sub#Hello"), "http://example.com/sub#Hello"); UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com/#Hello", "/sub"), "http://example.com/sub#Hello"); } - Y_UNIT_TEST(WrongLocation) { + Y_UNIT_TEST(WrongLocation) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", ""), ""); } - Y_UNIT_TEST(WrongBase) { + Y_UNIT_TEST(WrongBase) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("", "http://example.com"), ""); } - Y_UNIT_TEST(HashBangIsNothingSpecial) { + Y_UNIT_TEST(HashBangIsNothingSpecial) { UNIT_ASSERT_EQUAL( NUri::ResolveRedirectLocation("http://example.com", "http://redir-example.com/sub#!Hello"), "http://redir-example.com/sub#!Hello"); UNIT_ASSERT_EQUAL( diff --git a/library/cpp/uri/uri-ru_ut.cpp b/library/cpp/uri/uri-ru_ut.cpp index ac5b19160d..ec35a164d2 100644 --- a/library/cpp/uri/uri-ru_ut.cpp +++ b/library/cpp/uri/uri-ru_ut.cpp @@ -13,8 +13,8 @@ namespace NUri { } } - Y_UNIT_TEST_SUITE(URLTestRU) { - Y_UNIT_TEST(test_httpURL2) { + Y_UNIT_TEST_SUITE(URLTestRU) { + Y_UNIT_TEST(test_httpURL2) { TUri url; UNIT_ASSERT_VALUES_EQUAL(url.Parse("g:h"), TState::ParsedBadScheme); UNIT_ASSERT_VALUES_EQUAL(url.Parse("http:g"), TState::ParsedBadFormat); @@ -120,7 +120,7 @@ namespace NUri { AsWin1251("mailto:kampa@ukr.net?subject=Арабский язык"), "mailto:kampa@ukr.net?subject=%C0%F0%E0%E1%F1%EA%E8%E9%20%FF%E7%FB%EA", {}}; - Y_UNIT_TEST(testHtLinkDecode) { + Y_UNIT_TEST(testHtLinkDecode) { char decodedlink[URL_MAXLEN + 10]; for (int i = 0; links[i]; i += 2) { UNIT_ASSERT(HtLinkDecode(links[i].c_str(), decodedlink, sizeof(decodedlink))); @@ -128,7 +128,7 @@ namespace NUri { } } - Y_UNIT_TEST(testRuIDNA) { + Y_UNIT_TEST(testRuIDNA) { { #define DEC "\xD7\xE5\xF0\xE5\xEf\xEE\xE2\xE5\xF6.\xF0\xF4" /* "Череповец.рф" in Windows-1251 */ #define ENC "%D7%E5%F0%E5%EF%EE%E2%E5%F6.%F0%F4" diff --git a/library/cpp/uri/uri_ut.cpp b/library/cpp/uri/uri_ut.cpp index 852356ac26..2ebd83fc93 100644 --- a/library/cpp/uri/uri_ut.cpp +++ b/library/cpp/uri/uri_ut.cpp @@ -6,7 +6,7 @@ #include <util/system/maxlen.h> namespace NUri { - Y_UNIT_TEST_SUITE(URLTest) { + Y_UNIT_TEST_SUITE(URLTest) { static const char* urls[] = { "http://a/b/c/d;p?q#r", "g", "http://a/b/c/g", @@ -60,7 +60,7 @@ namespace NUri { // "%2zy", "http://a/b/c/%2zy", nullptr}; - Y_UNIT_TEST(test_httpURL) { + Y_UNIT_TEST(test_httpURL) { TUri rel, base, abs; TState::EParsed er = base.Parse(urls[0]); UNIT_ASSERT_VALUES_EQUAL(er, TState::ParsedOK); @@ -91,7 +91,7 @@ namespace NUri { } } - Y_UNIT_TEST(test_Schemes) { + Y_UNIT_TEST(test_Schemes) { TUri url; UNIT_ASSERT_VALUES_EQUAL(url.Parse("www.ya.ru/index.html"), TState::ParsedOK); UNIT_ASSERT_EQUAL(url.GetScheme(), TScheme::SchemeEmpty); @@ -128,7 +128,7 @@ namespace NUri { {nullptr, nullptr, nullptr, TUri::LinkIsBad}, }; - Y_UNIT_TEST(test_httpURLNormalize) { + Y_UNIT_TEST(test_httpURLNormalize) { TUri normalizedLink; for (int i = 0; link4Norm[i].link; i++) { @@ -149,7 +149,7 @@ namespace NUri { "http://a/b//c", "http://a/b/c", nullptr, nullptr}; - Y_UNIT_TEST(test_httpURLPathOperation) { + Y_UNIT_TEST(test_httpURLPathOperation) { char copyUrl[URL_MAXLEN]; for (int i = 0; urlsWithMultipleSlash[i]; i += 2) { const TStringBuf url(urlsWithMultipleSlash[i]); @@ -187,14 +187,14 @@ namespace NUri { TState::ParsedBadHost, }; - Y_UNIT_TEST(test_httpURLCheckHost) { + Y_UNIT_TEST(test_httpURLCheckHost) { for (size_t index = 0; hostsForCheckHost[index]; ++index) { TState::EParsed state = TUri::CheckHost(hostsForCheckHost[index]); UNIT_ASSERT_VALUES_EQUAL(state, answersForCheckHost[index]); } } - Y_UNIT_TEST(test_httpURLSet) { + Y_UNIT_TEST(test_httpURLSet) { // set port { TUri parsedUrl; @@ -232,7 +232,7 @@ namespace NUri { } } - Y_UNIT_TEST(test_httpURLAuth) { + Y_UNIT_TEST(test_httpURLAuth) { { TUri parsedUrl; TState::EParsed st = parsedUrl.Parse("http://@www.host.com/path", TFeature::FeaturesRobot); @@ -258,28 +258,28 @@ namespace NUri { } } - Y_UNIT_TEST(test01) { + Y_UNIT_TEST(test01) { TTest test = { "user:pass@host:8080", TFeature::FeaturesAll, TState::ParsedRootless, "user", "", "", "", 0, "", "", ""}; TUri url; URL_TEST(url, test); } - Y_UNIT_TEST(test02) { + Y_UNIT_TEST(test02) { TTest test = { "http://host", TFeature::FeaturesAll, TState::ParsedOK, "http", "", "", "host", 80, "/", "", ""}; TUri url; URL_TEST(url, test); } - Y_UNIT_TEST(test03) { + Y_UNIT_TEST(test03) { TTest test = { "https://host", TFeature::FeatureSchemeFlexible | TFeature::FeatureAllowHostIDN, TState::ParsedOK, "https", "", "", "host", 443, "/", "", ""}; TUri url; URL_TEST(url, test); } - Y_UNIT_TEST(test04) { + Y_UNIT_TEST(test04) { TTest test = { "user:pass@host:8080", TFeature::FeaturesAll | TFeature::FeatureNoRelPath | TFeature::FeatureAllowRootless, TState::ParsedOK, "user", "", "", "", 0, "pass@host:8080", "", ""}; TUri url; @@ -289,7 +289,7 @@ namespace NUri { URL_EQ(url, url2); } - Y_UNIT_TEST(test05) { + Y_UNIT_TEST(test05) { TTest test = { "host:8080", TFeature::FeaturesAll | TFeature::FeatureNoRelPath | TFeature::FeatureAllowRootless, TState::ParsedOK, "host", "", "", "", 0, "8080", "", ""}; TUri url; @@ -297,7 +297,7 @@ namespace NUri { UNIT_ASSERT_VALUES_EQUAL(url.PrintS(), "host:8080"); } - Y_UNIT_TEST(test06) { + Y_UNIT_TEST(test06) { TTest test = { "http://user:pass@host?q", TFeature::FeaturesAll, TState::ParsedOK, "http", "user", "pass", "host", 80, "/", "q", ""}; TUri url; @@ -359,7 +359,7 @@ namespace NUri { URL_EQ(url, url2); } - Y_UNIT_TEST(test07) { + Y_UNIT_TEST(test07) { { TTest test = { "http://host/path//", TFeature::FeaturesAll | TFeature::FeatureNoRelPath, TState::ParsedOK, "http", "", "", "host", 80, "/path/", "", ""}; @@ -385,7 +385,7 @@ namespace NUri { } } - Y_UNIT_TEST(test08) { + Y_UNIT_TEST(test08) { { TTest test = { "mailto://user@host.com", TFeature::FeaturesAll | TFeature::FeatureNoRelPath, TState::ParsedOK, "mailto", "user", "", "host.com", 0, "", "", ""}; @@ -472,7 +472,7 @@ namespace NUri { } } - Y_UNIT_TEST(test09) { + Y_UNIT_TEST(test09) { { TTest test = { "mailto:user@host.com", TFeature::FeaturesAll | TFeature::FeatureAllowRootless, TState::ParsedOK, "mailto", "", "", "", 0, "user@host.com", "", ""}; @@ -493,7 +493,7 @@ namespace NUri { } } - Y_UNIT_TEST(test10) { + Y_UNIT_TEST(test10) { // test some escaping madness, note the ehost vs host { TString host = "президент.рф"; @@ -553,7 +553,7 @@ namespace NUri { } } - Y_UNIT_TEST(test11) { + Y_UNIT_TEST(test11) { { TTest test = { "HtTp://HoSt/%50aTh/?Query#Frag", TFeature::FeaturesAll | TFeature::FeatureNoRelPath, TState::ParsedOK, "http", "", "", "host", 80, "/PaTh/", "Query", "Frag"}; @@ -569,7 +569,7 @@ namespace NUri { } } - Y_UNIT_TEST(test12) { + Y_UNIT_TEST(test12) { // test characters which are not always safe { #define RAW "/:" @@ -666,7 +666,7 @@ namespace NUri { } } - Y_UNIT_TEST(testFlexibleAuthority) { + Y_UNIT_TEST(testFlexibleAuthority) { TUri uri; UNIT_ASSERT_EQUAL(uri.Parse("http://hello_world", TFeature::FeatureCheckHost), TState::ParsedBadHost); UNIT_ASSERT_EQUAL(uri.Parse("http://hello_world", TFeature::FeatureSchemeFlexible), TState::ParsedOK); @@ -683,7 +683,7 @@ namespace NUri { UNIT_ASSERT_VALUES_EQUAL(uri.GetField(TField::FieldQuery), ""); } - Y_UNIT_TEST(testSpecialChar) { + Y_UNIT_TEST(testSpecialChar) { // test characters which are not always allowed { TTest test = { @@ -729,7 +729,7 @@ namespace NUri { } } - Y_UNIT_TEST(testIPv6) { + Y_UNIT_TEST(testIPv6) { { #define RAW "[1080:0:0:0:8:800:200C:417A]" #define DEC "[1080:0:0:0:8:800:200c:417a]" @@ -743,7 +743,7 @@ namespace NUri { } } - Y_UNIT_TEST(testEscapedFragment) { + Y_UNIT_TEST(testEscapedFragment) { { TTest test = { "http://host.com#!a=b&c=d#e+g%41%25", TParseFlags(TFeature::FeaturesAll | TFeature::FeatureHashBangToEscapedFragment), TState::ParsedOK, "http", "", "", "host.com", 80, "/", "_escaped_fragment_=a=b%26c=d%23e%2BgA%2525", ""}; @@ -760,7 +760,7 @@ namespace NUri { } } - Y_UNIT_TEST(testReEncode) { + Y_UNIT_TEST(testReEncode) { { TStringStream out; TUri::ReEncode(out, "foo bar"); @@ -782,7 +782,7 @@ namespace NUri { "http://translate.yandex.net/api/v1/tr.json/translate?lang=en-ru&text=>", nullptr}; - Y_UNIT_TEST(test_NonRfcUrls) { + Y_UNIT_TEST(test_NonRfcUrls) { TUri url; const long flags = TFeature::FeaturesRobot; for (size_t i = 0;; ++i) { @@ -797,7 +797,7 @@ namespace NUri { "http://www.'>'.com/?.net/", nullptr}; - Y_UNIT_TEST(test_CheckParseException) { + Y_UNIT_TEST(test_CheckParseException) { TUri url; const long flags = TFeature::FeaturesRobot | TFeature::FeaturesEncode; for (size_t i = 0;; ++i) { @@ -818,7 +818,7 @@ namespace NUri { } } - Y_UNIT_TEST(test_PrintPort) { + Y_UNIT_TEST(test_PrintPort) { TUri uri; { uri.Parse("http://srv.net:9100/print", TFeature::FeaturesRecommended); @@ -834,7 +834,7 @@ namespace NUri { } } - Y_UNIT_TEST(test_ParseFailures) { + Y_UNIT_TEST(test_ParseFailures) { { TTest test = { "http://host:port", TFeature::FeaturesAll | TFeature::FeatureNoRelPath, TState::ParsedBadFormat, "", "", "", "", Max<ui16>(), "", "", ""}; @@ -901,8 +901,8 @@ namespace NUri { } } - Y_UNIT_TEST_SUITE(TInvertDomainTest) { - Y_UNIT_TEST(TestInvert) { + Y_UNIT_TEST_SUITE(TInvertDomainTest) { + Y_UNIT_TEST(TestInvert) { TString a; UNIT_ASSERT_EQUAL(InvertDomain(a), ""); TString aa(".:/foo"); @@ -954,8 +954,8 @@ namespace NUri { return r; } - Y_UNIT_TEST_SUITE(QargsTest) { - Y_UNIT_TEST(TestSorting) { + Y_UNIT_TEST_SUITE(QargsTest) { + Y_UNIT_TEST(TestSorting) { UNIT_ASSERT_STRINGS_EQUAL(SortQargs("http://ya.ru/"), "http://ya.ru/"); UNIT_ASSERT_STRINGS_EQUAL(SortQargs("http://ya.ru/?"), "http://ya.ru/?"); UNIT_ASSERT_STRINGS_EQUAL(SortQargs("http://ya.ru/?some=value"), "http://ya.ru/?some=value"); @@ -973,7 +973,7 @@ namespace NUri { UNIT_ASSERT_STRINGS_EQUAL(SortQargs("http://ya.ru/?b==&a=&&c="), "http://ya.ru/?a=&b==&c="); } - Y_UNIT_TEST(TestParsingCorners) { + Y_UNIT_TEST(TestParsingCorners) { TString s; UNIT_ASSERT_EQUAL(ProcessQargs("http://ya.ru/?=", s), TQueryArg::ProcessedOK); @@ -992,14 +992,14 @@ namespace NUri { UNIT_ASSERT_STRINGS_EQUAL(SortQargs("http://ya.ru/?a"), "http://ya.ru/?a"); } - Y_UNIT_TEST(TestFiltering) { + Y_UNIT_TEST(TestFiltering) { UNIT_ASSERT_STRINGS_EQUAL(FilterQargs("http://ya.ru/?some=value", "missing"), "http://ya.ru/?some=value"); UNIT_ASSERT_STRINGS_EQUAL(FilterQargs("http://ya.ru/?b=1&a=2", "b"), "http://ya.ru/?a=2"); UNIT_ASSERT_STRINGS_EQUAL(FilterQargs("http://ya.ru/?b=1&a=2&a=3", "a"), "http://ya.ru/?b=1"); UNIT_ASSERT_STRINGS_EQUAL(FilterQargs("http://ya.ru/?some=&another=", "another"), "http://ya.ru/?some="); } - Y_UNIT_TEST(TestRemoveEmptyFeature) { + Y_UNIT_TEST(TestRemoveEmptyFeature) { TUri uri; uri.Parse("http://ya.ru/?", NUri::TFeature::FeaturesRecommended); @@ -1009,7 +1009,7 @@ namespace NUri { UNIT_ASSERT_STRINGS_EQUAL(uri.PrintS(), "http://ya.ru/"); } - Y_UNIT_TEST(TestNoRemoveEmptyFeature) { + Y_UNIT_TEST(TestNoRemoveEmptyFeature) { TUri uri; uri.Parse("http://ya.ru/?", NUri::TFeature::FeaturesRecommended); diff --git a/library/cpp/xml/document/xml-document.cpp b/library/cpp/xml/document/xml-document.cpp index eb2729f8db..18a554d732 100644 --- a/library/cpp/xml/document/xml-document.cpp +++ b/library/cpp/xml/document/xml-document.cpp @@ -308,7 +308,7 @@ namespace NXml { static int XmlWriteToOstream(void* context, const char* buffer, int len) { // possibly use to save doc as well - IOutputStream* out = (IOutputStream*)context; + IOutputStream* out = (IOutputStream*)context; out->Write(buffer, len); return len; } diff --git a/library/cpp/xml/document/xml-document_ut.cpp b/library/cpp/xml/document/xml-document_ut.cpp index 78e9cdf52b..9f537b75c4 100644 --- a/library/cpp/xml/document/xml-document_ut.cpp +++ b/library/cpp/xml/document/xml-document_ut.cpp @@ -3,8 +3,8 @@ #include "xml-document.h" -Y_UNIT_TEST_SUITE(TestXmlDocument) { - Y_UNIT_TEST(Iteration) { +Y_UNIT_TEST_SUITE(TestXmlDocument) { + Y_UNIT_TEST(Iteration) { NXml::TDocument xml( "<?xml version=\"1.0\"?>\n" "<root>qq<a><b></b></a>ww<c></c></root>", @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EQUAL(n.Name(), "c"); } - Y_UNIT_TEST(ParseString) { + Y_UNIT_TEST(ParseString) { NXml::TDocument xml( "<?xml version=\"1.0\"?>\n" "<root>\n" @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { NXml::TConstNode text = root.Node("text"); UNIT_ASSERT_EQUAL(text.Value<TString>(), "Некоторый текст"); } - Y_UNIT_TEST(SerializeString) { + Y_UNIT_TEST(SerializeString) { NXml::TDocument xml("frob", NXml::TDocument::RootName); xml.Root().SetAttr("xyzzy", "Frobozz"); xml.Root().SetAttr("kulness", 0.3); @@ -63,7 +63,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { "<frob xyzzy=\"привет =)\"/>\n"); } } - Y_UNIT_TEST(XPathNs) { + Y_UNIT_TEST(XPathNs) { using namespace NXml; TDocument xml( "<?xml version=\"1.0\"?>\n" @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EXCEPTION(root.Node("text", false, *ctxt), yexception); UNIT_ASSERT_EQUAL(root.Node("h:text", false, *ctxt).Value<TString>(), "Некоторый текст"); } - Y_UNIT_TEST(XmlNodes) { + Y_UNIT_TEST(XmlNodes) { using namespace NXml; TDocument xml("<?xml version=\"1.0\"?>\n" "<root>qq<a><b>asdfg</b></a>ww<c></c></root>", @@ -151,14 +151,14 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EXCEPTION(node.Value<TString>(), yexception); UNIT_ASSERT_EXCEPTION(node.IsText(), yexception); } - Y_UNIT_TEST(DefVal) { + Y_UNIT_TEST(DefVal) { using namespace NXml; TDocument xml("<?xml version=\"1.0\"?>\n" "<root><a></a></root>", NXml::TDocument::String); UNIT_ASSERT_EQUAL(xml.Root().Node("a", true).Node("b", true).Value<int>(3), 3); } - Y_UNIT_TEST(NodesVsXPath) { + Y_UNIT_TEST(NodesVsXPath) { using namespace NXml; TDocument xml("<?xml version=\"1.0\"?>\n" "<root><a x=\"y\"></a></root>", @@ -166,7 +166,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EXCEPTION(xml.Root().Nodes("/root/a/@x"), yexception); UNIT_ASSERT_VALUES_EQUAL(xml.Root().XPath("/root/a/@x").Size(), 1); } - Y_UNIT_TEST(NodeIsFirst) { + Y_UNIT_TEST(NodeIsFirst) { using namespace NXml; TDocument xml("<?xml version=\"1.0\"?>\n" "<root><a x=\"y\">first</a>" @@ -175,7 +175,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EXCEPTION(xml.Root().Node("/root/a/@x"), yexception); UNIT_ASSERT_STRINGS_EQUAL(xml.Root().Node("/root/a").Value<TString>(), "first"); } - Y_UNIT_TEST(CopyNode) { + Y_UNIT_TEST(CopyNode) { using namespace NXml; // default-construct empty node TNode empty; @@ -204,7 +204,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { "<root><a><node><b>bold</b><i>ita</i></node></a></root>\n"); } - Y_UNIT_TEST(RenderNode) { + Y_UNIT_TEST(RenderNode) { using namespace NXml; { // no namespaces @@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { } } - Y_UNIT_TEST(ReuseXPathContext) { + Y_UNIT_TEST(ReuseXPathContext) { using namespace NXml; TDocument xml( @@ -279,7 +279,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EQUAL(ys[0].Value<int>(), 20); } - Y_UNIT_TEST(Html) { + Y_UNIT_TEST(Html) { using namespace NXml; TDocument htmlChunk("video", TDocument::RootName); diff --git a/library/cpp/xml/document/xml-options_ut.cpp b/library/cpp/xml/document/xml-options_ut.cpp index 63f2ed4f59..9be16baf3d 100644 --- a/library/cpp/xml/document/xml-options_ut.cpp +++ b/library/cpp/xml/document/xml-options_ut.cpp @@ -2,19 +2,19 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TestXmlOptions) { - Y_UNIT_TEST(SetHuge) { +Y_UNIT_TEST_SUITE(TestXmlOptions) { + Y_UNIT_TEST(SetHuge) { NXml::TOptions opts; opts.Set(NXml::EOption::Huge); UNIT_ASSERT_EQUAL(XML_PARSE_HUGE, opts.GetMask()); } - Y_UNIT_TEST(VariadicContructor) { + Y_UNIT_TEST(VariadicContructor) { NXml::TOptions opts(NXml::EOption::Huge, NXml::EOption::Compact, NXml::EOption::SAX1); UNIT_ASSERT_EQUAL(XML_PARSE_HUGE | XML_PARSE_COMPACT | XML_PARSE_SAX1, opts.GetMask()); } - Y_UNIT_TEST(Chaining) { + Y_UNIT_TEST(Chaining) { NXml::TOptions opts; opts diff --git a/library/cpp/xml/document/xml-textreader.cpp b/library/cpp/xml/document/xml-textreader.cpp index 557fe9d3d4..b946f1fbf2 100644 --- a/library/cpp/xml/document/xml-textreader.cpp +++ b/library/cpp/xml/document/xml-textreader.cpp @@ -7,7 +7,7 @@ #include <util/system/compiler.h> namespace NXml { - TTextReader::TTextReader(IInputStream& stream, const TOptions& options) + TTextReader::TTextReader(IInputStream& stream, const TOptions& options) : Stream(stream) , IsError(false) { @@ -169,12 +169,12 @@ namespace NXml { // It is almost "noexcept" (std::bad_alloc may happen when saving exception message to new TString). // Waiting for std::exception_ptr and std::rethrow_exception from C++11 in Arcadia to make it really "noexcept". int TTextReader::ReadFromInputStreamCallback(void* context, char* buffer, int len) { - Y_ASSERT(len >= 0); + Y_ASSERT(len >= 0); TTextReader* reader = static_cast<TTextReader*>(context); int result = -1; - // Exception may be thrown by IInputStream::Read(). + // Exception may be thrown by IInputStream::Read(). // It is caught unconditionally because exceptions cannot safely pass through libxml2 plain C code // (no destructors, no RAII, raw pointers, so in case of stack unwinding some memory gets leaked). @@ -191,7 +191,7 @@ namespace NXml { void TTextReader::OnLibxmlError(void* arg, const char* msg, xmlParserSeverities severity, xmlTextReaderLocatorPtr locator) { TTextReader* reader = static_cast<TTextReader*>(arg); - Y_ASSERT(reader != nullptr); + Y_ASSERT(reader != nullptr); TStringStream& out = reader->LogError(); @@ -247,7 +247,7 @@ namespace NXml { } void TTextReader::CheckForExceptions() const { - if (Y_LIKELY(!IsError)) { + if (Y_LIKELY(!IsError)) { return; } @@ -266,28 +266,28 @@ namespace NXml { } bool TTextReader::BoolResult(int value) const { - if (Y_UNLIKELY(value == -1)) { + if (Y_UNLIKELY(value == -1)) { ThrowException(); } return (value != 0); } int TTextReader::IntResult(int value) const { - if (Y_UNLIKELY(value == -1)) { + if (Y_UNLIKELY(value == -1)) { ThrowException(); } return value; } char TTextReader::CharResult(int value) const { - if (Y_UNLIKELY(value == -1)) { + if (Y_UNLIKELY(value == -1)) { ThrowException(); } return static_cast<char>(value); } TStringBuf TTextReader::ConstStringResult(const xmlChar* value) const { - if (Y_UNLIKELY(value == nullptr)) { + if (Y_UNLIKELY(value == nullptr)) { ThrowException(); } return CAST2CHAR(value); @@ -299,7 +299,7 @@ namespace NXml { } TString TTextReader::TempStringResult(TCharPtr value) const { - if (Y_UNLIKELY(value == nullptr)) { + if (Y_UNLIKELY(value == nullptr)) { ThrowException(); } return TString(CAST2CHAR(value.Get())); diff --git a/library/cpp/xml/document/xml-textreader.h b/library/cpp/xml/document/xml-textreader.h index a1309c1019..ab4c329d26 100644 --- a/library/cpp/xml/document/xml-textreader.h +++ b/library/cpp/xml/document/xml-textreader.h @@ -77,7 +77,7 @@ namespace NXml { }; public: - TTextReader(IInputStream& stream, const TOptions& options = TOptions()); + TTextReader(IInputStream& stream, const TOptions& options = TOptions()); ~TTextReader(); /** @@ -313,7 +313,7 @@ namespace NXml { TString TempStringOrEmptyResult(TCharPtr value) const; private: - IInputStream& Stream; + IInputStream& Stream; mutable bool IsError; mutable TStringStream ErrorBuffer; diff --git a/library/cpp/xml/document/xml-textreader_ut.cpp b/library/cpp/xml/document/xml-textreader_ut.cpp index 81e11e3348..6232dfe47e 100644 --- a/library/cpp/xml/document/xml-textreader_ut.cpp +++ b/library/cpp/xml/document/xml-textreader_ut.cpp @@ -29,8 +29,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TestXmlTextReader) { - Y_UNIT_TEST(BasicExample) { +Y_UNIT_TEST_SUITE(TestXmlTextReader) { + Y_UNIT_TEST(BasicExample) { const TString xml = "<?xml version=\"1.0\"?>\n" "<example toto=\"1\">\n" " <examplechild id=\"1\">\n" @@ -134,7 +134,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { "" "</root>"; - Y_UNIT_TEST(ParseXmlSimple) { + Y_UNIT_TEST(ParseXmlSimple) { struct TCountry { TString Name; TVector<TString> Cities; @@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { c.Name = node.FirstChild("name").Value<TString>(); const NXml::TConstNodes cityNodes = node.Nodes("cities/city"); - for (auto cityNode : cityNodes) { + for (auto cityNode : cityNodes) { c.Cities.push_back(cityNode.Value<TString>()); } }; @@ -179,7 +179,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { UNIT_ASSERT_EQUAL(ukraine.Cities[0], "Киев"); } - Y_UNIT_TEST(ParseXmlDeepLevel) { + Y_UNIT_TEST(ParseXmlDeepLevel) { TVector<TString> cities; auto handler = [&cities](NXml::TConstNode node) { @@ -195,7 +195,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { UNIT_ASSERT_EQUAL(cities[3], "Киев"); } - Y_UNIT_TEST(ParseXmlException) { + Y_UNIT_TEST(ParseXmlException) { // Check that exception properly passes through plain C code of libxml, // no leaks are detected by valgrind. auto handler = [](NXml::TConstNode node) { @@ -251,7 +251,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { "" "</Companies>"; - Y_UNIT_TEST(NamespaceHell) { + Y_UNIT_TEST(NamespaceHell) { using TNS = NXml::TNamespaceForXPath; const NXml::TNamespacesForXPath ns = { TNS{"b", "http://maps.yandex.ru/backa/1.x"}, diff --git a/library/cpp/ya.make b/library/cpp/ya.make index 1ee2a6cc49..8c1193b007 100644 --- a/library/cpp/ya.make +++ b/library/cpp/ya.make @@ -4,8 +4,8 @@ RECURSE( accurate_accumulate accurate_accumulate/benchmark accurate_accumulate/benchmark/metrics - actors - actors/ut + actors + actors/ut aio any any/ut @@ -14,7 +14,7 @@ RECURSE( barcode barcode/ut binsaver - binsaver/ut + binsaver/ut binsaver/ut_util bit_io bit_io/ut @@ -62,8 +62,8 @@ RECURSE( config/ut consistent_hash_ring consistent_hash_ring/ut - consistent_hashing - consistent_hashing/ut + consistent_hashing + consistent_hashing/ut containers coroutine cppparser @@ -136,7 +136,7 @@ RECURSE( geohash/tile geohash/tile/ut geohash/ut - geolocation + geolocation geotarget getopt getopt/last_getopt_demo @@ -195,8 +195,8 @@ RECURSE( langmask/proto langmask/serialization langmask/ut - langs - langs/ut + langs + langs/ut lcookie lcookie/ut lcs @@ -243,8 +243,8 @@ RECURSE( minhash minhash/tools minhash/ut - mongo - monlib + mongo + monlib msgpack msgpack2json msgpack2json/ut @@ -338,8 +338,8 @@ RECURSE( solve_ambig/ut sorter sorter/ut - sqlite3 - sqlite3/ut + sqlite3 + sqlite3/ut sse ssh ssh/ut diff --git a/library/cpp/yson/node/node.cpp b/library/cpp/yson/node/node.cpp index c5933fa943..b39e070718 100644 --- a/library/cpp/yson/node/node.cpp +++ b/library/cpp/yson/node/node.cpp @@ -7,7 +7,7 @@ #include <util/generic/overloaded.h> namespace NYT { - + //////////////////////////////////////////////////////////////////////////////// bool TNode::TNull::operator==(const TNull&) const { @@ -346,51 +346,51 @@ TNode::TMapType& TNode::AsMap() return std::get<TMapType>(Value_); } -const TString& TNode::UncheckedAsString() const noexcept -{ +const TString& TNode::UncheckedAsString() const noexcept +{ return std::get<TString>(Value_); -} - -i64 TNode::UncheckedAsInt64() const noexcept -{ +} + +i64 TNode::UncheckedAsInt64() const noexcept +{ return std::get<i64>(Value_); -} - -ui64 TNode::UncheckedAsUint64() const noexcept -{ +} + +ui64 TNode::UncheckedAsUint64() const noexcept +{ return std::get<ui64>(Value_); -} - -double TNode::UncheckedAsDouble() const noexcept -{ +} + +double TNode::UncheckedAsDouble() const noexcept +{ return std::get<double>(Value_); -} - -bool TNode::UncheckedAsBool() const noexcept -{ +} + +bool TNode::UncheckedAsBool() const noexcept +{ return std::get<bool>(Value_); -} - +} + const TNode::TListType& TNode::UncheckedAsList() const noexcept -{ +{ return std::get<TListType>(Value_); -} - +} + const TNode::TMapType& TNode::UncheckedAsMap() const noexcept -{ +{ return std::get<TMapType>(Value_); -} - +} + TNode::TListType& TNode::UncheckedAsList() noexcept -{ +{ return std::get<TListType>(Value_); -} - +} + TNode::TMapType& TNode::UncheckedAsMap() noexcept -{ +{ return std::get<TMapType>(Value_); -} - +} + TNode TNode::CreateList() { TNode node; @@ -850,12 +850,12 @@ void TNode::CreateAttributes() Attributes_->Value_ = TMapType(); } -void TNode::Save(IOutputStream* out) const +void TNode::Save(IOutputStream* out) const { NodeToYsonStream(*this, out, NYson::EYsonFormat::Binary); } -void TNode::Load(IInputStream* in) +void TNode::Load(IInputStream* in) { Clear(); *this = NodeFromYsonStream(in, ::NYson::EYsonType::Node); diff --git a/library/cpp/yson/node/node.h b/library/cpp/yson/node/node.h index 971b5355be..5f90f95df0 100644 --- a/library/cpp/yson/node/node.h +++ b/library/cpp/yson/node/node.h @@ -12,8 +12,8 @@ #include <cmath> #include <variant> -class IInputStream; -class IOutputStream; +class IInputStream; +class IOutputStream; namespace NYT { @@ -149,16 +149,16 @@ public: TListType& AsList(); TMapType& AsMap(); - const TString& UncheckedAsString() const noexcept; - i64 UncheckedAsInt64() const noexcept; - ui64 UncheckedAsUint64() const noexcept; - double UncheckedAsDouble() const noexcept; - bool UncheckedAsBool() const noexcept; + const TString& UncheckedAsString() const noexcept; + i64 UncheckedAsInt64() const noexcept; + ui64 UncheckedAsUint64() const noexcept; + double UncheckedAsDouble() const noexcept; + bool UncheckedAsBool() const noexcept; const TListType& UncheckedAsList() const noexcept; const TMapType& UncheckedAsMap() const noexcept; TListType& UncheckedAsList() noexcept; TMapType& UncheckedAsMap() noexcept; - + // integer types cast // makes overflow checks template<typename T> @@ -264,8 +264,8 @@ public: // Serialize TNode using binary yson format. // Methods for ysaveload. - void Save(IOutputStream* output) const; - void Load(IInputStream* input); + void Save(IOutputStream* output) const; + void Load(IInputStream* input); private: void Move(TNode&& rhs); diff --git a/library/cpp/yson/node/node_ut.cpp b/library/cpp/yson/node/node_ut.cpp index f6922f7d01..448e99f575 100644 --- a/library/cpp/yson/node/node_ut.cpp +++ b/library/cpp/yson/node/node_ut.cpp @@ -8,13 +8,13 @@ using namespace NYT; template<> -void Out<NYT::TNode>(IOutputStream& s, const NYT::TNode& node) +void Out<NYT::TNode>(IOutputStream& s, const NYT::TNode& node) { s << "TNode:" << NodeToYsonString(node); } -Y_UNIT_TEST_SUITE(YtNodeTest) { - Y_UNIT_TEST(TestConstsructors) { +Y_UNIT_TEST_SUITE(YtNodeTest) { + Y_UNIT_TEST(TestConstsructors) { TNode nodeEmpty; UNIT_ASSERT_EQUAL(nodeEmpty.GetType(), TNode::Undefined); @@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_VALUES_EQUAL(mapNode.AsMap(), expectedMapValue); } - Y_UNIT_TEST(TestNodeMap) { + Y_UNIT_TEST(TestNodeMap) { TNode nodeMap = TNode()("foo", "bar")("bar", "baz"); UNIT_ASSERT(nodeMap.IsMap()); UNIT_ASSERT_EQUAL(nodeMap.GetType(), TNode::Map); @@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_EQUAL(copyNode["rock!!!"]["Purple"], TNode("Deep")); } - Y_UNIT_TEST(TestNodeList) { + Y_UNIT_TEST(TestNodeList) { TNode nodeList = TNode().Add("foo").Add(42).Add(3.14); UNIT_ASSERT(nodeList.IsList()); UNIT_ASSERT_EQUAL(nodeList.GetType(), TNode::List); @@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_EQUAL(copyNode[3][1], TNode("pwd")); } - Y_UNIT_TEST(TestInsertingMethodsFromTemporaryObjects) { + Y_UNIT_TEST(TestInsertingMethodsFromTemporaryObjects) { // check that .Add(...) doesn't return lvalue reference to temporary object { const TNode& nodeList = TNode().Add(0).Add("pass").Add(0); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { } } - Y_UNIT_TEST(TestAttributes) { + Y_UNIT_TEST(TestAttributes) { TNode node = TNode()("lee", 42)("faa", 54); UNIT_ASSERT(!node.HasAttributes()); node.Attributes()("foo", true)("bar", false); @@ -185,7 +185,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { } } - Y_UNIT_TEST(TestEq) { + Y_UNIT_TEST(TestEq) { TNode nodeNoAttributes = TNode()("lee", 42)("faa", 54); TNode node = nodeNoAttributes; node.Attributes()("foo", true)("bar", false); @@ -260,7 +260,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { } } - Y_UNIT_TEST(TestSaveLoad) { + Y_UNIT_TEST(TestSaveLoad) { TNode node = TNode()("foo", "bar")("baz", 42); node.Attributes()["attr_name"] = "attr_value"; @@ -279,7 +279,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_VALUES_EQUAL(node, nodeCopy); } - Y_UNIT_TEST(TestIntCast) { + Y_UNIT_TEST(TestIntCast) { TNode node = 1ull << 31; UNIT_ASSERT(node.IsUint64()); UNIT_ASSERT_EXCEPTION(node.IntCast<i32>(), TNode::TTypeError); @@ -315,7 +315,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_EXCEPTION(node.IntCast<ui64>(), TNode::TTypeError); } - Y_UNIT_TEST(TestConvertToString) { + Y_UNIT_TEST(TestConvertToString) { UNIT_ASSERT_VALUES_EQUAL(TNode(5).ConvertTo<TString>(), "5"); UNIT_ASSERT_VALUES_EQUAL(TNode(123432423).ConvertTo<TString>(), "123432423"); UNIT_ASSERT_VALUES_EQUAL(TNode(123456789012345678ll).ConvertTo<TString>(), "123456789012345678"); @@ -326,7 +326,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<TString>(), "5.3"); } - Y_UNIT_TEST(TestConvertFromString) { + Y_UNIT_TEST(TestConvertFromString) { UNIT_ASSERT_VALUES_EQUAL(TNode("123456789012345678").ConvertTo<ui64>(), 123456789012345678ull); UNIT_ASSERT_VALUES_EQUAL(TNode("123456789012345678").ConvertTo<i64>(), 123456789012345678); UNIT_ASSERT_VALUES_EQUAL(TNode(ToString(1ull << 63)).ConvertTo<ui64>(), 1ull << 63); @@ -334,7 +334,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_VALUES_EQUAL(TNode("5.34").ConvertTo<double>(), 5.34); } - Y_UNIT_TEST(TestConvertDoubleInt) { + Y_UNIT_TEST(TestConvertDoubleInt) { UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<i8>(), 5); UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<ui8>(), 5); UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<i64>(), 5); @@ -372,7 +372,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_EXCEPTION(TNode(INFINITY).ConvertTo<i64>(), TNode::TTypeError); } - Y_UNIT_TEST(TestConvertToBool) { + Y_UNIT_TEST(TestConvertToBool) { UNIT_ASSERT_VALUES_EQUAL(TNode("true").ConvertTo<bool>(), true); UNIT_ASSERT_VALUES_EQUAL(TNode("TRUE").ConvertTo<bool>(), true); UNIT_ASSERT_VALUES_EQUAL(TNode("false").ConvertTo<bool>(), false); @@ -383,7 +383,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) { UNIT_ASSERT_EXCEPTION(TNode("").ConvertTo<bool>(), TFromStringException); } - Y_UNIT_TEST(TestCanonicalSerialization) { + Y_UNIT_TEST(TestCanonicalSerialization) { auto node = TNode() ("ca", "ca")("c", "c")("a", "a")("b", "b") ("bb", TNode() diff --git a/library/cpp/yson/parser.cpp b/library/cpp/yson/parser.cpp index 99d2e55b9c..783f9b9047 100644 --- a/library/cpp/yson/parser.cpp +++ b/library/cpp/yson/parser.cpp @@ -47,7 +47,7 @@ namespace NYson { TYsonParser::TYsonParser( NYT::NYson::IYsonConsumer* consumer, - IInputStream* stream, + IInputStream* stream, EYsonType type, bool enableLinePositionInfo, TMaybe<ui64> memoryLimit) @@ -160,7 +160,7 @@ namespace NYson { TYsonListParser::TYsonListParser( NYT::NYson::IYsonConsumer* consumer, - IInputStream* stream, + IInputStream* stream, bool enableLinePositionInfo, TMaybe<ui64> memoryLimit) : Impl(new TImpl(consumer, stream, enableLinePositionInfo, memoryLimit)) diff --git a/library/cpp/yson/parser.h b/library/cpp/yson/parser.h index 1cb6fa0919..dce35a8cd4 100644 --- a/library/cpp/yson/parser.h +++ b/library/cpp/yson/parser.h @@ -5,7 +5,7 @@ #include <util/generic/maybe.h> #include <util/generic/ptr.h> -class IInputStream; +class IInputStream; namespace NYT::NYson { struct IYsonConsumer; diff --git a/library/cpp/yson/writer.h b/library/cpp/yson/writer.h index a43cce58f3..40f5d7d501 100644 --- a/library/cpp/yson/writer.h +++ b/library/cpp/yson/writer.h @@ -6,8 +6,8 @@ #include <util/generic/noncopyable.h> -class IOutputStream; -class IZeroCopyInput; +class IOutputStream; +class IZeroCopyInput; namespace NYson { //////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/yson_pull/detail/input/stream.h b/library/cpp/yson_pull/detail/input/stream.h index dfc1fc98ba..791cd5a3f5 100644 --- a/library/cpp/yson_pull/detail/input/stream.h +++ b/library/cpp/yson_pull/detail/input/stream.h @@ -14,7 +14,7 @@ namespace NYsonPull { namespace NInput { class TStreamBase: public NYsonPull::NInput::IStream { protected: - result DoFillBufferFrom(IZeroCopyInput& input) { + result DoFillBufferFrom(IZeroCopyInput& input) { void* ptr = nullptr; size_t size = input.Next(&ptr); if (Y_UNLIKELY(size == 0)) { @@ -26,10 +26,10 @@ namespace NYsonPull { }; class TZeroCopy: public TStreamBase { - IZeroCopyInput* Input; + IZeroCopyInput* Input; public: - explicit TZeroCopy(IZeroCopyInput* input) + explicit TZeroCopy(IZeroCopyInput* input) : Input(input) { } diff --git a/library/cpp/yson_pull/detail/output/stream.h b/library/cpp/yson_pull/detail/output/stream.h index 494e298068..d4810f3353 100644 --- a/library/cpp/yson_pull/detail/output/stream.h +++ b/library/cpp/yson_pull/detail/output/stream.h @@ -13,10 +13,10 @@ namespace NYsonPull { namespace NDetail { namespace NOutput { class TStream: public TBuffered<TStream> { - IOutputStream* Output; + IOutputStream* Output; public: - TStream(IOutputStream* output, size_t buffer_size) + TStream(IOutputStream* output, size_t buffer_size) : TBuffered<TStream>(buffer_size) , Output(output) { diff --git a/library/cpp/yson_pull/event.cpp b/library/cpp/yson_pull/event.cpp index b75d97fd8f..b7ede494b6 100644 --- a/library/cpp/yson_pull/event.cpp +++ b/library/cpp/yson_pull/event.cpp @@ -7,7 +7,7 @@ using namespace NYsonPull; template <> -void Out<TEvent>(IOutputStream& out, const TEvent& value) { +void Out<TEvent>(IOutputStream& out, const TEvent& value) { out << '(' << value.Type(); if (value.Type() == EEventType::Scalar) { out << ' ' << value.AsScalar(); diff --git a/library/cpp/yson_pull/input.cpp b/library/cpp/yson_pull/input.cpp index 9b75c4c297..1373c89868 100644 --- a/library/cpp/yson_pull/input.cpp +++ b/library/cpp/yson_pull/input.cpp @@ -24,10 +24,10 @@ THolder<IStream> NInput::FromMemory(TStringBuf data) { return MakeHolder<TOwned<TMemoryInput>>(data); } -THolder<IStream> NInput::FromInputStream(IInputStream* input, size_t buffer_size) { +THolder<IStream> NInput::FromInputStream(IInputStream* input, size_t buffer_size) { return MakeHolder<TOwned<TBufferedInput>>(input, buffer_size); } -THolder<IStream> NInput::FromZeroCopyInput(IZeroCopyInput* input) { +THolder<IStream> NInput::FromZeroCopyInput(IZeroCopyInput* input) { return MakeHolder<TZeroCopy>(input); } diff --git a/library/cpp/yson_pull/input.h b/library/cpp/yson_pull/input.h index 66184de034..2cdfae857e 100644 --- a/library/cpp/yson_pull/input.h +++ b/library/cpp/yson_pull/input.h @@ -10,8 +10,8 @@ #include <cstddef> #include <memory> -class IInputStream; -class IZeroCopyInput; +class IInputStream; +class IZeroCopyInput; namespace NYsonPull { namespace NInput { @@ -74,8 +74,8 @@ namespace NYsonPull { //! Does not take ownership on streambuf. THolder<IStream> FromPosixFd(int fd, size_t buffer_size = 65536); - THolder<IStream> FromZeroCopyInput(IZeroCopyInput* input); + THolder<IStream> FromZeroCopyInput(IZeroCopyInput* input); - THolder<IStream> FromInputStream(IInputStream* input, size_t buffer_size = 65536); + THolder<IStream> FromInputStream(IInputStream* input, size_t buffer_size = 65536); } } diff --git a/library/cpp/yson_pull/output.cpp b/library/cpp/yson_pull/output.cpp index 5d58966dbe..27c9ef9e69 100644 --- a/library/cpp/yson_pull/output.cpp +++ b/library/cpp/yson_pull/output.cpp @@ -24,6 +24,6 @@ THolder<IStream> NOutput::FromString(TString* output, size_t buffer_size) { return MakeHolder<TOwned<TStringOutput>>(buffer_size, *output); } -THolder<IStream> NOutput::FromOutputStream(IOutputStream* output, size_t buffer_size) { +THolder<IStream> NOutput::FromOutputStream(IOutputStream* output, size_t buffer_size) { return MakeHolder<TStream>(output, buffer_size); } diff --git a/library/cpp/yson_pull/output.h b/library/cpp/yson_pull/output.h index 32d55a6b0b..2d78107a93 100644 --- a/library/cpp/yson_pull/output.h +++ b/library/cpp/yson_pull/output.h @@ -58,7 +58,7 @@ namespace NYsonPull { //! \brief Write data to POSIX file descriptor THolder<IStream> FromPosixFd(int fd, size_t buffer_size = 65536); - THolder<IStream> FromOutputStream(IOutputStream* output, size_t buffer_size = 65536); + THolder<IStream> FromOutputStream(IOutputStream* output, size_t buffer_size = 65536); THolder<IStream> FromString(TString* output, size_t buffer_size = 1024); } diff --git a/library/cpp/yson_pull/scalar.cpp b/library/cpp/yson_pull/scalar.cpp index a538a07ecf..4325542e7a 100644 --- a/library/cpp/yson_pull/scalar.cpp +++ b/library/cpp/yson_pull/scalar.cpp @@ -7,7 +7,7 @@ using namespace NYsonPull; template <> -void Out<TScalar>(IOutputStream& out, const TScalar& value) { +void Out<TScalar>(IOutputStream& out, const TScalar& value) { out << '(' << value.Type(); if (value.Type() != EScalarType::Entity) { out << ' '; diff --git a/library/cpp/yson_pull/ut/cescape_ut.cpp b/library/cpp/yson_pull/ut/cescape_ut.cpp index 8e1547cdac..6628ba1d15 100644 --- a/library/cpp/yson_pull/ut/cescape_ut.cpp +++ b/library/cpp/yson_pull/ut/cescape_ut.cpp @@ -39,20 +39,20 @@ namespace { } // anonymous namespace -Y_UNIT_TEST_SUITE(CEscape) { - Y_UNIT_TEST(ExhaustiveOneChar) { +Y_UNIT_TEST_SUITE(CEscape) { + Y_UNIT_TEST(ExhaustiveOneChar) { test_exhaustive<1>(); } - Y_UNIT_TEST(ExhaustiveTwoChars) { + Y_UNIT_TEST(ExhaustiveTwoChars) { test_exhaustive<2>(); } - Y_UNIT_TEST(ExhaustiveThreeChars) { + Y_UNIT_TEST(ExhaustiveThreeChars) { test_exhaustive<3>(); } - Y_UNIT_TEST(SpecialEscapeEncode) { + Y_UNIT_TEST(SpecialEscapeEncode) { //UNIT_ASSERT_VALUES_EQUAL(R"(\b)", NCEscape::encode("\b")); //UNIT_ASSERT_VALUES_EQUAL(R"(\f)", NCEscape::encode("\f")); UNIT_ASSERT_VALUES_EQUAL(R"(\n)", NCEscape::encode("\n")); @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(CEscape) { UNIT_ASSERT_VALUES_EQUAL(R"(\t)", NCEscape::encode("\t")); } - Y_UNIT_TEST(SpecialEscapeDecode) { + Y_UNIT_TEST(SpecialEscapeDecode) { UNIT_ASSERT_VALUES_EQUAL("\b", NCEscape::decode(R"(\b)")); UNIT_ASSERT_VALUES_EQUAL("\f", NCEscape::decode(R"(\f)")); UNIT_ASSERT_VALUES_EQUAL("\n", NCEscape::decode(R"(\n)")); @@ -68,4 +68,4 @@ Y_UNIT_TEST_SUITE(CEscape) { UNIT_ASSERT_VALUES_EQUAL("\t", NCEscape::decode(R"(\t)")); } -} // Y_UNIT_TEST_SUITE(CEscape) +} // Y_UNIT_TEST_SUITE(CEscape) diff --git a/library/cpp/yson_pull/ut/loop_ut.cpp b/library/cpp/yson_pull/ut/loop_ut.cpp index 8ca651dc30..8c7b11dd1c 100644 --- a/library/cpp/yson_pull/ut/loop_ut.cpp +++ b/library/cpp/yson_pull/ut/loop_ut.cpp @@ -202,7 +202,7 @@ namespace { class sys_error {}; - IOutputStream& operator<<(IOutputStream& stream, const sys_error&) { + IOutputStream& operator<<(IOutputStream& stream, const sys_error&) { stream << strerror(errno); return stream; } @@ -317,66 +317,66 @@ namespace { } // anonymous namespace -Y_UNIT_TEST_SUITE(Loop) { - Y_UNIT_TEST(memory_pretty_text) { +Y_UNIT_TEST_SUITE(Loop) { + Y_UNIT_TEST(memory_pretty_text) { test_memory(pretty_text, 100); } - Y_UNIT_TEST(memory_text) { + Y_UNIT_TEST(memory_text) { test_memory(text, 100); } - Y_UNIT_TEST(memory_binary) { + Y_UNIT_TEST(memory_binary) { test_memory(binary, 100); } #ifdef _unix_ - Y_UNIT_TEST(posix_fd_pretty_text_buffered) { + Y_UNIT_TEST(posix_fd_pretty_text_buffered) { test_posix_fd(pretty_text, 100, 1024, 1024); } - Y_UNIT_TEST(posix_fd_pretty_text_unbuffered) { + Y_UNIT_TEST(posix_fd_pretty_text_unbuffered) { test_posix_fd(pretty_text, 100, 1, 0); } - Y_UNIT_TEST(posix_fd_text_buffered) { + Y_UNIT_TEST(posix_fd_text_buffered) { test_posix_fd(text, 100, 1024, 1024); } - Y_UNIT_TEST(posix_fd_text_unbuffered) { + Y_UNIT_TEST(posix_fd_text_unbuffered) { test_posix_fd(text, 100, 1, 0); } - Y_UNIT_TEST(posix_fd_binary_buffered) { + Y_UNIT_TEST(posix_fd_binary_buffered) { test_posix_fd(binary, 100, 1024, 1024); } - Y_UNIT_TEST(posix_fd_binary_unbuffered) { + Y_UNIT_TEST(posix_fd_binary_unbuffered) { test_posix_fd(binary, 100, 1, 0); } - Y_UNIT_TEST(stdio_file_pretty_text_buffered) { + Y_UNIT_TEST(stdio_file_pretty_text_buffered) { test_stdio_file(pretty_text, 100, 1024, 1024); } - Y_UNIT_TEST(stdio_file_pretty_text_unbuffered) { + Y_UNIT_TEST(stdio_file_pretty_text_unbuffered) { test_stdio_file(pretty_text, 100, 1, 0); } - Y_UNIT_TEST(stdio_file_text_buffered) { + Y_UNIT_TEST(stdio_file_text_buffered) { test_stdio_file(text, 100, 1024, 1024); } - Y_UNIT_TEST(stdio_file_text_unbuffered) { + Y_UNIT_TEST(stdio_file_text_unbuffered) { test_stdio_file(text, 100, 1, 0); } - Y_UNIT_TEST(stdio_file_binary_buffered) { + Y_UNIT_TEST(stdio_file_binary_buffered) { test_stdio_file(binary, 100, 1024, 1024); } - Y_UNIT_TEST(stdio_file_binary_unbuffered) { + Y_UNIT_TEST(stdio_file_binary_unbuffered) { test_stdio_file(binary, 100, 1, 0); } #endif -} // Y_UNIT_TEST_SUITE(Loop) +} // Y_UNIT_TEST_SUITE(Loop) diff --git a/library/cpp/yson_pull/ut/reader_ut.cpp b/library/cpp/yson_pull/ut/reader_ut.cpp index 21fb5e01a4..1184265ddb 100644 --- a/library/cpp/yson_pull/ut/reader_ut.cpp +++ b/library/cpp/yson_pull/ut/reader_ut.cpp @@ -73,12 +73,12 @@ namespace { } // anonymous namespace -Y_UNIT_TEST_SUITE(Reader) { - Y_UNIT_TEST(ScalarEntity) { +Y_UNIT_TEST_SUITE(Reader) { + Y_UNIT_TEST(ScalarEntity) { test_scalar(TStringBuf("#"), NYsonPull::TScalar{}); } - Y_UNIT_TEST(ScalarBoolean) { + Y_UNIT_TEST(ScalarBoolean) { test_scalar(TStringBuf("%true"), true); test_scalar(TStringBuf("%false"), false); @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("%hithere"); } - Y_UNIT_TEST(ScalarInt64) { + Y_UNIT_TEST(ScalarInt64) { test_scalar(TStringBuf("1"), i64{1}); test_scalar(TStringBuf("+1"), i64{1}); test_scalar(TStringBuf("100000"), i64{100000}); @@ -112,7 +112,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("1+0"); } - Y_UNIT_TEST(SclarUInt64) { + Y_UNIT_TEST(SclarUInt64) { test_scalar(TStringBuf("1u"), ui64{1}); test_scalar(TStringBuf("+1u"), ui64{1}); test_scalar(TStringBuf("100000u"), ui64{100000}); @@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(Reader) { // TODO: binary } - Y_UNIT_TEST(ScalarFloat64) { + Y_UNIT_TEST(ScalarFloat64) { test_scalar(TStringBuf("0.0"), double{0.0}); test_scalar(TStringBuf("+0.0"), double{0.0}); test_scalar(TStringBuf("+.0"), double{0.0}); @@ -193,7 +193,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("%-in"); } - Y_UNIT_TEST(ScalarString) { + Y_UNIT_TEST(ScalarString) { test_scalar(TStringBuf(R"(foobar)"), TStringBuf("foobar")); test_scalar(TStringBuf(R"(foobar11)"), TStringBuf("foobar11")); test_scalar(TStringBuf(R"("foobar")"), TStringBuf("foobar")); @@ -206,7 +206,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("\x01\x0d" "foobar"sv); // negative length } - Y_UNIT_TEST(EmptyList) { + Y_UNIT_TEST(EmptyList) { auto reader = memory_reader("[]", NYsonPull::EStreamType::Node); UNIT_ASSERT_VALUES_EQUAL(NYsonPull::EEventType::BeginStream, reader.NextEvent().Type()); @@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("]"); } - Y_UNIT_TEST(EmptyMap) { + Y_UNIT_TEST(EmptyMap) { auto reader = memory_reader("{}", NYsonPull::EStreamType::Node); UNIT_ASSERT_VALUES_EQUAL(NYsonPull::EEventType::BeginStream, reader.NextEvent().Type()); @@ -230,7 +230,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("}"); } - Y_UNIT_TEST(Sample) { + Y_UNIT_TEST(Sample) { auto reader = memory_reader( R"({"11"=11;"nothing"=#;"zero"=0.;"foo"="bar";"list"=[1;2;3]})", NYsonPull::EStreamType::Node); @@ -309,7 +309,7 @@ Y_UNIT_TEST_SUITE(Reader) { UNIT_ASSERT_VALUES_EQUAL(NYsonPull::EEventType::EndStream, reader.NextEvent().Type()); } - Y_UNIT_TEST(Accept) { + Y_UNIT_TEST(Accept) { ACCEPT("[]"); ACCEPT("{}"); ACCEPT("<>[]"); @@ -330,7 +330,7 @@ Y_UNIT_TEST_SUITE(Reader) { ACCEPT("{foo=<foo=foo>[foo;foo]}"); } - Y_UNIT_TEST(Reject) { + Y_UNIT_TEST(Reject) { REJECT("["); REJECT("{"); REJECT("<"); @@ -352,7 +352,7 @@ Y_UNIT_TEST_SUITE(Reader) { REJECT("@"); } - Y_UNIT_TEST(ReadPastEnd) { + Y_UNIT_TEST(ReadPastEnd) { auto reader = memory_reader("#", NYsonPull::EStreamType::Node); UNIT_ASSERT_VALUES_EQUAL(NYsonPull::EEventType::BeginStream, reader.NextEvent().Type()); UNIT_ASSERT_VALUES_EQUAL(NYsonPull::EEventType::Scalar, reader.NextEvent().Type()); @@ -369,7 +369,7 @@ Y_UNIT_TEST_SUITE(Reader) { UNIT_ASSERT_EXCEPTION(reader.NextEvent(), NYsonPull::NException::TBadInput); } - Y_UNIT_TEST(StreamType) { + Y_UNIT_TEST(StreamType) { REJECT2("", NYsonPull::EStreamType::Node); ACCEPT2("", NYsonPull::EStreamType::ListFragment); ACCEPT2("", NYsonPull::EStreamType::MapFragment); @@ -407,4 +407,4 @@ Y_UNIT_TEST_SUITE(Reader) { ACCEPT2("a=[1]; b=foobar", NYsonPull::EStreamType::MapFragment); } -} // Y_UNIT_TEST_SUITE(Reader) +} // Y_UNIT_TEST_SUITE(Reader) diff --git a/library/cpp/yson_pull/ut/writer_ut.cpp b/library/cpp/yson_pull/ut/writer_ut.cpp index 79e19930df..5c304bad0f 100644 --- a/library/cpp/yson_pull/ut/writer_ut.cpp +++ b/library/cpp/yson_pull/ut/writer_ut.cpp @@ -44,14 +44,14 @@ namespace { // =================== Text format ===================== -Y_UNIT_TEST_SUITE(Writer) { - Y_UNIT_TEST(TextEntity) { +Y_UNIT_TEST_SUITE(Writer) { + Y_UNIT_TEST(TextEntity) { UNIT_ASSERT_VALUES_EQUAL( "#", to_yson_text_string(NYsonPull::TScalar{})); } - Y_UNIT_TEST(TextBoolean) { + Y_UNIT_TEST(TextBoolean) { UNIT_ASSERT_VALUES_EQUAL( "%false", to_yson_text_string(NYsonPull::TScalar{false})); @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_text_string(NYsonPull::TScalar{true})); } - Y_UNIT_TEST(TextInt64) { + Y_UNIT_TEST(TextInt64) { UNIT_ASSERT_VALUES_EQUAL( "0", to_yson_text_string(NYsonPull::TScalar{i64{0}})); @@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_text_string(NYsonPull::TScalar{i64{INT64_MIN}})); } - Y_UNIT_TEST(TextUInt64) { + Y_UNIT_TEST(TextUInt64) { UNIT_ASSERT_VALUES_EQUAL( "0u", to_yson_text_string(NYsonPull::TScalar{ui64{0}})); @@ -121,7 +121,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_text_string(NYsonPull::TScalar{ui64{UINT64_MAX}})); } - Y_UNIT_TEST(TextFloat64) { + Y_UNIT_TEST(TextFloat64) { UNIT_ASSERT_VALUES_EQUAL( "%inf", to_yson_text_string(NYsonPull::TScalar{std::numeric_limits<double>::infinity()})); @@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_text_string(NYsonPull::TScalar{std::numeric_limits<double>::quiet_NaN()})); } - Y_UNIT_TEST(TextString) { + Y_UNIT_TEST(TextString) { UNIT_ASSERT_VALUES_EQUAL( R"("")", to_yson_text_string(NYsonPull::TScalar{""})); @@ -147,13 +147,13 @@ Y_UNIT_TEST_SUITE(Writer) { // =================== Binary format ===================== - Y_UNIT_TEST(BinaryEntity) { + Y_UNIT_TEST(BinaryEntity) { UNIT_ASSERT_VALUES_EQUAL( "#", to_yson_binary_string(NYsonPull::TScalar{})); } - Y_UNIT_TEST(BinaryBoolean) { + Y_UNIT_TEST(BinaryBoolean) { UNIT_ASSERT_VALUES_EQUAL( TStringBuf("\x4"), to_yson_binary_string(NYsonPull::TScalar{false})); @@ -162,7 +162,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_binary_string(NYsonPull::TScalar{true})); } - Y_UNIT_TEST(BinaryInt64) { + Y_UNIT_TEST(BinaryInt64) { UNIT_ASSERT_VALUES_EQUAL( TStringBuf("\x2\0"sv), to_yson_binary_string(NYsonPull::TScalar{i64{0}})); @@ -199,7 +199,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_binary_string(NYsonPull::TScalar{i64{INT64_MIN}})); } - Y_UNIT_TEST(BinaryUInt64) { + Y_UNIT_TEST(BinaryUInt64) { UNIT_ASSERT_VALUES_EQUAL( TStringBuf("\x6\0"sv), to_yson_binary_string(NYsonPull::TScalar{ui64{0}})); @@ -223,7 +223,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_binary_string(NYsonPull::TScalar{ui64{UINT64_MAX}})); } - Y_UNIT_TEST(BinaryFloat64) { + Y_UNIT_TEST(BinaryFloat64) { UNIT_ASSERT_VALUES_EQUAL( TStringBuf("\x03\x00\x00\x00\x00\x00\x00\xf0\x7f"sv), to_yson_binary_string(NYsonPull::TScalar{std::numeric_limits<double>::infinity()})); @@ -241,7 +241,7 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_binary_string(NYsonPull::TScalar{double{-1.1}})); } - Y_UNIT_TEST(BinaryString) { + Y_UNIT_TEST(BinaryString) { UNIT_ASSERT_VALUES_EQUAL( TStringBuf("\x1\0"sv), to_yson_binary_string(NYsonPull::TScalar{""})); @@ -253,4 +253,4 @@ Y_UNIT_TEST_SUITE(Writer) { to_yson_binary_string(NYsonPull::TScalar{"hello\nworld"})); } -} // Y_UNIT_TEST_SUITE(Writer) +} // Y_UNIT_TEST_SUITE(Writer) |