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 /library | |
parent | 23bf1d16dddf213a6aa8e8d5c8621e1242a1f118 (diff) | |
download | ydb-29b120fd551ad11a832424491fa992809feb3e99.tar.gz |
Restoring authorship annotation for <pozhilov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library')
-rw-r--r-- | library/cpp/binsaver/bin_saver.h | 58 | ||||
-rw-r--r-- | library/cpp/binsaver/ut/binsaver_ut.cpp | 36 | ||||
-rw-r--r-- | library/cpp/json/writer/json_value.cpp | 20 | ||||
-rw-r--r-- | library/cpp/json/writer/json_value.h | 2 | ||||
-rw-r--r-- | library/cpp/json/writer/json_value_ut.cpp | 166 | ||||
-rw-r--r-- | library/cpp/scheme/tests/ut/scheme_ut.cpp | 6 | ||||
-rw-r--r-- | library/cpp/string_utils/url/url.h | 4 | ||||
-rw-r--r-- | library/python/ya.make | 2 |
8 files changed, 147 insertions, 147 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 |