diff options
author | pozhilov <pozhilov@yandex-team.ru> | 2022-02-10 16:49:27 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:27 +0300 |
commit | 29b120fd551ad11a832424491fa992809feb3e99 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 | |
parent | 23bf1d16dddf213a6aa8e8d5c8621e1242a1f118 (diff) | |
download | ydb-29b120fd551ad11a832424491fa992809feb3e99.tar.gz |
Restoring authorship annotation for <pozhilov@yandex-team.ru>. Commit 2 of 2.
33 files changed, 345 insertions, 345 deletions
diff --git a/library/cpp/binsaver/bin_saver.h b/library/cpp/binsaver/bin_saver.h index 412c480d4a..412424889f 100644 --- a/library/cpp/binsaver/bin_saver.h +++ b/library/cpp/binsaver/bin_saver.h @@ -49,19 +49,19 @@ public: typedef ui32 TStoredSize; // changing this will break compatibility private: - // This overload is required to avoid infinite recursion when overriding serialization in derived classes: - // struct B { - // virtual int operator &(IBinSaver& f) { - // return 0; - // } - // }; - // - // struct D : B { - // int operator &(IBinSaver& f) override { - // f.Add(0, static_cast<B*>(this)); - // return 0; - // } - // }; + // This overload is required to avoid infinite recursion when overriding serialization in derived classes: + // struct B { + // virtual int operator &(IBinSaver& f) { + // return 0; + // } + // }; + // + // struct D : B { + // int operator &(IBinSaver& f) override { + // f.Add(0, static_cast<B*>(this)); + // return 0; + // } + // }; template <class T, typename = decltype(std::declval<T*>()->T::operator&(std::declval<IBinSaver&>()))> void CallObjectSerialize(T* p, NBinSaverInternals::TOverloadPriority<2>) { // highest priority - will be resolved first if enabled // Note: p->operator &(*this) would lead to infinite recursion @@ -77,7 +77,7 @@ private: void CallObjectSerialize(T* p, NBinSaverInternals::TOverloadPriority<0>) { // lower priority - will be resolved last #if (!defined(_MSC_VER)) // In MSVC __has_trivial_copy returns false to enums, primitive types and arrays. - static_assert(__has_trivial_copy(T), "Class is nontrivial copyable, you must define operator&, see"); + static_assert(__has_trivial_copy(T), "Class is nontrivial copyable, you must define operator&, see"); #endif DataChunk(p, sizeof(T)); } @@ -101,11 +101,11 @@ private: template <class T, int N> void DoArray(T (&data)[N]) { - for (size_t i = 0; i < N; i++) { - Add(1, &(data[i])); - } - } - + for (size_t i = 0; i < N; i++) { + Add(1, &(data[i])); + } + } + template <typename TLarge> void CheckOverflow(TStoredSize nSize, TLarge origSize) { if (nSize != origSize) { @@ -291,7 +291,7 @@ public: DataChunk(pData, nSize); } - // return type of Add() is used to detect specialized serializer (see HasNonTrivialSerializer below) + // return type of Add() is used to detect specialized serializer (see HasNonTrivialSerializer below) template <class T> char Add(const chunk_id, T* p) { CallObjectSerialize(p, NBinSaverInternals::TOverloadPriority<2>()); @@ -333,16 +333,16 @@ public: DoDataVector(*pVec); return 0; } - + template <class T, int N> int Add(const chunk_id, T (*pVec)[N]) { - if (HasNonTrivialSerializer<T>(0u)) - DoArray(*pVec); - else - DataChunk(pVec, sizeof(*pVec)); - return 0; - } - + if (HasNonTrivialSerializer<T>(0u)) + DoArray(*pVec); + else + DataChunk(pVec, sizeof(*pVec)); + return 0; + } + template <class T1, class T2, class T3, class T4> int Add(const chunk_id, TMap<T1, T2, T3, T4>* pMap) { DoAnyMap(*pMap); @@ -624,7 +624,7 @@ struct TRegisterSaveLoadType { f.AddMulti(__VA_ARGS__); \ return 0; \ } - + #define SAVELOAD_OVERRIDE_WITHOUT_BASE(...) \ int operator&(IBinSaver& f) override { \ f.AddMulti(__VA_ARGS__); \ diff --git a/library/cpp/binsaver/ut/binsaver_ut.cpp b/library/cpp/binsaver/ut/binsaver_ut.cpp index dd0584072f..37eba5406f 100644 --- a/library/cpp/binsaver/ut/binsaver_ut.cpp +++ b/library/cpp/binsaver/ut/binsaver_ut.cpp @@ -39,27 +39,27 @@ struct TCustomOuterSerializerTmplDerived: public TCustomOuterSerializerTmpl { TString StrData; }; -struct TMoveOnlyType { - ui32 Data = 0; - - TMoveOnlyType() = default; - TMoveOnlyType(TMoveOnlyType&&) = default; - +struct TMoveOnlyType { + ui32 Data = 0; + + TMoveOnlyType() = default; + TMoveOnlyType(TMoveOnlyType&&) = default; + bool operator==(const TMoveOnlyType& obj) const { - return Data == obj.Data; - } -}; - -struct TTypeWithArray { - ui32 Data = 1; + return Data == obj.Data; + } +}; + +struct TTypeWithArray { + ui32 Data = 1; TString Array[2][2]{{"test", "data"}, {"and", "more"}}; - - SAVELOAD(Data, Array); + + SAVELOAD(Data, Array); bool operator==(const TTypeWithArray& obj) const { return Data == obj.Data && std::equal(std::begin(Array[0]), std::end(Array[0]), obj.Array[0]) && std::equal(std::begin(Array[1]), std::end(Array[1]), obj.Array[1]); - } -}; - + } +}; + template <typename T, typename = std::enable_if_t<std::is_base_of<TCustomOuterSerializerTmpl, T>::value>> int operator&(T& s, IBinSaver& f); @@ -86,7 +86,7 @@ Y_UNIT_TEST(TestStroka) { Y_UNIT_TEST(TestMoveOnlyType) { TestBinSaverSerializationToBuffer(TMoveOnlyType()); } - + Y_UNIT_TEST(TestVectorStrok) { TestBinSaverSerialization(TVector<TString>{"A", "B", "C"}); } diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index fa948fe469..c61e8d1dc4 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -462,38 +462,38 @@ namespace NJson { bool TJsonValue::GetBooleanSafe(const bool defaultValue) const { if (Type == JSON_UNDEFINED) return defaultValue; - + return GetBooleanSafe(); } - + long long TJsonValue::GetIntegerSafe(const long long defaultValue) const { if (Type == JSON_UNDEFINED) return defaultValue; - + return GetIntegerSafe(); } - + unsigned long long TJsonValue::GetUIntegerSafe(const unsigned long long defaultValue) const { if (Type == JSON_UNDEFINED) return defaultValue; - + return GetUIntegerSafe(); } - + double TJsonValue::GetDoubleSafe(const double defaultValue) const { if (Type == JSON_UNDEFINED) return defaultValue; - + return GetDoubleSafe(); } - + TString TJsonValue::GetStringSafe(const TString& defaultValue) const { if (Type == JSON_UNDEFINED) return defaultValue; - + return GetStringSafe(); } - + const TJsonValue::TMapType& TJsonValue::GetMapSafe() const { if (Type != JSON_MAP) ythrow TJsonException() << "Not a map"; diff --git a/library/cpp/json/writer/json_value.h b/library/cpp/json/writer/json_value.h index 234861a4a8..3f0f50bc4c 100644 --- a/library/cpp/json/writer/json_value.h +++ b/library/cpp/json/writer/json_value.h @@ -135,7 +135,7 @@ namespace NJson { unsigned long long GetUIntegerRobust() const noexcept; double GetDoubleRobust() const noexcept; TString GetStringRobust() const; - + // Exception-free accessors bool GetBoolean(bool* value) const noexcept; bool GetInteger(long long* value) const noexcept; diff --git a/library/cpp/json/writer/json_value_ut.cpp b/library/cpp/json/writer/json_value_ut.cpp index b87710bf29..dc7f6affdf 100644 --- a/library/cpp/json/writer/json_value_ut.cpp +++ b/library/cpp/json/writer/json_value_ut.cpp @@ -507,98 +507,98 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } Y_UNIT_TEST(NonexistentFieldAccessTest) { - { - TJsonValue json; - json.InsertValue("some", "key"); - - UNIT_ASSERT(!json["some"]["weird"]["access"]["sequence"].Has("value")); - UNIT_ASSERT(!json["some"]["weird"]["access"]["sequence"].IsDefined()); - - UNIT_ASSERT(json["some"].GetType() == JSON_MAP); - } - } - + { + TJsonValue json; + json.InsertValue("some", "key"); + + UNIT_ASSERT(!json["some"]["weird"]["access"]["sequence"].Has("value")); + UNIT_ASSERT(!json["some"]["weird"]["access"]["sequence"].IsDefined()); + + UNIT_ASSERT(json["some"].GetType() == JSON_MAP); + } + } + Y_UNIT_TEST(DefaultValuesTest) { - { - TJsonValue json; - json.InsertValue("some", "key"); - json.InsertValue("existing", 1.2); - - UNIT_ASSERT_VALUES_EQUAL(json["existing"].GetDoubleSafe(), 1.2); - UNIT_ASSERT_VALUES_EQUAL(json["existing"].GetDoubleSafe(15), 1.2); - - UNIT_ASSERT_EXCEPTION(json["some"].GetUIntegerSafe(), yexception); - UNIT_ASSERT_EXCEPTION(json["some"].GetUIntegerSafe(12), yexception); - - UNIT_ASSERT_EXCEPTION(json["nonexistent"].GetUIntegerSafe(), yexception); - UNIT_ASSERT_VALUES_EQUAL(json["nonexistent"].GetUIntegerSafe(12), 12); - UNIT_ASSERT_VALUES_EQUAL(json["nonexistent"]["more_nonexistent"].GetUIntegerSafe(12), 12); - - json.InsertValue("map", TJsonValue(JSON_MAP)); - - UNIT_ASSERT_VALUES_EQUAL(json["map"]["nonexistent"].GetUIntegerSafe(12), 12); - } - } - + { + TJsonValue json; + json.InsertValue("some", "key"); + json.InsertValue("existing", 1.2); + + UNIT_ASSERT_VALUES_EQUAL(json["existing"].GetDoubleSafe(), 1.2); + UNIT_ASSERT_VALUES_EQUAL(json["existing"].GetDoubleSafe(15), 1.2); + + UNIT_ASSERT_EXCEPTION(json["some"].GetUIntegerSafe(), yexception); + UNIT_ASSERT_EXCEPTION(json["some"].GetUIntegerSafe(12), yexception); + + UNIT_ASSERT_EXCEPTION(json["nonexistent"].GetUIntegerSafe(), yexception); + UNIT_ASSERT_VALUES_EQUAL(json["nonexistent"].GetUIntegerSafe(12), 12); + UNIT_ASSERT_VALUES_EQUAL(json["nonexistent"]["more_nonexistent"].GetUIntegerSafe(12), 12); + + json.InsertValue("map", TJsonValue(JSON_MAP)); + + UNIT_ASSERT_VALUES_EQUAL(json["map"]["nonexistent"].GetUIntegerSafe(12), 12); + } + } + Y_UNIT_TEST(GetArrayPointerInArrayTest) { - TJsonValue outer; - { - TJsonValue json; - json.AppendValue(1); - json.AppendValue(2); - json.AppendValue(3); - - outer.AppendValue(json); - } + TJsonValue outer; + { + TJsonValue json; + json.AppendValue(1); + json.AppendValue(2); + json.AppendValue(3); + + outer.AppendValue(json); + } const TJsonValue::TArray* array = nullptr; - GetArrayPointer(outer, 0, &array); - UNIT_ASSERT_VALUES_EQUAL((*array)[1], 2); - } - + GetArrayPointer(outer, 0, &array); + UNIT_ASSERT_VALUES_EQUAL((*array)[1], 2); + } + Y_UNIT_TEST(GetArrayPointerInMapTest) { - TJsonValue outer; - { - TJsonValue json; - json.AppendValue(1); - json.AppendValue(2); - json.AppendValue(3); - - outer.InsertValue("x", json); - } + TJsonValue outer; + { + TJsonValue json; + json.AppendValue(1); + json.AppendValue(2); + json.AppendValue(3); + + outer.InsertValue("x", json); + } const TJsonValue::TArray* array = nullptr; - GetArrayPointer(outer, "x", &array); - UNIT_ASSERT_VALUES_EQUAL((*array)[1], 2); - } - + GetArrayPointer(outer, "x", &array); + UNIT_ASSERT_VALUES_EQUAL((*array)[1], 2); + } + Y_UNIT_TEST(GetMapPointerInArrayTest) { - TJsonValue outer; - { - TJsonValue json; - json.InsertValue("a", 1); - json.InsertValue("b", 2); - json.InsertValue("c", 3); - - outer.AppendValue(json); - } + TJsonValue outer; + { + TJsonValue json; + json.InsertValue("a", 1); + json.InsertValue("b", 2); + json.InsertValue("c", 3); + + outer.AppendValue(json); + } const TJsonValue::TMapType* map = nullptr; - GetMapPointer(outer, 0, &map); - UNIT_ASSERT_VALUES_EQUAL((*map).at("b"), 2); - } - + GetMapPointer(outer, 0, &map); + UNIT_ASSERT_VALUES_EQUAL((*map).at("b"), 2); + } + Y_UNIT_TEST(GetMapPointerInMapTest) { - TJsonValue outer; - { - TJsonValue json; - json.InsertValue("a", 1); - json.InsertValue("b", 2); - json.InsertValue("c", 3); - - outer.InsertValue("x", json); - } + TJsonValue outer; + { + TJsonValue json; + json.InsertValue("a", 1); + json.InsertValue("b", 2); + json.InsertValue("c", 3); + + outer.InsertValue("x", json); + } const TJsonValue::TMapType* map = nullptr; - GetMapPointer(outer, "x", &map); - UNIT_ASSERT_VALUES_EQUAL((*map).at("b"), 2); - } + GetMapPointer(outer, "x", &map); + UNIT_ASSERT_VALUES_EQUAL((*map).at("b"), 2); + } Y_UNIT_TEST(GetIntegerRobustBignumStringTest) { TString value = "1626862681464633683"; diff --git a/library/cpp/scheme/tests/ut/scheme_ut.cpp b/library/cpp/scheme/tests/ut/scheme_ut.cpp index dec50ce926..1a5d07c31b 100644 --- a/library/cpp/scheme/tests/ut/scheme_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_ut.cpp @@ -200,9 +200,9 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { } { NSc::TValue v; - UNIT_ASSERT(v.IsNull()); + UNIT_ASSERT(v.IsNull()); v = t; - UNIT_ASSERT(!v.IsNull()); + UNIT_ASSERT(!v.IsNull()); UNIT_ASSERT_VALUES_EQUAL_C(expectnum, v.IsNumber(), ss); UNIT_ASSERT_VALUES_EQUAL_C(expectint, v.IsIntNumber(), ss); UNIT_ASSERT_VALUES_EQUAL_C(expectbool, v.IsBool(), ss); @@ -572,7 +572,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { = NSc::NImpl::TSelfLoopContext::EMode::Stderr; NSc::TValue x; - + x["a"]["x"] = x; x["b"][0] = x; diff --git a/library/cpp/string_utils/url/url.h b/library/cpp/string_utils/url/url.h index 432ce97a3e..84137ccc57 100644 --- a/library/cpp/string_utils/url/url.h +++ b/library/cpp/string_utils/url/url.h @@ -44,8 +44,8 @@ TStringBuf GetSchemePrefix(const TStringBuf url) noexcept; //! removes protocol prefixes 'http://' and 'https://' from given URL //! @note if URL has no prefix or some other prefix the function does nothing -//! @param url URL from which the prefix should be removed -//! @param ignorehttps if true, leaves https:// +//! @param url URL from which the prefix should be removed +//! @param ignorehttps if true, leaves https:// //! @return a new URL without protocol prefix Y_PURE_FUNCTION TStringBuf CutHttpPrefix(const TStringBuf url, bool ignorehttps = false) noexcept; diff --git a/library/python/ya.make b/library/python/ya.make index 172b2dc6ef..2e1eb6e0e1 100644 --- a/library/python/ya.make +++ b/library/python/ya.make @@ -129,7 +129,7 @@ RECURSE( nirvana_test nstools nyt - oauth + oauth oauth/example ok_client openssl diff --git a/util/datetime/base.h b/util/datetime/base.h index 6a8710b3a6..5e902b8f63 100644 --- a/util/datetime/base.h +++ b/util/datetime/base.h @@ -45,7 +45,7 @@ class TDateTimeParseException: public yexception { const int DATE_BUF_LEN = 4 + 2 + 2 + 1; // [YYYYMMDD*] -constexpr long seconds(const struct tm& theTm) { +constexpr long seconds(const struct tm& theTm) { return 60 * (60 * theTm.tm_hour + theTm.tm_min) + theTm.tm_sec; } @@ -78,7 +78,7 @@ bool ParseHTTPDateTime(const char* date, size_t dateLen, time_t& utcTime); bool ParseX509ValidityDateTime(const char* date, time_t& utcTime); bool ParseX509ValidityDateTime(const char* date, size_t dateLen, time_t& utcTime); -constexpr long TVdiff(timeval r1, timeval r2) { +constexpr long TVdiff(timeval r1, timeval r2) { return (1000000 * (r2.tv_sec - r1.tv_sec) + (r2.tv_usec - r1.tv_usec)); } @@ -264,9 +264,9 @@ public: return TDuration(us); } - /* noexcept(false) as conversion from T might throw, for example FromString("abc") */ + /* noexcept(false) as conversion from T might throw, for example FromString("abc") */ template <typename T> - static constexpr TDuration MilliSeconds(T ms) noexcept(false) { + static constexpr TDuration MilliSeconds(T ms) noexcept(false) { return MicroSeconds((ui64)(typename NDateTimeHelpers::TPrecisionHelper<T>::THighPrecision(ms) * 1000)); } @@ -279,7 +279,7 @@ public: /// DeadLineFromTimeOut inline TInstant ToDeadLine() const; - constexpr TInstant ToDeadLine(TInstant now) const; + constexpr TInstant ToDeadLine(TInstant now) const; static constexpr TDuration Max() noexcept { return TDuration(::Max<TValue>()); @@ -289,9 +289,9 @@ public: return TDuration(); } - /* noexcept(false) as conversion from T might throw, for example FromString("abc") */ + /* noexcept(false) as conversion from T might throw, for example FromString("abc") */ template <typename T> - static constexpr TDuration Seconds(T s) noexcept(false) { + static constexpr TDuration Seconds(T s) noexcept(false) { return MilliSeconds(typename NDateTimeHelpers::TPrecisionHelper<T>::THighPrecision(s) * 1000); } @@ -571,7 +571,7 @@ namespace NPrivate { struct TPrintableLocalTime { TInstant MomentToPrint; - constexpr explicit TPrintableLocalTime(TInstant momentToPrint) + constexpr explicit TPrintableLocalTime(TInstant momentToPrint) : MomentToPrint(momentToPrint) { } @@ -633,17 +633,17 @@ static constexpr bool operator>=(const TTimeBase<S>& l, const TTimeBase<S>& r) n namespace NDateTimeHelpers { template <typename T> - static constexpr T SumWithSaturation(T a, T b) { + static constexpr T SumWithSaturation(T a, T b) { static_assert(!std::numeric_limits<T>::is_signed, "expect !std::numeric_limits<T>::is_signed"); - return Max<T>() - a < b ? Max<T>() : a + b; + return Max<T>() - a < b ? Max<T>() : a + b; } template <typename T> - static constexpr T DiffWithSaturation(T a, T b) { + static constexpr T DiffWithSaturation(T a, T b) { static_assert(!std::numeric_limits<T>::is_signed, "expect !std::numeric_limits<T>::is_signed"); - return a < b ? 0 : a - b; + return a < b ? 0 : a - b; } } @@ -803,11 +803,11 @@ constexpr double operator/(const TDuration& x, const TDuration& y) noexcept { return static_cast<double>(x.GetValue()) / static_cast<double>(y.GetValue()); } -inline TInstant TDuration::ToDeadLine() const { +inline TInstant TDuration::ToDeadLine() const { return ToDeadLine(TInstant::Now()); } -constexpr TInstant TDuration::ToDeadLine(TInstant now) const { +constexpr TInstant TDuration::ToDeadLine(TInstant now) const { return now + *this; } diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp index 0291c39329..afc3f802eb 100644 --- a/util/datetime/base_ut.cpp +++ b/util/datetime/base_ut.cpp @@ -491,11 +491,11 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { Y_UNIT_TEST(TestDurationUnits) { TestTimeUnits<TDuration>(); } - + Y_UNIT_TEST(TestNoexceptConstruction) { UNIT_ASSERT_EXCEPTION(TDuration::MilliSeconds(FromString(TStringBuf("not a number"))), yexception); UNIT_ASSERT_EXCEPTION(TDuration::Seconds(FromString(TStringBuf("not a number"))), yexception); - } + } Y_UNIT_TEST(TestFromValueForTDuration) { // check that FromValue creates the same TDuration diff --git a/util/folder/path.h b/util/folder/path.h index 62c9741d1b..2fb4d6b4ef 100644 --- a/util/folder/path.h +++ b/util/folder/path.h @@ -62,9 +62,9 @@ public: TFsPath& operator/=(const TFsPath& that); - friend TFsPath operator/(const TFsPath& s, const TFsPath& p) { - TFsPath ret(s); - return ret /= p; + friend TFsPath operator/(const TFsPath& s, const TFsPath& p) { + TFsPath ret(s); + return ret /= p; } const TPathSplit& PathSplit() const; diff --git a/util/folder/tempdir.h b/util/folder/tempdir.h index 0eef1c2e1f..ff458f83b9 100644 --- a/util/folder/tempdir.h +++ b/util/folder/tempdir.h @@ -1,7 +1,7 @@ #pragma once #include "fwd.h" -#include "path.h" +#include "path.h" #include <util/generic/string.h> class TTempDir { @@ -22,10 +22,10 @@ public: } const TString& Name() const { - return TempDir.GetPath(); - } - - const TFsPath& Path() const { + return TempDir.GetPath(); + } + + const TFsPath& Path() const { return TempDir; } @@ -38,6 +38,6 @@ private: // by requiring additional fake argument. TTempDir(const char* prefix, TCreationToken); - TFsPath TempDir; + TFsPath TempDir; bool Remove; }; diff --git a/util/generic/fwd.h b/util/generic/fwd.h index 6bc808a8c2..5cc2da40e5 100644 --- a/util/generic/fwd.h +++ b/util/generic/fwd.h @@ -132,7 +132,7 @@ class TSharedPtr; template <class T, class C = TCopyNew, class D = TDelete> class TCopyPtr; - + template <class TPtr, class TCopy = TCopyNew> class TCowPtr; @@ -151,13 +151,13 @@ using TArrayPtr = TAutoPtr<T, TDeleteArray>; template <typename T> using TMallocPtr = TAutoPtr<T, TFree>; -//maybe -namespace NMaybe { - struct TPolicyUndefinedExcept; -} +//maybe +namespace NMaybe { + struct TPolicyUndefinedExcept; +} -template <class T, class Policy = ::NMaybe::TPolicyUndefinedExcept> -class TMaybe; +template <class T, class Policy = ::NMaybe::TPolicyUndefinedExcept> +class TMaybe; struct TGUID; diff --git a/util/generic/hash.cpp b/util/generic/hash.cpp index bbc922072e..a674ee4538 100644 --- a/util/generic/hash.cpp +++ b/util/generic/hash.cpp @@ -1,18 +1,18 @@ #include "hash.h" -#include <util/string/escape.h> +#include <util/string/escape.h> #include <util/string/cast.h> const void* const _yhashtable_empty_data[] = {(void*)3, nullptr, (void*)1}; - + TString NPrivate::MapKeyToString(TStringBuf key) { - constexpr size_t HASH_KEY_MAX_LENGTH = 500; - try { - return EscapeC(key.substr(0, HASH_KEY_MAX_LENGTH)); - } catch (...) { + constexpr size_t HASH_KEY_MAX_LENGTH = 500; + try { + return EscapeC(key.substr(0, HASH_KEY_MAX_LENGTH)); + } catch (...) { return "TStringBuf"; - } -} + } +} TString NPrivate::MapKeyToString(unsigned short key) { return ToString(key); diff --git a/util/generic/hash.h b/util/generic/hash.h index 30d00685e8..e46db21fa9 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -1390,12 +1390,12 @@ void THashTable<V, K, HF, Ex, Eq, A>::copy_from_dynamic(const THashTable& ht) { #endif /* __STL_USE_EXCEPTIONS */ } -namespace NPrivate { +namespace NPrivate { template <class Key> inline TString MapKeyToString(const Key&) { return TypeName<Key>(); - } - + } + TString MapKeyToString(TStringBuf key); TString MapKeyToString(unsigned short key); TString MapKeyToString(short key); @@ -1405,22 +1405,22 @@ namespace NPrivate { TString MapKeyToString(long key); TString MapKeyToString(unsigned long long key); TString MapKeyToString(long long key); - + inline TString MapKeyToString(const TString& key) { - return MapKeyToString(TStringBuf(key)); - } - + return MapKeyToString(TStringBuf(key)); + } + inline TString MapKeyToString(const char* key) { - return MapKeyToString(TStringBuf(key)); - } - + return MapKeyToString(TStringBuf(key)); + } + inline TString MapKeyToString(char* key) { - return MapKeyToString(TStringBuf(key)); - } + return MapKeyToString(TStringBuf(key)); + } [[noreturn]] void ThrowKeyNotFoundInHashTableException(const TStringBuf keyRepresentation); } - + template <class Key, class T, class HashFcn, class EqualKey, class Alloc> class THashMap: public TMapOps<THashMap<Key, T, HashFcn, EqualKey, Alloc>> { private: diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 3df3371dbe..0551d58770 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -21,11 +21,11 @@ class THashTest: public TTestBase { UNIT_TEST(TestHMMap1); UNIT_TEST(TestHMMapHas); UNIT_TEST(TestHSetConstructorsAndAssignments); - UNIT_TEST(TestHSetSize); + UNIT_TEST(TestHSetSize); UNIT_TEST(TestHSet2); UNIT_TEST(TestHSetEqualityOperator); UNIT_TEST(TestHMSetConstructorsAndAssignments); - UNIT_TEST(TestHMSetSize); + UNIT_TEST(TestHMSetSize); UNIT_TEST(TestHMSet1); UNIT_TEST(TestHMSetEqualityOperator); UNIT_TEST(TestHMSetEmplace); @@ -52,7 +52,7 @@ class THashTest: public TTestBase { UNIT_TEST(TestValueInitialization); UNIT_TEST(TestAssignmentClear); UNIT_TEST(TestReleaseNodes); - UNIT_TEST(TestAt); + UNIT_TEST(TestAt); UNIT_TEST(TestHMapInitializerList); UNIT_TEST(TestHMMapInitializerList); UNIT_TEST(TestHSetInitializerList); @@ -72,11 +72,11 @@ protected: void TestHMMap1(); void TestHMMapHas(); void TestHSetConstructorsAndAssignments(); - void TestHSetSize(); + void TestHSetSize(); void TestHSet2(); void TestHSetEqualityOperator(); void TestHMSetConstructorsAndAssignments(); - void TestHMSetSize(); + void TestHMSetSize(); void TestHMSet1(); void TestHMSetEqualityOperator(); void TestHMSetEmplace(); @@ -103,7 +103,7 @@ protected: void TestValueInitialization(); void TestAssignmentClear(); void TestReleaseNodes(); - void TestAt(); + void TestAt(); void TestHMapInitializerList(); void TestHMMapInitializerList(); void TestHSetInitializerList(); @@ -407,20 +407,20 @@ void THashTest::TestHSetConstructorsAndAssignments() { UNIT_ASSERT(c4.contains(3)); } -void THashTest::TestHSetSize() { +void THashTest::TestHSetSize() { using container = THashSet<int>; - - container c; - c.insert(100); - c.insert(200); - - UNIT_ASSERT_VALUES_EQUAL(2, c.size()); - - c.insert(200); - - UNIT_ASSERT_VALUES_EQUAL(2, c.size()); -} - + + container c; + c.insert(100); + c.insert(200); + + UNIT_ASSERT_VALUES_EQUAL(2, c.size()); + + c.insert(200); + + UNIT_ASSERT_VALUES_EQUAL(2, c.size()); +} + void THashTest::TestHSet2() { THashSet<int, THash<int>, TEqualTo<int>> s; auto p = s.insert(42); @@ -492,20 +492,20 @@ void THashTest::TestHMSetConstructorsAndAssignments() { UNIT_ASSERT(c3.find(400) != c3.end()); } -void THashTest::TestHMSetSize() { +void THashTest::TestHMSetSize() { using container = THashMultiSet<int>; - - container c; - c.insert(100); - c.insert(200); - - UNIT_ASSERT_VALUES_EQUAL(2, c.size()); - - c.insert(200); - - UNIT_ASSERT_VALUES_EQUAL(3, c.size()); -} - + + container c; + c.insert(100); + c.insert(200); + + UNIT_ASSERT_VALUES_EQUAL(2, c.size()); + + c.insert(200); + + UNIT_ASSERT_VALUES_EQUAL(3, c.size()); +} + void THashTest::TestHMSet1() { hmset s; UNIT_ASSERT(s.count(star) == 0); @@ -1111,8 +1111,8 @@ void THashTest::TestReleaseNodes() { set2.insert(1); UNIT_ASSERT_VALUES_EQUAL(set2.size(), 1); } - -void THashTest::TestAt() { + +void THashTest::TestAt() { #define TEST_AT_THROWN_EXCEPTION(SRC_TYPE, DST_TYPE, KEY_TYPE, KEY, MESSAGE) \ { \ THashMap<SRC_TYPE, DST_TYPE> testMap; \ @@ -1125,8 +1125,8 @@ void THashTest::TestAt() { } catch (...) { \ UNIT_ASSERT_C(false, "THashMap::at(\"" << KEY << "\") should throw yexception"); \ } \ - } - + } + TEST_AT_THROWN_EXCEPTION(TString, TString, TString, "111", "111"); TEST_AT_THROWN_EXCEPTION(TString, TString, const TString, "111", "111"); TEST_AT_THROWN_EXCEPTION(TString, TString, TStringBuf, "111", "111"); @@ -1140,13 +1140,13 @@ void THashTest::TestAt() { TEST_AT_THROWN_EXCEPTION(int, int, unsigned int, 2, "2"); TEST_AT_THROWN_EXCEPTION(int, int, unsigned long, 131, "131"); TEST_AT_THROWN_EXCEPTION(int, int, unsigned long long, 1000000000000ll, "1000000000000"); - + char key[] = {11, 12, 0, 1, 2, 11, 0}; TEST_AT_THROWN_EXCEPTION(TString, TString, char*, key, "\\x0B\\x0C"); TEST_AT_THROWN_EXCEPTION(TString, TString, TStringBuf, TStringBuf(key, sizeof(key) - 1), "\\x0B\\x0C\\0\\1\\2\\x0B"); - -#undef TEST_AT_THROWN_EXCEPTION -} + +#undef TEST_AT_THROWN_EXCEPTION +} void THashTest::TestHMapInitializerList() { THashMap<TString, TString> h1 = {{"foo", "bar"}, {"bar", "baz"}, {"baz", "qux"}}; diff --git a/util/generic/is_in.h b/util/generic/is_in.h index a3277f173d..4f175ea5eb 100644 --- a/util/generic/is_in.h +++ b/util/generic/is_in.h @@ -47,7 +47,7 @@ static inline bool IsIn(const C& c, const T& e) { return TIsInTraits<C, T, TIsAssocCont<C>::value>::IsIn(c, e); } -template <class T, class U> -static inline bool IsIn(std::initializer_list<T> l, const U& e) { +template <class T, class U> +static inline bool IsIn(std::initializer_list<T> l, const U& e) { return ::IsIn(l.begin(), l.end(), e); } diff --git a/util/generic/is_in_ut.cpp b/util/generic/is_in_ut.cpp index 1306e427e7..c668bce807 100644 --- a/util/generic/is_in_ut.cpp +++ b/util/generic/is_in_ut.cpp @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TIsIn) { UNIT_ASSERT(IsIn(b, 'f')); UNIT_ASSERT(!IsIn(b, 'z')); } - + Y_UNIT_TEST(IsInInitListTest) { const char* abc = "abc"; const char* def = "def"; @@ -88,22 +88,22 @@ Y_UNIT_TEST_SUITE(TIsIn) { UNIT_ASSERT(!IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("ghi"))); UNIT_ASSERT(!IsIn({"abc", "def"}, TStringBuf("ghi"))); UNIT_ASSERT(!IsIn({"abc", "def"}, TString("ghi"))); - - const TStringBuf str = "abc////"; - + + const TStringBuf str = "abc////"; + UNIT_ASSERT(IsIn({"abc", "def"}, TStringBuf{str.data(), 3})); } Y_UNIT_TEST(ConfOfTest) { UNIT_ASSERT(IsIn({1, 2, 3}, 1)); UNIT_ASSERT(!IsIn({1, 2, 3}, 4)); - + const TString b = "b"; - + UNIT_ASSERT(!IsIn({"a", "b", "c"}, b.data())); // compares pointers by value. Whether it's good or not. UNIT_ASSERT(IsIn(TVector<TStringBuf>({"a", "b", "c"}), b.data())); UNIT_ASSERT(IsIn(TVector<TStringBuf>({"a", "b", "c"}), "b")); - } + } Y_UNIT_TEST(IsInArrayTest) { const TString array[] = {"a", "b", "d"}; diff --git a/util/generic/maybe.h b/util/generic/maybe.h index f009fdb1e9..34d21aebcd 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -34,7 +34,7 @@ constexpr bool operator==(TNothing, TNothing) noexcept { return true; } -template <class T, class Policy /*= ::NMaybe::TPolicyUndefinedExcept*/> +template <class T, class Policy /*= ::NMaybe::TPolicyUndefinedExcept*/> class TMaybe: private TMaybeBase<T> { public: using TInPlace = NMaybe::TInPlace; diff --git a/util/generic/ptr_ut.cpp b/util/generic/ptr_ut.cpp index b8429f7ca2..c2dcff23f6 100644 --- a/util/generic/ptr_ut.cpp +++ b/util/generic/ptr_ut.cpp @@ -20,7 +20,7 @@ class TPointerTest: public TTestBase { UNIT_TEST(TestHolderPtrMoveAssignmentInheritance); UNIT_TEST(TestMakeHolder); UNIT_TEST(TestTrulePtr); - UNIT_TEST(TestAutoToHolder); + UNIT_TEST(TestAutoToHolder); UNIT_TEST(TestCopyPtr); UNIT_TEST(TestIntrPtr); UNIT_TEST(TestIntrusiveConvertion); @@ -72,7 +72,7 @@ private: void TestHolderPtrMoveAssignmentInheritance(); void TestMakeHolder(); void TestTrulePtr(); - void TestAutoToHolder(); + void TestAutoToHolder(); void TestCopyPtr(); void TestIntrPtr(); void TestIntrusiveConvertion(); @@ -136,7 +136,7 @@ void TPointerTest::TestSimpleIntrPtr() { a2 = a3; } - UNIT_ASSERT_VALUES_EQUAL(cnt, 0); + UNIT_ASSERT_VALUES_EQUAL(cnt, 0); } void TPointerTest::TestHolderPtr() { @@ -145,7 +145,7 @@ void TPointerTest::TestHolderPtr() { THolder<A> a2(a1.Release()); } - UNIT_ASSERT_VALUES_EQUAL(cnt, 0); + UNIT_ASSERT_VALUES_EQUAL(cnt, 0); } THolder<int> CreateInt(int value) { @@ -246,19 +246,19 @@ void TPointerTest::TestTrulePtr() { a1 = a2; } - UNIT_ASSERT_VALUES_EQUAL(cnt, 0); + UNIT_ASSERT_VALUES_EQUAL(cnt, 0); } void TPointerTest::TestAutoToHolder() { - { + { TAutoPtr<A> a1(MakeA()); - THolder<A> a2(a1); - - UNIT_ASSERT_EQUAL(a1.Get(), nullptr); - UNIT_ASSERT_VALUES_EQUAL(cnt, 1); - } - - UNIT_ASSERT_VALUES_EQUAL(cnt, 0); + THolder<A> a2(a1); + + UNIT_ASSERT_EQUAL(a1.Get(), nullptr); + UNIT_ASSERT_VALUES_EQUAL(cnt, 1); + } + + UNIT_ASSERT_VALUES_EQUAL(cnt, 0); { TAutoPtr<A> x(new A()); @@ -276,22 +276,22 @@ void TPointerTest::TestAutoToHolder() { } UNIT_ASSERT_VALUES_EQUAL(cnt, 0); -} - +} + void TPointerTest::TestCopyPtr() { TCopyPtr<A> a1(MakeA()); { TCopyPtr<A> a2(MakeA()); TCopyPtr<A> a3 = a2; - UNIT_ASSERT_VALUES_EQUAL(cnt, 3); + UNIT_ASSERT_VALUES_EQUAL(cnt, 3); a1 = a2; a2 = a3; } - UNIT_ASSERT_VALUES_EQUAL(cnt, 1); + UNIT_ASSERT_VALUES_EQUAL(cnt, 1); a1.Destroy(); - UNIT_ASSERT_VALUES_EQUAL(cnt, 0); + UNIT_ASSERT_VALUES_EQUAL(cnt, 0); } class TOp: public TSimpleRefCount<TOp>, public TNonCopyable { @@ -348,20 +348,20 @@ void TPointerTest::TestIntrPtr() { f2.push_back(p); Attach(&op3, &f2[1]); f1 = f2; - UNIT_ASSERT_VALUES_EQUAL(f1[0]->RefCount(), 2); - UNIT_ASSERT_VALUES_EQUAL(f1[1]->RefCount(), 3); + UNIT_ASSERT_VALUES_EQUAL(f1[0]->RefCount(), 2); + UNIT_ASSERT_VALUES_EQUAL(f1[1]->RefCount(), 3); UNIT_ASSERT_EQUAL(f1[1].Get(), op3.Op2.Get()); - UNIT_ASSERT_VALUES_EQUAL(op3.Op2->RefCount(), 3); - UNIT_ASSERT_VALUES_EQUAL(op3.Op2->Op->RefCount(), 2); - UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 4); + UNIT_ASSERT_VALUES_EQUAL(op3.Op2->RefCount(), 3); + UNIT_ASSERT_VALUES_EQUAL(op3.Op2->Op->RefCount(), 2); + UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 4); } p2 = p; } - UNIT_ASSERT_VALUES_EQUAL(op3.Op2->RefCount(), 1); - UNIT_ASSERT_VALUES_EQUAL(op3.Op2->Op->RefCount(), 3); - UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 3); + UNIT_ASSERT_VALUES_EQUAL(op3.Op2->RefCount(), 1); + UNIT_ASSERT_VALUES_EQUAL(op3.Op2->Op->RefCount(), 3); + UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 3); } - UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 0); + UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 0); } namespace NTestIntrusiveConvertion { @@ -424,7 +424,7 @@ void TPointerTest::TestMakeIntrusive() { UNIT_ASSERT_VALUES_EQUAL(1, p->RefCount()); UNIT_ASSERT_VALUES_EQUAL(1, TOp::Cnt); } - UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 0); + UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 0); } void TPointerTest::TestCopyOnWritePtr1() { diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp index 28f6951b5f..69cde785af 100644 --- a/util/generic/strbuf_ut.cpp +++ b/util/generic/strbuf_ut.cpp @@ -197,10 +197,10 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("b")); UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("a")); UNIT_ASSERT_EQUAL(buf2, TStringBuf()); - - TStringBuf buf3("a@@b@@c"); + + TStringBuf buf3("a@@b@@c"); UNIT_ASSERT_EQUAL(buf3.RNextTok("@@@"), TStringBuf("a@@b@@c")); - UNIT_ASSERT_EQUAL(buf3, TStringBuf()); + UNIT_ASSERT_EQUAL(buf3, TStringBuf()); } Y_UNIT_TEST(TestReadLine) { diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp index fe3c6059b4..e7571c75ec 100644 --- a/util/generic/typetraits_ut.cpp +++ b/util/generic/typetraits_ut.cpp @@ -227,9 +227,9 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) { UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass4>::value); } - template <class T> + template <class T> using TTrySum = decltype(std::declval<T>() + std::declval<T>()); - + Y_UNIT_TEST(TestIsTriviallyCopyable) { struct TPod { int value; diff --git a/util/generic/utility.h b/util/generic/utility.h index 96061fe45c..43b98eeafc 100644 --- a/util/generic/utility.h +++ b/util/generic/utility.h @@ -5,22 +5,22 @@ #include <cstring> template <class T> -static constexpr const T& Min(const T& l, const T& r) { +static constexpr const T& Min(const T& l, const T& r) { return r < l ? r : l; } template <typename T, typename... Args> -static constexpr const T& Min(const T& a, const T& b, const Args&... args) { +static constexpr const T& Min(const T& a, const T& b, const Args&... args) { return Min(a, Min(b, args...)); } template <class T> -static constexpr const T& Max(const T& l, const T& r) { +static constexpr const T& Max(const T& l, const T& r) { return l < r ? r : l; } template <typename T, typename... Args> -static constexpr const T& Max(const T& a, const T& b, const Args&... args) { +static constexpr const T& Max(const T& a, const T& b, const Args&... args) { return Max(a, Max(b, args...)); } diff --git a/util/generic/ylimits.h b/util/generic/ylimits.h index 46c6cd5ed5..fe42b4dfc0 100644 --- a/util/generic/ylimits.h +++ b/util/generic/ylimits.h @@ -19,14 +19,14 @@ static constexpr T Min() noexcept { namespace NPrivate { struct TMax { template <class T> - constexpr operator T() const { + constexpr operator T() const { return Max<T>(); } }; struct TMin { template <class T> - constexpr operator T() const { + constexpr operator T() const { return Min<T>(); } }; diff --git a/util/generic/ymath.h b/util/generic/ymath.h index 5998207f9f..9ff9ae2abe 100644 --- a/util/generic/ymath.h +++ b/util/generic/ymath.h @@ -18,7 +18,7 @@ constexpr double M_LN2_INV = M_LOG2E; // 1 / ln(2) == log2(e) * \returns Absolute value of the provided argument. */ template <class T> -constexpr T Abs(T value) { +constexpr T Abs(T value) { return std::abs(value); } diff --git a/util/string/cast.h b/util/string/cast.h index 48d4c5c5cd..90e925c194 100644 --- a/util/string/cast.h +++ b/util/string/cast.h @@ -119,9 +119,9 @@ inline const TUtf16String& ToWtring(TUtf16String& w) { return w; } -struct TFromStringException: public TBadCastException { -}; - +struct TFromStringException: public TBadCastException { +}; + /* * specialized for: * bool diff --git a/util/string/cast.pxd b/util/string/cast.pxd index b0fcc8123f..dc23619e1e 100644 --- a/util/string/cast.pxd +++ b/util/string/cast.pxd @@ -1,8 +1,8 @@ -from util.generic.string cimport TString - +from util.generic.string cimport TString + from libcpp cimport bool as bool_t -cdef extern from "<util/string/cast.h>" nogil: +cdef extern from "<util/string/cast.h>" nogil: T FromString[T](const TString&) except + bool_t TryFromString[T](const TString&, T&) except + TString ToString[T](const T&) except + diff --git a/util/string/cast_ut.pyx b/util/string/cast_ut.pyx index 16bc90e5f5..88e86ef961 100644 --- a/util/string/cast_ut.pyx +++ b/util/string/cast_ut.pyx @@ -1,13 +1,13 @@ # cython: c_string_type=str, c_string_encoding=utf8 from util.string.cast cimport FromString, ToString - -import unittest - + +import unittest + class TestFromString(unittest.TestCase): def test_from_int(self): self.assertEquals(FromString[int]("42"), 42) -class TestToString(unittest.TestCase): - def test_from_int(self): - self.assertEquals(ToString(42), "42") +class TestToString(unittest.TestCase): + def test_from_int(self): + self.assertEquals(ToString(42), "42") diff --git a/util/string/split.h b/util/string/split.h index 81607e0961..bc46d9e64c 100644 --- a/util/string/split.h +++ b/util/string/split.h @@ -1,10 +1,10 @@ #pragma once #include "strspn.h" -#include "cast.h" +#include "cast.h" #include <util/generic/algorithm.h> -#include <util/generic/fwd.h> +#include <util/generic/fwd.h> #include <util/generic/iterator.h> #include <util/generic/iterator_range.h> #include <util/generic/store_policy.h> @@ -431,16 +431,16 @@ void GetNext(TStringBuf& s, D delim, P& param) { param = FromString<P>(next); } -template <class P, class D> -void GetNext(TStringBuf& s, D delim, TMaybe<P>& param) { - TStringBuf next = s.NextTok(delim); - if (next.IsInited()) { - param = FromString<P>(next); - } else { - param.Clear(); - } -} - +template <class P, class D> +void GetNext(TStringBuf& s, D delim, TMaybe<P>& param) { + TStringBuf next = s.NextTok(delim); + if (next.IsInited()) { + param = FromString<P>(next); + } else { + param.Clear(); + } +} + // example: // Split(TStringBuf("Sherlock,2014,36.6"), ',', name, year, temperature); template <class D, class P1, class P2> diff --git a/util/string/split_ut.cpp b/util/string/split_ut.cpp index 89c28258e5..43e59f2d75 100644 --- a/util/string/split_ut.cpp +++ b/util/string/split_ut.cpp @@ -5,7 +5,7 @@ #include <util/stream/output.h> #include <util/charset/wide.h> #include <util/datetime/cputimer.h> -#include <util/generic/maybe.h> +#include <util/generic/maybe.h> #include <string> #include <string_view> @@ -258,25 +258,25 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { double num2 = 0; TStringBuf strBuf; Split(data, ' ', str, num1, num2, strBuf); - UNIT_ASSERT_VALUES_EQUAL(str, "abc"); - UNIT_ASSERT_VALUES_EQUAL(num1, 22); - UNIT_ASSERT_VALUES_EQUAL(num2, 33.5); - UNIT_ASSERT_VALUES_EQUAL(strBuf, "xyz"); + UNIT_ASSERT_VALUES_EQUAL(str, "abc"); + UNIT_ASSERT_VALUES_EQUAL(num1, 22); + UNIT_ASSERT_VALUES_EQUAL(num2, 33.5); + UNIT_ASSERT_VALUES_EQUAL(strBuf, "xyz"); } Y_UNIT_TEST(ConvenientSplitTestWithMaybe) { TString data("abc 42"); TString str; - TMaybe<double> num2 = 1; - TMaybe<double> maybe = 1; - - Split(data, ' ', str, num2, maybe); - - UNIT_ASSERT_VALUES_EQUAL(str, "abc"); - UNIT_ASSERT_VALUES_EQUAL(*num2, 42); - UNIT_ASSERT(!maybe); - } - + TMaybe<double> num2 = 1; + TMaybe<double> maybe = 1; + + Split(data, ' ', str, num2, maybe); + + UNIT_ASSERT_VALUES_EQUAL(str, "abc"); + UNIT_ASSERT_VALUES_EQUAL(*num2, 42); + UNIT_ASSERT(!maybe); + } + Y_UNIT_TEST(ConvenientSplitTestExceptions) { TString data("abc 22 33"); TString s1, s2, s3, s4; @@ -285,22 +285,22 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { UNIT_ASSERT_NO_EXCEPTION(Split(data, ' ', s1, s2, s3)); UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, s2, s3, s4), yexception); } - + Y_UNIT_TEST(ConvenientSplitTestMaybeExceptions) { TString data("abc 22 33"); TString s1, s2; TMaybe<TString> m1, m2; - - UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, m1), yexception); - UNIT_ASSERT_EXCEPTION(Split(data, ' ', m1, m2), yexception); - UNIT_ASSERT_NO_EXCEPTION(Split(data, ' ', s1, s2, m1)); - - UNIT_ASSERT_NO_EXCEPTION(Split(data, ' ', s1, s2, m1, m2)); - UNIT_ASSERT_EXCEPTION(Split(data, ' ', m1, m2, s1, s2), yexception); - - UNIT_ASSERT_NO_EXCEPTION(Split(data, ' ', s1, s2, m1, m2, m1, m1, m1, m1)); - UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, s2, m1, m2, m1, m1, m1, m1, s1), yexception); - } + + UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, m1), yexception); + UNIT_ASSERT_EXCEPTION(Split(data, ' ', m1, m2), yexception); + UNIT_ASSERT_NO_EXCEPTION(Split(data, ' ', s1, s2, m1)); + + UNIT_ASSERT_NO_EXCEPTION(Split(data, ' ', s1, s2, m1, m2)); + UNIT_ASSERT_EXCEPTION(Split(data, ' ', m1, m2, s1, s2), yexception); + + UNIT_ASSERT_NO_EXCEPTION(Split(data, ' ', s1, s2, m1, m2, m1, m1, m1, m1)); + UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, s2, m1, m2, m1, m1, m1, m1, s1), yexception); + } } template <typename I, typename C> diff --git a/util/tests/cython/test_generic.py b/util/tests/cython/test_generic.py index 0d257a4496..a0d61339cc 100644 --- a/util/tests/cython/test_generic.py +++ b/util/tests/cython/test_generic.py @@ -25,5 +25,5 @@ __all__ = [ 'TestStroka', 'TestVector', 'TestFromString', - 'TestToString', + 'TestToString', ] diff --git a/util/tests/cython/ya.make b/util/tests/cython/ya.make index c21bf92b5f..b928c19026 100644 --- a/util/tests/cython/ya.make +++ b/util/tests/cython/ya.make @@ -22,7 +22,7 @@ PY_SRCS( generic/hash_ut.pyx memory/blob_ut.pyx stream/str_ut.pyx - string/cast_ut.pyx + string/cast_ut.pyx system/types_ut.pyx digest/multi_ut.pyx ) diff --git a/util/ysaveload.h b/util/ysaveload.h index 17ed83dd32..02efb4049b 100644 --- a/util/ysaveload.h +++ b/util/ysaveload.h @@ -685,12 +685,12 @@ private: template <class T> static inline void SaveLoad(IOutputStream* out, const T& t) { - Save(out, t); + Save(out, t); } template <class T> static inline void SaveLoad(IInputStream* in, T& t) { - Load(in, t); + Load(in, t); } template <class S, class... Ts> |