diff options
author | gotmanov <gotmanov@yandex-team.ru> | 2022-02-10 16:49:26 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:26 +0300 |
commit | 243edeedfd2c5152b5c7812e0af471e1bb0232e8 (patch) | |
tree | 7efbef4b4e045bcee8833f7fc22a639fa0ff06aa | |
parent | 56c39b3cf908e7202b1f7551a1653681e8015607 (diff) | |
download | ydb-243edeedfd2c5152b5c7812e0af471e1bb0232e8.tar.gz |
Restoring authorship annotation for <gotmanov@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | library/cpp/codecs/float_huffman.h | 2 | ||||
-rw-r--r-- | library/cpp/codecs/ut/float_huffman_ut.cpp | 38 | ||||
-rw-r--r-- | library/cpp/enumbitset/enumbitset.h | 88 | ||||
-rw-r--r-- | library/cpp/json/writer/ya.make | 4 | ||||
-rw-r--r-- | library/cpp/protobuf/util/is_equal.cpp | 6 | ||||
-rw-r--r-- | library/cpp/protobuf/util/is_equal.h | 6 | ||||
-rw-r--r-- | library/cpp/protobuf/util/is_equal_ut.cpp | 84 | ||||
-rw-r--r-- | library/cpp/protobuf/util/traits.h | 14 | ||||
-rw-r--r-- | library/cpp/timezone_conversion/civil-inl.h | 122 | ||||
-rw-r--r-- | library/cpp/timezone_conversion/civil.cpp | 102 | ||||
-rw-r--r-- | library/cpp/timezone_conversion/civil.h | 132 | ||||
-rw-r--r-- | library/cpp/timezone_conversion/ut/civil_ut.cpp | 86 | ||||
-rw-r--r-- | library/cpp/timezone_conversion/ya.make | 4 | ||||
-rw-r--r-- | tools/ya.make | 6 | ||||
-rw-r--r-- | util/generic/flags.h | 16 | ||||
-rw-r--r-- | util/generic/flags_ut.cpp | 4 | ||||
-rw-r--r-- | util/generic/map_ut.cpp | 26 | ||||
-rw-r--r-- | util/generic/typelist.cpp | 6 | ||||
-rw-r--r-- | util/memory/pool.h | 6 | ||||
-rw-r--r-- | util/memory/pool_ut.cpp | 82 | ||||
-rw-r--r-- | util/stream/input.cpp | 2 | ||||
-rw-r--r-- | util/stream/input_ut.cpp | 76 |
22 files changed, 456 insertions, 456 deletions
diff --git a/library/cpp/codecs/float_huffman.h b/library/cpp/codecs/float_huffman.h index 786a8eae1d..e94a778115 100644 --- a/library/cpp/codecs/float_huffman.h +++ b/library/cpp/codecs/float_huffman.h @@ -47,4 +47,4 @@ namespace NCodecs::NFloatHuff { }; TVector<float> Decode(TStringBuf data, size_t sizeHint = 0); -} +} diff --git a/library/cpp/codecs/ut/float_huffman_ut.cpp b/library/cpp/codecs/ut/float_huffman_ut.cpp index 3156fb1f46..55e578ca03 100644 --- a/library/cpp/codecs/ut/float_huffman_ut.cpp +++ b/library/cpp/codecs/ut/float_huffman_ut.cpp @@ -136,11 +136,11 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { 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) { - void* data = static_cast<void*>(factors); - memset(data, 0xAA, sizeof(float) * count); - } - + void FillWithGarbage(float* factors, size_t count) { + void* data = static_cast<void*>(factors); + memset(data, 0xAA, sizeof(float) * count); + } + // Helper for dumping compressed values void PrintCompressed(const TVector<ui8>& codedFactors) { for (size_t i = 0; i < codedFactors.size(); ++i) { @@ -184,7 +184,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { Y_UNIT_TEST(TestDecompressInParts) { float factors[FactorCount]; - FillWithGarbage(factors, FactorCount); + FillWithGarbage(factors, FactorCount); fh::TDecoder decoder(CodedFactorsBuf); const size_t firstPack = 100; // unpack first pack @@ -198,26 +198,26 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { } Y_UNIT_TEST(TestSkip) { - float factors[FactorCount]; - FillWithGarbage(factors, FactorCount); + float factors[FactorCount]; + FillWithGarbage(factors, FactorCount); fh::TDecoder decoder(CodedFactorsBuf); - const size_t firstPack = 100; - // unpack first pack + const size_t firstPack = 100; + // unpack first pack UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors, firstPack}), firstPack); - // skip some factors - const size_t skipCount = 60; + // skip some factors + const size_t skipCount = 60; UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2); - // unpack all, except some factors in the end + // unpack all, except some factors in the end const auto toDecode = FactorCount - firstPack - skipCount; UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors + firstPack, toDecode}), toDecode); UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2); for (size_t i = 0; i < FactorCount - skipCount; ++i) { - size_t correctedI = i < firstPack ? i : i + skipCount / 2; - UNIT_ASSERT_VALUES_EQUAL(factors[i], Factors[correctedI]); - } - //PrintDecompressed(factors); - } - + size_t correctedI = i < firstPack ? i : i + skipCount / 2; + UNIT_ASSERT_VALUES_EQUAL(factors[i], Factors[correctedI]); + } + //PrintDecompressed(factors); + } + Y_UNIT_TEST(TestDecompressForgedData) { // this coredumps without end-of-coded-stream check, see SEARCH-1156 for details TString brokenBase64Encoded = diff --git a/library/cpp/enumbitset/enumbitset.h b/library/cpp/enumbitset/enumbitset.h index 41864c3a04..178dd497ce 100644 --- a/library/cpp/enumbitset/enumbitset.h +++ b/library/cpp/enumbitset/enumbitset.h @@ -11,12 +11,12 @@ // Stack memory bitmask for TEnum values [begin, end). // @end value is not included in the mask and is not necessarily defined as enum value. // For example: enum EType { A, B, C } ==> TEnumBitSet<EType, A, C + 1> -template <typename TEnum, int mbegin, int mend> +template <typename TEnum, int mbegin, int mend> class TEnumBitSet: private TBitMap<mend - mbegin> { public: - static const int BeginIndex = mbegin; - static const int EndIndex = mend; - static const size_t BitsetSize = EndIndex - BeginIndex; + static const int BeginIndex = mbegin; + static const int EndIndex = mend; + static const size_t BitsetSize = EndIndex - BeginIndex; typedef TBitMap<BitsetSize> TParent; typedef TEnumBitSet<TEnum, mbegin, mend> TThis; @@ -57,7 +57,7 @@ public: } static bool IsValid(TEnum c) { - return int(c) >= BeginIndex && int(c) < EndIndex; + return int(c) >= BeginIndex && int(c) < EndIndex; } bool Test(TEnum c) const { @@ -260,7 +260,7 @@ public: //serialization to/from stream void Save(IOutputStream* buffer) const { ::Save(buffer, (ui32)Count()); - for (TEnum bit : *this) { + for (TEnum bit : *this) { ::Save(buffer, (ui32)bit); } } @@ -271,7 +271,7 @@ public: ui32 sz = 0; ::Load(buffer, sz); - for (ui32 t = 0; t < sz; t++) { + for (ui32 t = 0; t < sz; t++) { ui32 bit = 0; ::Load(buffer, bit); @@ -350,18 +350,18 @@ public: class TIterator { public: - TIterator(TEnum value, const TThis* bitmap) noexcept - : Value(static_cast<int>(value)) - , BitMap(bitmap) - { - } - - TIterator(const TThis* bitmap) noexcept - : Value(EndIndex) + TIterator(TEnum value, const TThis* bitmap) noexcept + : Value(static_cast<int>(value)) , BitMap(bitmap) { } + TIterator(const TThis* bitmap) noexcept + : Value(EndIndex) + , BitMap(bitmap) + { + } + TEnum operator*() const noexcept { Y_ASSERT(Value < EndIndex); return static_cast<TEnum>(Value); @@ -373,12 +373,12 @@ public: TIterator& operator++() noexcept { Y_ASSERT(Value < EndIndex); - TEnum res; - if (BitMap->FindNext(static_cast<TEnum>(Value), res)) { - Value = static_cast<int>(res); - } else { - Value = EndIndex; - } + TEnum res; + if (BitMap->FindNext(static_cast<TEnum>(Value), res)) { + Value = static_cast<int>(res); + } else { + Value = EndIndex; + } return *this; } @@ -389,12 +389,12 @@ public: }; TIterator begin() const { - TEnum res; - return FindFirst(res) ? TIterator(res, this) : TIterator(this); + TEnum res; + return FindFirst(res) ? TIterator(res, this) : TIterator(this); } TIterator end() const { - return TIterator(this); + return TIterator(this); } private: @@ -410,26 +410,26 @@ private: bool HasAll(TEnum c) const { return Test(c); } - - bool FindFirst(TEnum& result) const { - // finds first set item in bitset (or End if bitset is empty) - const int index = int(this->FirstNonZeroBit()) + BeginIndex; - if (index < EndIndex) { - result = static_cast<TEnum>(index); - return true; - } - return false; - } - - bool FindNext(TEnum current, TEnum& result) const { - // finds first set item in bitset (or End if bitset is empty) - const int index = int(this->NextNonZeroBit(int(current) - BeginIndex)) + BeginIndex; - if (index < EndIndex) { - result = static_cast<TEnum>(index); - return true; - } - return false; - } + + bool FindFirst(TEnum& result) const { + // finds first set item in bitset (or End if bitset is empty) + const int index = int(this->FirstNonZeroBit()) + BeginIndex; + if (index < EndIndex) { + result = static_cast<TEnum>(index); + return true; + } + return false; + } + + bool FindNext(TEnum current, TEnum& result) const { + // finds first set item in bitset (or End if bitset is empty) + const int index = int(this->NextNonZeroBit(int(current) - BeginIndex)) + BeginIndex; + if (index < EndIndex) { + result = static_cast<TEnum>(index); + return true; + } + return false; + } }; template <typename TEnum, TEnum mbegin, int mend> diff --git a/library/cpp/json/writer/ya.make b/library/cpp/json/writer/ya.make index 3989ff3504..5bbef2d3f5 100644 --- a/library/cpp/json/writer/ya.make +++ b/library/cpp/json/writer/ya.make @@ -15,6 +15,6 @@ SRCS( json.cpp ) -GENERATE_ENUM_SERIALIZATION(json_value.h) - +GENERATE_ENUM_SERIALIZATION(json_value.h) + END() diff --git a/library/cpp/protobuf/util/is_equal.cpp b/library/cpp/protobuf/util/is_equal.cpp index 227408006e..0cc14774e3 100644 --- a/library/cpp/protobuf/util/is_equal.cpp +++ b/library/cpp/protobuf/util/is_equal.cpp @@ -158,6 +158,6 @@ namespace NProtoBuf { bool IsEqualFieldDefault(const Message& m1, const Message& m2, const FieldDescriptor& field) { return IsEqualFieldImpl<true>(m1, m2, field, nullptr); - } - -} + } + +} diff --git a/library/cpp/protobuf/util/is_equal.h b/library/cpp/protobuf/util/is_equal.h index 13c0aae63d..97de691767 100644 --- a/library/cpp/protobuf/util/is_equal.h +++ b/library/cpp/protobuf/util/is_equal.h @@ -5,13 +5,13 @@ namespace google { namespace protobuf { class Message; - class FieldDescriptor; + class FieldDescriptor; } } namespace NProtoBuf { using ::google::protobuf::FieldDescriptor; - using ::google::protobuf::Message; + using ::google::protobuf::Message; } namespace NProtoBuf { @@ -27,7 +27,7 @@ namespace NProtoBuf { // Non-strict version: optional field without explicit value is compared // using its default value. bool IsEqualDefault(const Message& m1, const Message& m2); - + bool IsEqualFieldDefault(const Message& m1, const Message& m2, const FieldDescriptor& field); } diff --git a/library/cpp/protobuf/util/is_equal_ut.cpp b/library/cpp/protobuf/util/is_equal_ut.cpp index 3ca4c90dd5..c370b26e8d 100644 --- a/library/cpp/protobuf/util/is_equal_ut.cpp +++ b/library/cpp/protobuf/util/is_equal_ut.cpp @@ -4,19 +4,19 @@ #include <library/cpp/testing/unittest/registar.h> #include <google/protobuf/descriptor.h> - + 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); - + 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) { - UNIT_ASSERT(Descr); - UNIT_ASSERT(NameDescr); - UNIT_ASSERT_VALUES_EQUAL(NameDescr->name(), "Name"); - UNIT_ASSERT_VALUES_EQUAL(InnerDescr->name(), "Inner"); - } - + UNIT_ASSERT(Descr); + UNIT_ASSERT(NameDescr); + UNIT_ASSERT_VALUES_EQUAL(NameDescr->name(), "Name"); + UNIT_ASSERT_VALUES_EQUAL(InnerDescr->name(), "Inner"); + } + Y_UNIT_TEST(IsEqual1) { TSampleForIsEqual a; TSampleForIsEqual b; @@ -29,8 +29,8 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { bool equal = NProtoBuf::IsEqual(a, b, &path); UNIT_ASSERT(!equal); UNIT_ASSERT_VALUES_EQUAL("Name", path); - - UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); + + UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); } Y_UNIT_TEST(IsEqual2) { @@ -45,35 +45,35 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { bool equal = NProtoBuf::IsEqual(a, b, &path); UNIT_ASSERT(!equal); UNIT_ASSERT_VALUES_EQUAL("Inner/Brbrbr", path); - - bool equalField = NProtoBuf::IsEqualField(a, b, *InnerDescr); - UNIT_ASSERT(!equalField); + + bool equalField = NProtoBuf::IsEqualField(a, b, *InnerDescr); + UNIT_ASSERT(!equalField); } Y_UNIT_TEST(IsEqual3) { - TSampleForIsEqual a; - TSampleForIsEqual b; - - a.SetName("aaa"); - a.MutableInner()->SetBrbrbr("bbb"); - - b.SetName("aaa"); - b.MutableInner()->SetBrbrbr("bbb"); - - TString path; - - UNIT_ASSERT(NProtoBuf::IsEqual(a, b)); - UNIT_ASSERT(NProtoBuf::IsEqualField(a, b, *NameDescr)); - UNIT_ASSERT(NProtoBuf::IsEqualField(a, b, *InnerDescr)); - - b.MutableInner()->SetBrbrbr("ccc"); - UNIT_ASSERT(!NProtoBuf::IsEqual(a, b)); - UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *InnerDescr)); - - b.SetName("ccc"); - UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); - } - + TSampleForIsEqual a; + TSampleForIsEqual b; + + a.SetName("aaa"); + a.MutableInner()->SetBrbrbr("bbb"); + + b.SetName("aaa"); + b.MutableInner()->SetBrbrbr("bbb"); + + TString path; + + UNIT_ASSERT(NProtoBuf::IsEqual(a, b)); + UNIT_ASSERT(NProtoBuf::IsEqualField(a, b, *NameDescr)); + UNIT_ASSERT(NProtoBuf::IsEqualField(a, b, *InnerDescr)); + + b.MutableInner()->SetBrbrbr("ccc"); + UNIT_ASSERT(!NProtoBuf::IsEqual(a, b)); + UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *InnerDescr)); + + b.SetName("ccc"); + UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); + } + Y_UNIT_TEST(IsEqualDefault) { TSampleForIsEqual a; TSampleForIsEqual b; @@ -81,8 +81,8 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { a.SetName(""); UNIT_ASSERT(NProtoBuf::IsEqualDefault(a, b)); UNIT_ASSERT(!NProtoBuf::IsEqual(a, b)); - - UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); - UNIT_ASSERT(NProtoBuf::IsEqualFieldDefault(a, b, *NameDescr)); + + UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); + UNIT_ASSERT(NProtoBuf::IsEqualFieldDefault(a, b, *NameDescr)); } } diff --git a/library/cpp/protobuf/util/traits.h b/library/cpp/protobuf/util/traits.h index 50f036d0ea..e2d75e4a90 100644 --- a/library/cpp/protobuf/util/traits.h +++ b/library/cpp/protobuf/util/traits.h @@ -44,8 +44,8 @@ namespace NProtoBuf { Y_ASSERT(fd); \ return fd->default_value_##method(); \ } \ - }; - + }; + DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_INT32, int32); DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_INT64, int64); DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_UINT32, uint32); @@ -55,9 +55,9 @@ namespace NProtoBuf { DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_BOOL, bool); DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_ENUM, enum); DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_STRING, string); - -#undef DECLARE_CPPTYPE_DEFAULT - + +#undef DECLARE_CPPTYPE_DEFAULT + // getters/setters of field with specified CppType template <FieldDescriptor::CppType cpptype> struct TCppTypeTraits : TCppTypeTraitsBase { @@ -190,7 +190,7 @@ namespace NProtoBuf { Y_ASSERT(index == 0); TBaseTraits::Set(msg, field, value); } - + static inline void Add(Message& msg, const FieldDescriptor* field, T value) { TBaseTraits::Set(msg, field, value); } @@ -220,7 +220,7 @@ namespace NProtoBuf { static inline void Set(Message& msg, const FieldDescriptor* field, T value, size_t index = 0) { TBaseTraits::SetRepeated(msg, field, index, value); } - + static inline void Add(Message& msg, const FieldDescriptor* field, T value) { TBaseTraits::AddRepeated(msg, field, value); } diff --git a/library/cpp/timezone_conversion/civil-inl.h b/library/cpp/timezone_conversion/civil-inl.h index 32afbccb64..5181c97b7d 100644 --- a/library/cpp/timezone_conversion/civil-inl.h +++ b/library/cpp/timezone_conversion/civil-inl.h @@ -1,63 +1,63 @@ -#pragma once - -#include "civil.h" - -namespace NDatetime { - namespace NDetail { - template <typename T> - struct TGetCivilUnit; - - template <> - struct TGetCivilUnit<TCivilSecond> { - static constexpr ECivilUnit Value = ECivilUnit::Second; - }; - template <> - struct TGetCivilUnit<TCivilMinute> { - static constexpr ECivilUnit Value = ECivilUnit::Minute; - }; - template <> - struct TGetCivilUnit<TCivilHour> { - static constexpr ECivilUnit Value = ECivilUnit::Hour; - }; - template <> - struct TGetCivilUnit<TCivilDay> { - static constexpr ECivilUnit Value = ECivilUnit::Day; - }; - template <> - struct TGetCivilUnit<TCivilMonth> { - static constexpr ECivilUnit Value = ECivilUnit::Month; - }; - template <> - struct TGetCivilUnit<TCivilYear> { - static constexpr ECivilUnit Value = ECivilUnit::Year; - }; - - template <ECivilUnit Unit> - struct TGetCivilTime; - - template <> - struct TGetCivilTime<ECivilUnit::Second> { - using TResult = TCivilSecond; - }; - template <> - struct TGetCivilTime<ECivilUnit::Minute> { - using TResult = TCivilMinute; - }; - template <> - struct TGetCivilTime<ECivilUnit::Hour> { - using TResult = TCivilHour; - }; - template <> - struct TGetCivilTime<ECivilUnit::Day> { - using TResult = TCivilDay; - }; - template <> - struct TGetCivilTime<ECivilUnit::Month> { - using TResult = TCivilMonth; - }; - template <> - struct TGetCivilTime<ECivilUnit::Year> { - using TResult = TCivilYear; - }; +#pragma once + +#include "civil.h" + +namespace NDatetime { + namespace NDetail { + template <typename T> + struct TGetCivilUnit; + + template <> + struct TGetCivilUnit<TCivilSecond> { + static constexpr ECivilUnit Value = ECivilUnit::Second; + }; + template <> + struct TGetCivilUnit<TCivilMinute> { + static constexpr ECivilUnit Value = ECivilUnit::Minute; + }; + template <> + struct TGetCivilUnit<TCivilHour> { + static constexpr ECivilUnit Value = ECivilUnit::Hour; + }; + template <> + struct TGetCivilUnit<TCivilDay> { + static constexpr ECivilUnit Value = ECivilUnit::Day; + }; + template <> + struct TGetCivilUnit<TCivilMonth> { + static constexpr ECivilUnit Value = ECivilUnit::Month; + }; + template <> + struct TGetCivilUnit<TCivilYear> { + static constexpr ECivilUnit Value = ECivilUnit::Year; + }; + + template <ECivilUnit Unit> + struct TGetCivilTime; + + template <> + struct TGetCivilTime<ECivilUnit::Second> { + using TResult = TCivilSecond; + }; + template <> + struct TGetCivilTime<ECivilUnit::Minute> { + using TResult = TCivilMinute; + }; + template <> + struct TGetCivilTime<ECivilUnit::Hour> { + using TResult = TCivilHour; + }; + template <> + struct TGetCivilTime<ECivilUnit::Day> { + using TResult = TCivilDay; + }; + template <> + struct TGetCivilTime<ECivilUnit::Month> { + using TResult = TCivilMonth; + }; + template <> + struct TGetCivilTime<ECivilUnit::Year> { + using TResult = TCivilYear; + }; } } diff --git a/library/cpp/timezone_conversion/civil.cpp b/library/cpp/timezone_conversion/civil.cpp index 5986318b9a..c712f88748 100644 --- a/library/cpp/timezone_conversion/civil.cpp +++ b/library/cpp/timezone_conversion/civil.cpp @@ -122,57 +122,57 @@ namespace NDatetime { return Calc<TCivilSecond>(tp, diff); } - TCivilSecond AddCivil(const TCivilSecond& tp, TCivilDiff diff) { - switch (diff.Unit) { - case ECivilUnit::Second: { - return AddSeconds(tp, diff.Value); - } - case ECivilUnit::Minute: { - return AddMinutes(tp, diff.Value); - } - case ECivilUnit::Hour: { - return AddHours(tp, diff.Value); - } - case ECivilUnit::Day: { - return AddDays(tp, diff.Value); - } - case ECivilUnit::Month: { - return AddMonths(tp, diff.Value); - } - case ECivilUnit::Year: { - return AddYears(tp, diff.Value); - } - default: { - ythrow yexception() << "Unexpected civil unit value " << static_cast<int>(diff.Unit); - } - } - } - - TCivilDiff GetCivilDiff(const TCivilSecond& tpX, const TCivilSecond& tpY, ECivilUnit unit) { - switch (unit) { - case ECivilUnit::Second: { - return {tpX - tpY, unit}; - } - case ECivilUnit::Minute: { - return {static_cast<TCivilMinute>(tpX) - static_cast<TCivilMinute>(tpY), unit}; - } - case ECivilUnit::Hour: { - return {static_cast<TCivilHour>(tpX) - static_cast<TCivilHour>(tpY), unit}; - } - case ECivilUnit::Day: { - return {static_cast<TCivilDay>(tpX) - static_cast<TCivilDay>(tpY), unit}; - } - case ECivilUnit::Month: { - return {static_cast<TCivilMonth>(tpX) - static_cast<TCivilMonth>(tpY), unit}; - } - case ECivilUnit::Year: { - return {static_cast<TCivilYear>(tpX) - static_cast<TCivilYear>(tpY), unit}; - } - default: { - ythrow yexception() << "Unexpected civil unit value " << static_cast<int>(unit); - } - } - } + TCivilSecond AddCivil(const TCivilSecond& tp, TCivilDiff diff) { + switch (diff.Unit) { + case ECivilUnit::Second: { + return AddSeconds(tp, diff.Value); + } + case ECivilUnit::Minute: { + return AddMinutes(tp, diff.Value); + } + case ECivilUnit::Hour: { + return AddHours(tp, diff.Value); + } + case ECivilUnit::Day: { + return AddDays(tp, diff.Value); + } + case ECivilUnit::Month: { + return AddMonths(tp, diff.Value); + } + case ECivilUnit::Year: { + return AddYears(tp, diff.Value); + } + default: { + ythrow yexception() << "Unexpected civil unit value " << static_cast<int>(diff.Unit); + } + } + } + + TCivilDiff GetCivilDiff(const TCivilSecond& tpX, const TCivilSecond& tpY, ECivilUnit unit) { + switch (unit) { + case ECivilUnit::Second: { + return {tpX - tpY, unit}; + } + case ECivilUnit::Minute: { + return {static_cast<TCivilMinute>(tpX) - static_cast<TCivilMinute>(tpY), unit}; + } + case ECivilUnit::Hour: { + return {static_cast<TCivilHour>(tpX) - static_cast<TCivilHour>(tpY), unit}; + } + case ECivilUnit::Day: { + return {static_cast<TCivilDay>(tpX) - static_cast<TCivilDay>(tpY), unit}; + } + case ECivilUnit::Month: { + return {static_cast<TCivilMonth>(tpX) - static_cast<TCivilMonth>(tpY), unit}; + } + case ECivilUnit::Year: { + return {static_cast<TCivilYear>(tpX) - static_cast<TCivilYear>(tpY), unit}; + } + default: { + ythrow yexception() << "Unexpected civil unit value " << static_cast<int>(unit); + } + } + } } template <> diff --git a/library/cpp/timezone_conversion/civil.h b/library/cpp/timezone_conversion/civil.h index 0e95b807ed..51983e73b2 100644 --- a/library/cpp/timezone_conversion/civil.h +++ b/library/cpp/timezone_conversion/civil.h @@ -43,53 +43,53 @@ namespace NDatetime { using TYear = cctz::year_t; using TMonth = cctz::detail::month_t; - enum class ECivilUnit : int { - Second = 0, - Minute = 1, - Hour = 2, - Day = 3, - Month = 4, - Year = 5 - }; - - namespace NDetail { - template <typename T> - struct TGetCivilUnit; - - template <ECivilUnit Unit> - struct TGetCivilTime; - } - - template <typename T> - CONSTEXPR_M ECivilUnit GetCivilUnit(const T& = {}) { - return NDetail::TGetCivilUnit<T>::Value; + enum class ECivilUnit : int { + Second = 0, + Minute = 1, + Hour = 2, + Day = 3, + Month = 4, + Year = 5 + }; + + namespace NDetail { + template <typename T> + struct TGetCivilUnit; + + template <ECivilUnit Unit> + struct TGetCivilTime; } - - template <ECivilUnit Unit> - using TCivilTime = typename NDetail::TGetCivilTime<Unit>::TResult; - - /** - * Class with variable unit diff. - */ - struct TCivilDiff { - TDiff Value = 0; - ECivilUnit Unit = ECivilUnit::Second; - - TCivilDiff() = default; - TCivilDiff(TDiff value, ECivilUnit unit) - : Value(value) - , Unit(unit) - { - } - - /** - * Straightfoward implementation of operators <, == and unit conversions - * can be potentially misleading (e.g. 1 month == 30 days?); - * we leave it to user to implement it properly for each application. - */ - }; - + + template <typename T> + CONSTEXPR_M ECivilUnit GetCivilUnit(const T& = {}) { + return NDetail::TGetCivilUnit<T>::Value; + } + + template <ECivilUnit Unit> + using TCivilTime = typename NDetail::TGetCivilTime<Unit>::TResult; + /** + * Class with variable unit diff. + */ + struct TCivilDiff { + TDiff Value = 0; + ECivilUnit Unit = ECivilUnit::Second; + + TCivilDiff() = default; + TCivilDiff(TDiff value, ECivilUnit unit) + : Value(value) + , Unit(unit) + { + } + + /** + * Straightfoward implementation of operators <, == and unit conversions + * can be potentially misleading (e.g. 1 month == 30 days?); + * we leave it to user to implement it properly for each application. + */ + }; + + /** * Gets the time zone by an IANA name. * @param name A name in IANA format (e.g., "Europe/Moscow"). * @note After you request a time zone for the first time, it is cached @@ -150,7 +150,7 @@ namespace NDatetime { * @return the calculated T type */ template <typename T, typename S> - inline T Calc(const S& tp, TDiff diff) { + inline T Calc(const S& tp, TDiff diff) { return T(tp) + diff; } @@ -166,24 +166,24 @@ namespace NDatetime { TCivilSecond AddMinutes(const TCivilSecond& tp, TDiff diff); TCivilSecond AddSeconds(const TCivilSecond& tp, TDiff diff); - /** Method to add TCivilDiff - * @param[in] tp is a timepoint with which calc will be - * @param[in] diff is quantity of which will be added to the tp - * @return the calculated TCivilSecond object - */ - TCivilSecond AddCivil(const TCivilSecond& tp, TCivilDiff diff); - - /** Method to subtract to civil dates/times and get TCivilDiff. - * First casts to unit, then subtracts; - * e.g. GetCivilDiff(2017-10-01, 2017-09-30, Month) = 1. - * - * @param[in] tpX is a timepoint - * @param[in] tpY is a timepoint to subtract from tpX - * @param[in] unit is a civil time unit to use in subtraction - * @return the calculated diff as TCivilDiff object - */ - TCivilDiff GetCivilDiff(const TCivilSecond& tpX, const TCivilSecond& tpY, ECivilUnit unit); - + /** Method to add TCivilDiff + * @param[in] tp is a timepoint with which calc will be + * @param[in] diff is quantity of which will be added to the tp + * @return the calculated TCivilSecond object + */ + TCivilSecond AddCivil(const TCivilSecond& tp, TCivilDiff diff); + + /** Method to subtract to civil dates/times and get TCivilDiff. + * First casts to unit, then subtracts; + * e.g. GetCivilDiff(2017-10-01, 2017-09-30, Month) = 1. + * + * @param[in] tpX is a timepoint + * @param[in] tpY is a timepoint to subtract from tpX + * @param[in] unit is a civil time unit to use in subtraction + * @return the calculated diff as TCivilDiff object + */ + TCivilDiff GetCivilDiff(const TCivilSecond& tpX, const TCivilSecond& tpY, ECivilUnit unit); + /** Formats the given TimePoint in the given TTimeZone according to * the provided format string. Uses strftime()-like formatting options, * with the following extensions: @@ -333,6 +333,6 @@ namespace NDatetime { } } -#include "civil-inl.h" - +#include "civil-inl.h" + #undef CONSTEXPR_M diff --git a/library/cpp/timezone_conversion/ut/civil_ut.cpp b/library/cpp/timezone_conversion/ut/civil_ut.cpp index a21bd4bd7d..a4e45879af 100644 --- a/library/cpp/timezone_conversion/ut/civil_ut.cpp +++ b/library/cpp/timezone_conversion/ut/civil_ut.cpp @@ -4,17 +4,17 @@ #include <util/stream/str.h> -namespace NDatetime { +namespace NDatetime { inline bool operator==(const NDatetime::TCivilDiff& x, const NDatetime::TCivilDiff& y) { - return x.Unit == y.Unit && x.Value == y.Value; - } -} - -template <> -inline void Out<NDatetime::TCivilDiff>(IOutputStream& out, const NDatetime::TCivilDiff& diff) { - out << "(" << diff.Value << "," << diff.Unit << ")"; + return x.Unit == y.Unit && x.Value == y.Value; + } } - + +template <> +inline void Out<NDatetime::TCivilDiff>(IOutputStream& out, const NDatetime::TCivilDiff& diff) { + out << "(" << diff.Value << "," << diff.Unit << ")"; +} + Y_UNIT_TEST_SUITE(DateTime) { Y_UNIT_TEST(Calc) { NDatetime::TCivilSecond s(2017, 2, 1, 10, 12, 9); @@ -83,40 +83,40 @@ Y_UNIT_TEST_SUITE(DateTime) { UNIT_ASSERT_VALUES_EQUAL(NDatetime::WeekdayOnTheWeek(d, NDatetime::TWeekday::friday), NDatetime::TCivilDay(2013, 1, 4)); } Y_UNIT_TEST(CivilUnit) { - using namespace NDatetime; - - UNIT_ASSERT_VALUES_EQUAL(GetCivilUnit<TCivilMonth>(), ECivilUnit::Month); - UNIT_ASSERT_VALUES_EQUAL(GetCivilUnit(TCivilHour{}), ECivilUnit::Hour); - - UNIT_ASSERT_VALUES_EQUAL(TCivilTime<ECivilUnit::Day>(2017, 1, 11), TCivilDay(2017, 1, 11)); - - NDatetime::TCivilSecond s(2017, 2, 1, 10, 12, 9); - - UNIT_ASSERT_VALUES_EQUAL( - NDatetime::AddCivil(s, TCivilDiff{2, ECivilUnit::Day}), - NDatetime::AddDays(s, 2)); - UNIT_ASSERT_VALUES_EQUAL( - NDatetime::AddCivil(s, TCivilDiff{-2, ECivilUnit::Month}), - NDatetime::AddMonths(s, -2)); - UNIT_ASSERT_VALUES_EQUAL( - NDatetime::AddCivil(s, TCivilDiff{-55, ECivilUnit::Year}), - NDatetime::AddYears(s, -55)); - UNIT_ASSERT_VALUES_EQUAL( - NDatetime::AddCivil(s, TCivilDiff{40, ECivilUnit::Hour}), - NDatetime::AddHours(s, 40)); - - UNIT_ASSERT_VALUES_EQUAL( - GetCivilDiff(TCivilSecond(2017, 10), TCivilSecond(2017, 7), ECivilUnit::Month), - TCivilDiff(3, ECivilUnit::Month)); - - UNIT_ASSERT_VALUES_EQUAL( - GetCivilDiff(TCivilSecond(2017, 10, 1), TCivilSecond(2017, 9, 30), ECivilUnit::Month), - TCivilDiff(1, ECivilUnit::Month)); - - UNIT_ASSERT_VALUES_EQUAL( - GetCivilDiff(TCivilSecond(2017, 10, 1), TCivilSecond(2017, 9, 31), ECivilUnit::Month), - TCivilDiff(0, ECivilUnit::Month)); - } + using namespace NDatetime; + + UNIT_ASSERT_VALUES_EQUAL(GetCivilUnit<TCivilMonth>(), ECivilUnit::Month); + UNIT_ASSERT_VALUES_EQUAL(GetCivilUnit(TCivilHour{}), ECivilUnit::Hour); + + UNIT_ASSERT_VALUES_EQUAL(TCivilTime<ECivilUnit::Day>(2017, 1, 11), TCivilDay(2017, 1, 11)); + + NDatetime::TCivilSecond s(2017, 2, 1, 10, 12, 9); + + UNIT_ASSERT_VALUES_EQUAL( + NDatetime::AddCivil(s, TCivilDiff{2, ECivilUnit::Day}), + NDatetime::AddDays(s, 2)); + UNIT_ASSERT_VALUES_EQUAL( + NDatetime::AddCivil(s, TCivilDiff{-2, ECivilUnit::Month}), + NDatetime::AddMonths(s, -2)); + UNIT_ASSERT_VALUES_EQUAL( + NDatetime::AddCivil(s, TCivilDiff{-55, ECivilUnit::Year}), + NDatetime::AddYears(s, -55)); + UNIT_ASSERT_VALUES_EQUAL( + NDatetime::AddCivil(s, TCivilDiff{40, ECivilUnit::Hour}), + NDatetime::AddHours(s, 40)); + + UNIT_ASSERT_VALUES_EQUAL( + GetCivilDiff(TCivilSecond(2017, 10), TCivilSecond(2017, 7), ECivilUnit::Month), + TCivilDiff(3, ECivilUnit::Month)); + + UNIT_ASSERT_VALUES_EQUAL( + GetCivilDiff(TCivilSecond(2017, 10, 1), TCivilSecond(2017, 9, 30), ECivilUnit::Month), + TCivilDiff(1, ECivilUnit::Month)); + + UNIT_ASSERT_VALUES_EQUAL( + GetCivilDiff(TCivilSecond(2017, 10, 1), TCivilSecond(2017, 9, 31), ECivilUnit::Month), + TCivilDiff(0, ECivilUnit::Month)); + } Y_UNIT_TEST(TestYearWeekNmb) { diff --git a/library/cpp/timezone_conversion/ya.make b/library/cpp/timezone_conversion/ya.make index f99ebe73ee..b0412c6932 100644 --- a/library/cpp/timezone_conversion/ya.make +++ b/library/cpp/timezone_conversion/ya.make @@ -15,8 +15,8 @@ SRCS( civil.cpp ) -GENERATE_ENUM_SERIALIZATION(civil.h) - +GENERATE_ENUM_SERIALIZATION(civil.h) + END() RECURSE_FOR_TESTS(ut) diff --git a/tools/ya.make b/tools/ya.make index 51a6b8b426..4ec3adf70a 100644 --- a/tools/ya.make +++ b/tools/ya.make @@ -30,10 +30,10 @@ RECURSE( doc_url_index_print dolbilo domschemec - domschemec/ut + domschemec/ut drawrichtree dsindexer - easyparser + easyparser enforce_fsync enum_parser event2cpp @@ -87,7 +87,7 @@ RECURSE( oauth_token pgmigrate pire - print_ranking_features + print_ranking_features printcorpus printdocstat printdom diff --git a/util/generic/flags.h b/util/generic/flags.h index a1f5921d42..ada083de7f 100644 --- a/util/generic/flags.h +++ b/util/generic/flags.h @@ -3,7 +3,7 @@ #include <type_traits> #include <util/system/types.h> -#include <util/generic/typetraits.h> +#include <util/generic/typetraits.h> #include <util/generic/fwd.h> class IOutputStream; @@ -203,13 +203,13 @@ private: TInt Value_; }; -template <class T> -struct TPodTraits<TFlags<T>> { - enum { - IsPod = TTypeTraits<T>::IsPod - }; -}; - +template <class T> +struct TPodTraits<TFlags<T>> { + enum { + IsPod = TTypeTraits<T>::IsPod + }; +}; + template <class Enum> struct THash<TFlags<Enum>> { size_t operator()(const TFlags<Enum>& flags) const noexcept { diff --git a/util/generic/flags_ut.cpp b/util/generic/flags_ut.cpp index 5377c6a058..75a06173bb 100644 --- a/util/generic/flags_ut.cpp +++ b/util/generic/flags_ut.cpp @@ -11,8 +11,8 @@ enum ETestFlag1: ui16 { Y_DECLARE_FLAGS(ETest1, ETestFlag1) Y_DECLARE_OPERATORS_FOR_FLAGS(ETest1) -static_assert(TTypeTraits<ETest1>::IsPod, "flags should be POD type"); - +static_assert(TTypeTraits<ETest1>::IsPod, "flags should be POD type"); + enum class ETestFlag2 { Test1 = 1, Test2 = 2, diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp index 79e832b024..64a2ad6d04 100644 --- a/util/generic/map_ut.cpp +++ b/util/generic/map_ut.cpp @@ -476,21 +476,21 @@ Y_UNIT_TEST_SUITE(TYMapTest) { expected.emplace("three", 3); UNIT_ASSERT_VALUES_EQUAL(mm, expected); } - + Y_UNIT_TEST(TestMovePoolAlloc) { using TMapInPool = TMap<int, int, TLess<int>, TPoolAllocator>; - - TMemoryPool pool(1); - - TMapInPool m(&pool); - m.emplace(0, 1); - + + TMemoryPool pool(1); + + TMapInPool m(&pool); + m.emplace(0, 1); + UNIT_ASSERT(m.contains(0)); - UNIT_ASSERT_VALUES_EQUAL(1, m[0]); - - TMapInPool movedM = std::move(m); - + UNIT_ASSERT_VALUES_EQUAL(1, m[0]); + + TMapInPool movedM = std::move(m); + UNIT_ASSERT(movedM.contains(0)); - UNIT_ASSERT_VALUES_EQUAL(1, movedM[0]); - } + UNIT_ASSERT_VALUES_EQUAL(1, movedM[0]); + } } diff --git a/util/generic/typelist.cpp b/util/generic/typelist.cpp index 275b565ddb..df347aafec 100644 --- a/util/generic/typelist.cpp +++ b/util/generic/typelist.cpp @@ -1,5 +1,5 @@ #include "typelist.h" -static_assert( - TSignedInts::THave<char>::value, - "char type in Arcadia must be signed; add -fsigned-char to compiler options"); +static_assert( + TSignedInts::THave<char>::value, + "char type in Arcadia must be signed; add -fsigned-char to compiler options"); diff --git a/util/memory/pool.h b/util/memory/pool.h index 13c8b6b9ed..2e4e8da840 100644 --- a/util/memory/pool.h +++ b/util/memory/pool.h @@ -388,9 +388,9 @@ public: return size_type(-1) / sizeof(T); } - template <typename... Args> - inline void construct(pointer p, Args&&... args) { - new (p) T(std::forward<Args>(args)...); + template <typename... Args> + inline void construct(pointer p, Args&&... args) { + new (p) T(std::forward<Args>(args)...); } inline void destroy(pointer p) noexcept { diff --git a/util/memory/pool_ut.cpp b/util/memory/pool_ut.cpp index 1158a8ca42..5c6aa59feb 100644 --- a/util/memory/pool_ut.cpp +++ b/util/memory/pool_ut.cpp @@ -50,39 +50,39 @@ private: size_t Frees_; }; -class TErrorOnCopy { -public: - TErrorOnCopy() = default; - TErrorOnCopy(TErrorOnCopy&&) = default; - - TErrorOnCopy(const TErrorOnCopy&) { - UNIT_ASSERT(false); - } -}; - -class TNoCopy { -public: - TNoCopy() = default; - TNoCopy(TNoCopy&&) = default; - - TNoCopy(const TNoCopy&) = delete; -}; - -class TNoMove { -public: - TNoMove() = default; - TNoMove(const TNoMove&) = default; - - TNoMove(TNoMove&&) = delete; -}; - +class TErrorOnCopy { +public: + TErrorOnCopy() = default; + TErrorOnCopy(TErrorOnCopy&&) = default; + + TErrorOnCopy(const TErrorOnCopy&) { + UNIT_ASSERT(false); + } +}; + +class TNoCopy { +public: + TNoCopy() = default; + TNoCopy(TNoCopy&&) = default; + + TNoCopy(const TNoCopy&) = delete; +}; + +class TNoMove { +public: + TNoMove() = default; + TNoMove(const TNoMove&) = default; + + TNoMove(TNoMove&&) = delete; +}; + class TMemPoolTest: public TTestBase { UNIT_TEST_SUITE(TMemPoolTest); UNIT_TEST(TestMemPool) UNIT_TEST(TestAlign) UNIT_TEST(TestZeroArray) UNIT_TEST(TestLargeStartingAlign) - UNIT_TEST(TestMoveAlloc) + UNIT_TEST(TestMoveAlloc) UNIT_TEST(TestRoundUpToNextPowerOfTwoOption) UNIT_TEST_SUITE_END(); @@ -223,22 +223,22 @@ private: UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned4k1) & 4095, 0); UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned4k2) & 4095, 0); } - - template <typename T> - void CheckMoveAlloc() { - TMemoryPool pool(10 * sizeof(T)); - + + template <typename T> + void CheckMoveAlloc() { + TMemoryPool pool(10 * sizeof(T)); + TVector<T, TPoolAllocator> elems(&pool); - elems.reserve(1); - elems.emplace_back(); - elems.resize(100); - } - - void TestMoveAlloc() { - CheckMoveAlloc<TNoMove>(); - CheckMoveAlloc<TNoCopy>(); - CheckMoveAlloc<TErrorOnCopy>(); + elems.reserve(1); + elems.emplace_back(); + elems.resize(100); } + + void TestMoveAlloc() { + CheckMoveAlloc<TNoMove>(); + CheckMoveAlloc<TNoCopy>(); + CheckMoveAlloc<TErrorOnCopy>(); + } void TestRoundUpToNextPowerOfTwoOption() { const size_t MEMORY_POOL_BLOCK_SIZE = (1024 - 16) * 4096 - 16 - 16 - 32; diff --git a/util/stream/input.cpp b/util/stream/input.cpp index 6e8170f2f9..7ef40c1510 100644 --- a/util/stream/input.cpp +++ b/util/stream/input.cpp @@ -209,7 +209,7 @@ namespace { st.AssignNoAlias(B_, r); - if (st && st.back() == ch) { + if (st && st.back() == ch) { st.pop_back(); } diff --git a/util/stream/input_ut.cpp b/util/stream/input_ut.cpp index 4a93f5458e..3e22e1f3b9 100644 --- a/util/stream/input_ut.cpp +++ b/util/stream/input_ut.cpp @@ -3,44 +3,44 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/system/file.h> +#include <util/system/file.h> #include <util/system/yassert.h> #ifdef _win_ #include <io.h> #endif -class TMockStdIn { -public: - TMockStdIn() +class TMockStdIn { +public: + TMockStdIn() : StdInCopy_(dup(0)) { } - ~TMockStdIn() { + ~TMockStdIn() { close(StdInCopy_); - } - - template <typename FuncType> + } + + template <typename FuncType> void ForInput(const TStringBuf text, const FuncType& func) { - TFile tempFile(TFile::Temporary("input_ut")); + TFile tempFile(TFile::Temporary("input_ut")); tempFile.Write(text.data(), text.size()); - tempFile.FlushData(); - tempFile.Seek(0, sSet); - - TFileHandle tempFh(tempFile.GetHandle()); + tempFile.FlushData(); + tempFile.Seek(0, sSet); + + TFileHandle tempFh(tempFile.GetHandle()); tempFh.Duplicate2Posix(0); - tempFh.Release(); - - func(); - Cin.ReadAll(); + tempFh.Release(); + + func(); + Cin.ReadAll(); dup2(StdInCopy_, 0); clearerr(stdin); - } + } -private: +private: int StdInCopy_; -}; - +}; + class TNoInput: public IInputStream { public: TNoInput(ui64 size) @@ -130,28 +130,28 @@ Y_UNIT_TEST_SUITE(TInputTest) { UNIT_ASSERT_VALUES_EQUAL(in.ReadLine(t), 0); UNIT_ASSERT_VALUES_EQUAL(t, "333"); } - + Y_UNIT_TEST(TestStdInReadTo) { - std::pair<std::pair<TStringBuf, char>, TStringBuf> testPairs[] = { - {{"", '\n'}, ""}, - {{"\n", '\n'}, ""}, - {{"\n\t", '\t'}, "\n"}, - {{"\t\n", '\n'}, "\t"}, + std::pair<std::pair<TStringBuf, char>, TStringBuf> testPairs[] = { + {{"", '\n'}, ""}, + {{"\n", '\n'}, ""}, + {{"\n\t", '\t'}, "\n"}, + {{"\t\n", '\n'}, "\t"}, {{"a\tb\n", '\t'}, "a"}}; - - TMockStdIn stdIn; - - for (const auto& testPair : testPairs) { - const TStringBuf text = testPair.first.first; - const char delim = testPair.first.second; - const TStringBuf expectedValue = testPair.second; - - stdIn.ForInput(text, + + TMockStdIn stdIn; + + for (const auto& testPair : testPairs) { + const TStringBuf text = testPair.first.first; + const char delim = testPair.first.second; + const TStringBuf expectedValue = testPair.second; + + stdIn.ForInput(text, [=] { TString value; Cin.ReadTo(value, delim); UNIT_ASSERT_VALUES_EQUAL(value, expectedValue); }); - } - } + } + } } |