diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:23 +0300 |
commit | 706b83ed7de5a473436620367af31fc0ceecde07 (patch) | |
tree | 103305d30dec77e8f6367753367f59b3cd68f9f1 /library/cpp/scheme | |
parent | 918e8a1574070d0ec733f0b76cfad8f8892ad2e5 (diff) | |
download | ydb-706b83ed7de5a473436620367af31fc0ceecde07.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/scheme')
-rw-r--r-- | library/cpp/scheme/domscheme_traits.h | 6 | ||||
-rw-r--r-- | library/cpp/scheme/scheme.cpp | 4 | ||||
-rw-r--r-- | library/cpp/scheme/scheme.h | 10 | ||||
-rw-r--r-- | library/cpp/scheme/scheme_cast.h | 60 | ||||
-rw-r--r-- | library/cpp/scheme/scimpl.h | 2 | ||||
-rw-r--r-- | library/cpp/scheme/scimpl_defs.h | 8 | ||||
-rw-r--r-- | library/cpp/scheme/scimpl_json_read.cpp | 8 | ||||
-rw-r--r-- | library/cpp/scheme/scimpl_json_write.cpp | 6 | ||||
-rw-r--r-- | library/cpp/scheme/scimpl_private.cpp | 4 | ||||
-rw-r--r-- | library/cpp/scheme/scimpl_private.h | 6 | ||||
-rw-r--r-- | library/cpp/scheme/scimpl_protobuf.cpp | 12 | ||||
-rw-r--r-- | library/cpp/scheme/scimpl_select.rl6 | 4 | ||||
-rw-r--r-- | library/cpp/scheme/tests/ut/scheme_cast_ut.cpp | 32 | ||||
-rw-r--r-- | library/cpp/scheme/tests/ut/scheme_json_ut.cpp | 4 | ||||
-rw-r--r-- | library/cpp/scheme/tests/ut/scheme_path_ut.cpp | 20 | ||||
-rw-r--r-- | library/cpp/scheme/tests/ut/scheme_proto_ut.cpp | 2 | ||||
-rw-r--r-- | library/cpp/scheme/tests/ut/scheme_ut.cpp | 40 | ||||
-rw-r--r-- | library/cpp/scheme/ut_utils/scheme_ut_utils.h | 10 |
18 files changed, 119 insertions, 119 deletions
diff --git a/library/cpp/scheme/domscheme_traits.h b/library/cpp/scheme/domscheme_traits.h index a11c4dd444..3d6e92e803 100644 --- a/library/cpp/scheme/domscheme_traits.h +++ b/library/cpp/scheme/domscheme_traits.h @@ -7,7 +7,7 @@ struct TSchemeTraits { using TValue = NSc::TValue; using TValueRef = TValue*; using TConstValueRef = const TValue*; - using TStringType = TStringBuf; + using TStringType = TStringBuf; // anyvalue defaults template <class T> @@ -213,8 +213,8 @@ struct TSchemeTraits { } // validation ops - static inline TVector<TString> GetKeys(TConstValueRef v) { - TVector<TString> res; + static inline TVector<TString> GetKeys(TConstValueRef v) { + TVector<TString> res; for (const auto& key : v->DictKeys(true)) { res.push_back(ToString(key)); } diff --git a/library/cpp/scheme/scheme.cpp b/library/cpp/scheme/scheme.cpp index 3efd116d4f..cade561ed4 100644 --- a/library/cpp/scheme/scheme.cpp +++ b/library/cpp/scheme/scheme.cpp @@ -128,7 +128,7 @@ namespace NSc { return deflt; } - TString TValue::ForceString(const TString& deflt) const { + TString TValue::ForceString(const TString& deflt) const { const TScCore& core = Core(); if (core.IsString()) { return ToString(core.GetString(TStringBuf())); @@ -584,7 +584,7 @@ namespace NSc { LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(double, CompareFloat) LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(TStringBuf, CompareStr) - LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(const TString&, CompareStr) + LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(const TString&, CompareStr) LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(const char* const, CompareStr) #undef LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL diff --git a/library/cpp/scheme/scheme.h b/library/cpp/scheme/scheme.h index 3d7c59f3c9..8d32fd88d5 100644 --- a/library/cpp/scheme/scheme.h +++ b/library/cpp/scheme/scheme.h @@ -176,7 +176,7 @@ namespace NSc { inline TValue& SetString(TStringBuf val = TStringBuf()); // returns self - TString ForceString(const TString& deflt = TString()) const; // Best-effort cast to TString (will do ToString for numeric types) + TString ForceString(const TString& deflt = TString()) const; // Best-effort cast to TString (will do ToString for numeric types) // todo: remove inline bool StringEmpty() const; @@ -301,11 +301,11 @@ namespace NSc { static bool FromJson(TValue&, TStringBuf, const TJsonOpts& = TJsonOpts()); // TODO: Переименовать ToJson в ToJsonUnsafe, а ToJsonSafe в ToJson - TString ToJson(const TJsonOpts& = TJsonOpts()) const; + TString ToJson(const TJsonOpts& = TJsonOpts()) const; const TValue& ToJson(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; // returns self // ToJson(JO_SORT_KEYS | JO_SKIP_UNSAFE) - TString ToJsonSafe(const TJsonOpts& = TJsonOpts()) const; + TString ToJsonSafe(const TJsonOpts& = TJsonOpts()) const; const TValue& ToJsonSafe(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; // ToJson(JO_SORT_KEYS | JO_PRETTY | JO_SKIP_UNSAFE) @@ -354,7 +354,7 @@ namespace NSc { // TODO: add throwing variants // make sure to properly escape the tokens - static TString EscapeForPath(TStringBuf rawKey); // converts a raw dict key into a valid token for a selector path + static TString EscapeForPath(TStringBuf rawKey); // converts a raw dict key into a valid token for a selector path static bool PathValid(TStringBuf path); // returns true if the path is syntactically valid @@ -514,7 +514,7 @@ namespace NSc { // todo: allow insertions // todo: make TDict methods safe class TDict: public THashMap<TStringBuf, TValue, THash<TStringBuf>, TEqualTo<TStringBuf>, TPoolAllocator>, TNonCopyable { - using TParent = THashMap<TStringBuf, TValue, THash<TStringBuf>, TEqualTo<TStringBuf>, TPoolAllocator>; + using TParent = THashMap<TStringBuf, TValue, THash<TStringBuf>, TEqualTo<TStringBuf>, TPoolAllocator>; public: TDict(TMemoryPool* p) diff --git a/library/cpp/scheme/scheme_cast.h b/library/cpp/scheme/scheme_cast.h index 00839e8017..4ab215a0be 100644 --- a/library/cpp/scheme/scheme_cast.h +++ b/library/cpp/scheme/scheme_cast.h @@ -31,35 +31,35 @@ namespace NJsonConverters { // fwd declarations ////////////////////////////////////////////////////////////////////// - //TVector + //TVector template <typename T, typename A> - NSc::TValue ToTValue(const TVector<T, A>& x); + NSc::TValue ToTValue(const TVector<T, A>& x); template <typename T, typename A> - void FromTValue(const NSc::TValue& x, TVector<T, A>& out, const bool validate); + void FromTValue(const NSc::TValue& x, TVector<T, A>& out, const bool validate); - //THashMap + //THashMap template <class Key, class T, class HashFcn, class EqualKey, class Alloc> - NSc::TValue ToTValue(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& x); + NSc::TValue ToTValue(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& x); template <class Key, class T, class HashFcn, class EqualKey, class Alloc> - void FromTValue(const NSc::TValue& x, THashMap<Key, T, HashFcn, EqualKey, Alloc>& out, const bool validate); + void FromTValue(const NSc::TValue& x, THashMap<Key, T, HashFcn, EqualKey, Alloc>& out, const bool validate); - //TMap + //TMap template <class K, class V, class Less, class A> - NSc::TValue ToTValue(const TMap<K, V, Less, A>& x); + NSc::TValue ToTValue(const TMap<K, V, Less, A>& x); template <class K, class V, class Less, class A> - void FromTValue(const NSc::TValue& x, TMap<K, V, Less, A>& out, const bool validate); + void FromTValue(const NSc::TValue& x, TMap<K, V, Less, A>& out, const bool validate); - //THashSet + //THashSet template <class V, class H, class E, class A> - NSc::TValue ToTValue(const THashSet<V, H, E, A>& x); + NSc::TValue ToTValue(const THashSet<V, H, E, A>& x); template <class V, class H, class E, class A> - void FromTValue(const NSc::TValue& x, THashSet<V, H, E, A>& out, const bool validate); + void FromTValue(const NSc::TValue& x, THashSet<V, H, E, A>& out, const bool validate); - //TSet + //TSet template <class K, class L, class A> - NSc::TValue ToTValue(const TSet<K, L, A>& x); + NSc::TValue ToTValue(const TSet<K, L, A>& x); template <class K, class L, class A> - void FromTValue(const NSc::TValue& x, TSet<K, L, A>& out, const bool validate); + void FromTValue(const NSc::TValue& x, TSet<K, L, A>& out, const bool validate); //std::pair template <class T1, class T2> @@ -83,7 +83,7 @@ namespace NJsonConverters { out = x; } - static TString ToString(const T& x) { + static TString ToString(const T& x) { return ::ToString(x); } @@ -102,7 +102,7 @@ namespace NJsonConverters { out.FromTValue(x, validate); } - static TString ToString(const T& x) { + static TString ToString(const T& x) { return x.ToJson(); } @@ -129,7 +129,7 @@ namespace NJsonConverters { } template <typename T> - TString ToString(const T& x) { + TString ToString(const T& x) { return TValueAndStrokaConv<T, std::is_base_of<IJsonSerializable, T>::value>::ToString(x); } @@ -204,16 +204,16 @@ namespace NJsonConverters { // TVector ////////////////////////////////////////////////////////////////////// template <typename T, typename A> - NSc::TValue ToTValue(const TVector<T, A>& x) { + NSc::TValue ToTValue(const TVector<T, A>& x) { NSc::TValue out; out.SetArray(); - for (typename TVector<T, A>::const_iterator it = x.begin(); it != x.end(); ++it) + for (typename TVector<T, A>::const_iterator it = x.begin(); it != x.end(); ++it) out.Push(NJsonConverters::ToTValue(*it)); return out; } template <typename T, typename A> - void FromTValue(const NSc::TValue& x, TVector<T, A>& out, const bool validate) { + void FromTValue(const NSc::TValue& x, TVector<T, A>& out, const bool validate) { if (validate) Y_ENSURE(x.IsArray() || x.IsNull(), "not valid input scheme"); out.clear(); @@ -232,22 +232,22 @@ namespace NJsonConverters { // THashMap & TMap ////////////////////////////////////////////////////////////////////// template <class Key, class T, class HashFcn, class EqualKey, class Alloc> - NSc::TValue ToTValue(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& x) { + NSc::TValue ToTValue(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& x) { return NPrivate::ToTValueDict(x); } template <class Key, class T, class HashFcn, class EqualKey, class Alloc> - void FromTValue(const NSc::TValue& x, THashMap<Key, T, HashFcn, EqualKey, Alloc>& out, const bool validate) { + void FromTValue(const NSc::TValue& x, THashMap<Key, T, HashFcn, EqualKey, Alloc>& out, const bool validate) { NPrivate::FromTValueDict(x, out, validate); } template <class K, class V, class Less, class A> - NSc::TValue ToTValue(const TMap<K, V, Less, A>& x) { + NSc::TValue ToTValue(const TMap<K, V, Less, A>& x) { return NPrivate::ToTValueDict(x); } template <class K, class V, class Less, class A> - void FromTValue(const NSc::TValue& x, TMap<K, V, Less, A>& out, const bool validate) { + void FromTValue(const NSc::TValue& x, TMap<K, V, Less, A>& out, const bool validate) { NPrivate::FromTValueDict(x, out, validate); } @@ -255,22 +255,22 @@ namespace NJsonConverters { // THashSet & TSet ////////////////////////////////////////////////////////////////////// template <class V, class H, class E, class A> - NSc::TValue ToTValue(const THashSet<V, H, E, A>& x) { + NSc::TValue ToTValue(const THashSet<V, H, E, A>& x) { return NPrivate::ToTValueSet(x); } template <class V, class H, class E, class A> - void FromTValue(const NSc::TValue& x, THashSet<V, H, E, A>& out, const bool validate) { + void FromTValue(const NSc::TValue& x, THashSet<V, H, E, A>& out, const bool validate) { NPrivate::FromTValueSet(x, out, validate); } template <class K, class L, class A> - NSc::TValue ToTValue(const TSet<K, L, A>& x) { + NSc::TValue ToTValue(const TSet<K, L, A>& x) { return NPrivate::ToTValueSet(x); } template <class K, class L, class A> - void FromTValue(const NSc::TValue& x, TSet<K, L, A>& out, const bool validate) { + void FromTValue(const NSc::TValue& x, TSet<K, L, A>& out, const bool validate) { NPrivate::FromTValueSet(x, out, validate); } @@ -307,7 +307,7 @@ namespace NJsonConverters { // global user functions ////////////////////////////////////////////////////////////////////// template <typename T> - TString ToJson(const T& val, const bool sort = false) { + TString ToJson(const T& val, const bool sort = false) { return NJsonConverters::ToTValue(val).ToJson(sort); } diff --git a/library/cpp/scheme/scimpl.h b/library/cpp/scheme/scimpl.h index 4f68f16290..984f4076e5 100644 --- a/library/cpp/scheme/scimpl.h +++ b/library/cpp/scheme/scimpl.h @@ -849,7 +849,7 @@ namespace NSc { LIBRARY_SCHEME_DECLARE_TVALUE_OPS(double, CompareFloat) LIBRARY_SCHEME_DECLARE_TVALUE_OPS(TStringBuf, CompareStr) - LIBRARY_SCHEME_DECLARE_TVALUE_OPS(const TString&, CompareStr) + LIBRARY_SCHEME_DECLARE_TVALUE_OPS(const TString&, CompareStr) LIBRARY_SCHEME_DECLARE_TVALUE_OPS(const char* const, CompareStr) #undef LIBRARY_SCHEME_DECLARE_TVALUE_OPS diff --git a/library/cpp/scheme/scimpl_defs.h b/library/cpp/scheme/scimpl_defs.h index f3dd66b437..638488c6b6 100644 --- a/library/cpp/scheme/scimpl_defs.h +++ b/library/cpp/scheme/scimpl_defs.h @@ -10,7 +10,7 @@ #include <util/generic/hash.h> #include <util/generic/ptr.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <functional> #include <util/string/vector.h> @@ -43,7 +43,7 @@ namespace NSc { }; } - using TStringBufs = TVector<TStringBuf>; + using TStringBufs = TVector<TStringBuf>; class TSchemeException : public yexception { }; @@ -51,12 +51,12 @@ namespace NSc { class TSchemeParseException : public TSchemeException { public: size_t Offset = 0; - TString Reason; + TString Reason; public: TSchemeParseException() = default; - TSchemeParseException(size_t off, const TString& reason) + TSchemeParseException(size_t off, const TString& reason) : Offset(off) , Reason(reason) { diff --git a/library/cpp/scheme/scimpl_json_read.cpp b/library/cpp/scheme/scimpl_json_read.cpp index 8a29cc7739..12b7625200 100644 --- a/library/cpp/scheme/scimpl_json_read.cpp +++ b/library/cpp/scheme/scimpl_json_read.cpp @@ -7,7 +7,7 @@ namespace NSc { struct TJsonError { size_t Offset = 0; - TMaybe<TString> Reason; + TMaybe<TString> Reason; }; struct TJsonDeserializer : NJson::TJsonCallbacks { @@ -57,14 +57,14 @@ namespace NSc { } }; - typedef TVector<TContainer> TStackType; + typedef TVector<TContainer> TStackType; public: TValue& Root; TJsonError& Error; const TJsonOpts& Cfg; - TStackType Stack; + TStackType Stack; bool Virgin = true; public: @@ -213,7 +213,7 @@ namespace NSc { return res; } - TString reason = err.Reason.Empty() ? "NULL" : *err.Reason; + TString reason = err.Reason.Empty() ? "NULL" : *err.Reason; ythrow TSchemeParseException(err.Offset, reason) << "JSON error at offset " << err.Offset << " (" << reason << ")"; } diff --git a/library/cpp/scheme/scimpl_json_write.cpp b/library/cpp/scheme/scimpl_json_write.cpp index aadd7e6cd5..60026e8d09 100644 --- a/library/cpp/scheme/scimpl_json_write.cpp +++ b/library/cpp/scheme/scimpl_json_write.cpp @@ -154,8 +154,8 @@ namespace NSc { return *this; } - TString TValue::ToJson(const TJsonOpts& jopts) const { - TString s; + TString TValue::ToJson(const TJsonOpts& jopts) const { + TString s; { TStringOutput out(s); ToJson(out, jopts); @@ -175,7 +175,7 @@ namespace NSc { return MakeOptsSafeForSerializer(opts); } - TString TValue::ToJsonSafe(const TJsonOpts& jopts) const { + TString TValue::ToJsonSafe(const TJsonOpts& jopts) const { return ToJson(MakeOptsSafeForSerializer(jopts)); } diff --git a/library/cpp/scheme/scimpl_private.cpp b/library/cpp/scheme/scimpl_private.cpp index 024bf8cc3b..51323d3e3c 100644 --- a/library/cpp/scheme/scimpl_private.cpp +++ b/library/cpp/scheme/scimpl_private.cpp @@ -22,7 +22,7 @@ namespace NSc { }; template <typename TAction, typename TElement, typename TColl> - static inline void PutToVector(TVector<TElement>& vector, TColl& coll) { + static inline void PutToVector(TVector<TElement>& vector, TColl& coll) { size_t i = vector.size(); vector.resize(vector.size() + coll.size()); @@ -61,7 +61,7 @@ namespace NSc { Y_FAIL("REFERENCE LOOP DETECTED"); break; case EMode::Stderr: - Cerr << "REFERENCE LOOP DETECTED: " << JoinStrings(Vector.begin(), Vector.end(), ", ") + Cerr << "REFERENCE LOOP DETECTED: " << JoinStrings(Vector.begin(), Vector.end(), ", ") << " AND " << ToString((const void*)&self) << Endl; break; } diff --git a/library/cpp/scheme/scimpl_private.h b/library/cpp/scheme/scimpl_private.h index b92badabde..aadc56a58c 100644 --- a/library/cpp/scheme/scimpl_private.h +++ b/library/cpp/scheme/scimpl_private.h @@ -15,7 +15,7 @@ namespace NSc { class TContextGuard : TNonCopyable { using TElement = typename TContext::TElement; using TTarget = typename TContext::TTarget; - using TVectorType = TVector<TElement>; + using TVectorType = TVector<TElement>; public: TContextGuard(TContext& ctx, TTarget& target) @@ -35,7 +35,7 @@ namespace NSc { } } - const TVectorType& GetVector() const { + const TVectorType& GetVector() const { return Ctx.Vector; } @@ -68,7 +68,7 @@ namespace NSc { Vector.reserve(64); } - TVector<TElement> Vector; + TVector<TElement> Vector; }; class TKeySortContext: public TBasicContext<TStringBuf, const TDict> { diff --git a/library/cpp/scheme/scimpl_protobuf.cpp b/library/cpp/scheme/scimpl_protobuf.cpp index 0c99122c69..f640118a5a 100644 --- a/library/cpp/scheme/scimpl_protobuf.cpp +++ b/library/cpp/scheme/scimpl_protobuf.cpp @@ -13,12 +13,12 @@ namespace NSc { TValue TValue::From(const Message& msg, bool mapAsDict) { TValue v; const Reflection* r = msg.GetReflection(); - TVector<const FieldDescriptor*> fields; - TVector<const FieldDescriptor*>::iterator it; - int i1; + TVector<const FieldDescriptor*> fields; + TVector<const FieldDescriptor*>::iterator it; + int i1; r->ListFields(msg, &fields); - for (it = fields.begin(), i1 = 0; it != fields.end(); ++it, ++i1) { + for (it = fields.begin(), i1 = 0; it != fields.end(); ++it, ++i1) { const FieldDescriptor* field = *it; try { if (field->is_repeated()) { @@ -154,7 +154,7 @@ namespace NSc { } void TValue::ValueToField(const TValue& value, Message& msg, const FieldDescriptor* field, const TProtoOpts& opts) const { - const TString& name = field->name(); + const TString& name = field->name(); if (value.IsNull()) { if (field->is_required() && !field->has_default_value()) { ythrow TSchemeException() << "has no value for required field " << name; @@ -233,7 +233,7 @@ namespace NSc { } void TValue::ToRepeatedField(Message& msg, const FieldDescriptor* field, const TProtoOpts& opts) const { - const TString& name = field->name(); + const TString& name = field->name(); const TValue& fieldValue = Get(name); if (fieldValue.IsNull()) { diff --git a/library/cpp/scheme/scimpl_select.rl6 b/library/cpp/scheme/scimpl_select.rl6 index 11aa549b78..a7dbbfdf81 100644 --- a/library/cpp/scheme/scimpl_select.rl6 +++ b/library/cpp/scheme/scimpl_select.rl6 @@ -54,7 +54,7 @@ namespace NSc { template <typename TSelector> struct TSelectorCtx { TSelector Selector; - TString Buffer; + TString Buffer; const char* p0 = nullptr; const char* p = nullptr; @@ -252,7 +252,7 @@ namespace NSc { return ctx.SelectPath() || !ctx.Selector.HasError; } - TString TValue::EscapeForPath(TStringBuf rawKey) { + TString TValue::EscapeForPath(TStringBuf rawKey) { static const str_spn danger{"/[]"}; if (!rawKey || danger.brk(rawKey.begin(), rawKey.end()) != rawKey.end()) { return NEscJ::EscapeJ<true>(rawKey); diff --git a/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp b/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp index 4f907157e9..7f9101eff4 100644 --- a/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp @@ -9,11 +9,11 @@ using namespace NJsonConverters; -using TVI = TVector<int>; -using THI = THashMap<int, int>; -using TMI = TMap<int, int>; -using THSI = THashSet<int>; -using TSI = TSet<int>; +using TVI = TVector<int>; +using THI = THashMap<int, int>; +using TMI = TMap<int, int>; +using THSI = THashSet<int>; +using TSI = TSet<int>; using TPI = std::pair<int, int>; Y_UNIT_TEST_SUITE(TSchemeCastTest) { @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { for (int i = 0; i < 3; ++i) h[i] = i * i; - const TString etalon = "{\"0\":0,\"1\":1,\"2\":4}"; + const TString etalon = "{\"0\":0,\"1\":1,\"2\":4}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true)); THI h2(FromJson<THI>(ToJson(h))); @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { for (int i = 0; i < 3; ++i) h[i] = i * i; - const TString etalon = "{\"0\":0,\"1\":1,\"2\":4}"; + const TString etalon = "{\"0\":0,\"1\":1,\"2\":4}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true)); TMI h2(FromJson<TMI>(ToJson(h))); @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { for (int i = 0; i < 3; ++i) h.insert(i * i); - const TString etalon = "{\"0\":null,\"1\":null,\"4\":null}"; + const TString etalon = "{\"0\":null,\"1\":null,\"4\":null}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true)); THSI h2(FromJson<THSI>(ToJson(h))); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { for (int i = 0; i < 3; ++i) h.insert(i * i); - const TString etalon = "{\"0\":null,\"1\":null,\"4\":null}"; + const TString etalon = "{\"0\":null,\"1\":null,\"4\":null}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true)); TSI h2(FromJson<TSI>(ToJson(h))); @@ -80,7 +80,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { Y_UNIT_TEST(TestTPair) { TPI p(1, 1); - const TString etalon = "[1,1]"; + const TString etalon = "[1,1]"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(p, true)); TPI p2(FromJson<TPI>(ToJson(p))); @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { Y_UNIT_TEST(TestTCustom) { TCustom x(2, 3); - const TString etalon = "{\"a\":2,\"b\":3}"; + const TString etalon = "{\"a\":2,\"b\":3}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(x, true)); TCustom x2(FromJson<TCustom>(ToJson(x))); @@ -124,13 +124,13 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { } Y_UNIT_TEST(TestVectorOfPairs) { - typedef TVector<TPI> TVPI; + typedef TVector<TPI> TVPI; TVPI v; for (int i = 0; i < 3; ++i) v.push_back(TPI(i, i * i)); - const TString etalon = "[[0,0],[1,1],[2,4]]"; + const TString etalon = "[[0,0],[1,1],[2,4]]"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(v, true)); TVPI v2(FromJson<TVPI>(ToJson(v))); @@ -138,11 +138,11 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { } Y_UNIT_TEST(TestSetOfCustom) { - typedef TSet<TCustom> TSC; + typedef TSet<TCustom> TSC; TSC s; s.insert(TCustom(2, 3)); - const TString etalon = "{\"{\\\"a\\\":2,\\\"b\\\":3}\":null}"; + const TString etalon = "{\"{\\\"a\\\":2,\\\"b\\\":3}\":null}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(s, true)); TSC s2(FromJson<TSC>(ToJson(s))); @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { Y_UNIT_TEST(TestExceptions) { NSc::TValue v = 1; - const TString json = v.ToJson(); + const TString json = v.ToJson(); UNIT_ASSERT_EXCEPTION(FromJson<TVI>(json, true), yexception); UNIT_ASSERT_EXCEPTION(FromJson<THI>(json, true), yexception); UNIT_ASSERT_EXCEPTION(FromJson<TMI>(json, true), yexception); diff --git a/library/cpp/scheme/tests/ut/scheme_json_ut.cpp b/library/cpp/scheme/tests/ut/scheme_json_ut.cpp index daeb2654f9..7b248299d6 100644 --- a/library/cpp/scheme/tests/ut/scheme_json_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_json_ut.cpp @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TSchemeJsonTest) { } Y_UNIT_TEST(TestSafeJson) { - TString ss; + TString ss; ss.reserve(256); for (int i = 0; i < 256; ++i) { @@ -114,7 +114,7 @@ Y_UNIT_TEST_SUITE(TSchemeJsonTest) { { NSc::TValue value; - TString articleName{"\xC2\xC2\xCF"}; + TString articleName{"\xC2\xC2\xCF"}; value["text"] = articleName; UNIT_ASSERT_VALUES_EQUAL(value.ToJson(), "{\"text\":\"\xC2\xC2\xCF\"}"); UNIT_ASSERT_VALUES_EQUAL(value.ToJsonSafe(), "{\"text\":null}"); diff --git a/library/cpp/scheme/tests/ut/scheme_path_ut.cpp b/library/cpp/scheme/tests/ut/scheme_path_ut.cpp index 0d4d79d483..7b95f02d13 100644 --- a/library/cpp/scheme/tests/ut/scheme_path_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_path_ut.cpp @@ -98,61 +98,61 @@ Y_UNIT_TEST_SUITE(TSchemePathTest) { { NSc::TValue val; *val.TrySelectOrAdd("") = 100; - const TString res = R"=(100)="; + const TString res = R"=(100)="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd("a") = 100; - const TString res = R"=({"a":100})="; + const TString res = R"=({"a":100})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=(////)=") = 100; - const TString res = R"=(100)="; + const TString res = R"=(100)="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=()=") = 100; - const TString res = R"=(100)="; + const TString res = R"=(100)="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=("")=") = 100; - const TString res = R"=({"":100})="; + const TString res = R"=({"":100})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=("[1]")=") = 100; - const TString res = R"=({"[1]":100})="; + const TString res = R"=({"[1]":100})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=("\"\"")=") = 100; - const TString res = R"=({"\"\"":100})="; + const TString res = R"=({"\"\"":100})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=("/10/")=") = 100; - const TString res = R"=({"/10/":100})="; + const TString res = R"=({"/10/":100})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=(/"[10]"//""/"\"/10/\""///)=") = 100; - const TString res = R"=({"[10]":{"":{"\"/10/\"":100}}})="; + const TString res = R"=({"[10]":{"":{"\"/10/\"":100}}})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=(/"[10]"//""/"\"/10/\""///)=") = 100; - const TString res = R"=({"[10]":{"":{"\"/10/\"":100}}})="; + const TString res = R"=({"[10]":{"":{"\"/10/\"":100}}})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } } diff --git a/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp b/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp index e711a0d092..db8d13b978 100644 --- a/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp @@ -213,7 +213,7 @@ Y_UNIT_TEST_SUITE(TSchemeProtoTest) { NSc::TMessage proto; v.To(proto); - TString differentPath; + TString differentPath; UNIT_ASSERT_C(NProtoBuf::IsEqual(m, proto, &differentPath), differentPath); } } diff --git a/library/cpp/scheme/tests/ut/scheme_ut.cpp b/library/cpp/scheme/tests/ut/scheme_ut.cpp index 1a5d07c31b..290ebd6c04 100644 --- a/library/cpp/scheme/tests/ut/scheme_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_ut.cpp @@ -241,7 +241,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { Y_UNIT_TEST(TestAssignments) { for (int i = -2; i < 3; ++i) { - TString ii = ToString(i); + TString ii = ToString(i); int iless = i - 1; int imore = i + 1; DoCheckAssignmentNum<signed char>(i, iless, imore, ii, "schar"); @@ -262,7 +262,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { // DoCheckAssignment<bool>(false, false, false, "false", "bool"); for (int i = 1; i < 3; ++i) { - TString ii = ToString(i); + TString ii = ToString(i); int iless = i - 1; int imore = i + 1; @@ -292,9 +292,9 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { DoCheckAssignmentNum<double>(i, iless, imore, ii, "double"); } - TString uuu = "uuu"; - TString uua = "uua"; - TString uuz = "uuz"; + TString uuu = "uuu"; + TString uua = "uua"; + TString uuz = "uuz"; DoCheckAssignment<char*>(uuu.begin(), uua.begin(), uuz.begin(), "\"uuu\"", "char*"); DoCheckAssignment<const char*>("www", "wwa", "wwz", "\"www\"", "const char*"); DoCheckAssignmentArr("xxx", "xxa", "xxz", "\"xxx\"", "const char[]"); @@ -303,7 +303,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { #if defined(_MSC_VER) //TODO #else - DoCheckAssignment<TString>("ttt", "tta", "ttz", "\"ttt\"", "TString"); + DoCheckAssignment<TString>("ttt", "tta", "ttz", "\"ttt\"", "TString"); #endif NSc::TValue v; @@ -358,12 +358,12 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { v.AppendAll(d); UNIT_ASSERT_VALUES_EQUAL(v.ToJson(), R"(["a","b","c","d",1,2,3,4,5,6])"); UNIT_ASSERT_VALUES_EQUAL(d.size(), 3u); - TVector<TStringBuf> s{"x", "y", "z"}; + TVector<TStringBuf> s{"x", "y", "z"}; v.AppendAll(s.begin(), s.end()); UNIT_ASSERT_VALUES_EQUAL(v.ToJson(), R"(["a","b","c","d",1,2,3,4,5,6,"x","y","z"])"); UNIT_ASSERT_VALUES_EQUAL(v.Clone().Clear().AppendAll(s).ToJson(), R"(["x","y","z"])"); - UNIT_ASSERT_VALUES_EQUAL(v.Clone().Clear().AppendAll(TVector<TStringBuf>()).ToJson(), R"([])"); + UNIT_ASSERT_VALUES_EQUAL(v.Clone().Clear().AppendAll(TVector<TStringBuf>()).ToJson(), R"([])"); v.AddAll({{"a", "b"}, {"c", "d"}}); UNIT_ASSERT_VALUES_EQUAL(v.ToJson(), R"({"a":"b","c":"d"})"); @@ -421,10 +421,10 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { NSc::TValue va = NSc::TValue::FromJson("[ x, y]"); NSc::TValue vs = NSc::TValue::FromJson("foo"); NSc::TValue vn = NSc::TValue::FromJson("1"); - TString sd = "{\"a\":1,\"b\":\"c\"}"; - TString sa = "[\"x\",\"y\"]"; - TString ss = "\"foo\""; - TString sn = "1"; + TString sd = "{\"a\":1,\"b\":\"c\"}"; + TString sa = "[\"x\",\"y\"]"; + TString ss = "\"foo\""; + TString sn = "1"; UNIT_ASSERT_VALUES_EQUAL(sd, vd.ToJson(true)); UNIT_ASSERT_VALUES_EQUAL(sa, va.ToJson(true)); UNIT_ASSERT_VALUES_EQUAL(ss, vs.ToJson(true)); @@ -781,7 +781,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { Y_UNIT_TEST(TestCopyFrom) { { - TString sa = "[1,2]"; + TString sa = "[1,2]"; const NSc::TValue& va = NSc::TValue::FromJson(sa); NSc::TValue vb = va; vb.CopyFrom(va); @@ -789,7 +789,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } { - TString sa = "[1,2]"; + TString sa = "[1,2]"; NSc::TValue va = NSc::TValue::FromJson(sa); NSc::TValue vb = va; vb.CopyFrom(va); @@ -797,7 +797,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } { - TString sa = "[1,2]"; + TString sa = "[1,2]"; NSc::TValue va = NSc::TValue::FromJson(sa); const NSc::TValue& vb = va; va.CopyFrom(vb); @@ -805,7 +805,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } { - TString sa = "[1,2]"; + TString sa = "[1,2]"; NSc::TValue va = NSc::TValue::FromJson(sa); NSc::TValue vb = va; va.CopyFrom(vb); @@ -816,7 +816,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { NSc::TValue va = NSc::TValue::FromJson("{\"x\":\"ab\",\"y\":{\"p\":\"cd\",\"q\":\"ef\"}}"); NSc::TValue vb = va.Get("y"); va.CopyFrom(vb); - TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; + TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; UNIT_ASSERT_VALUES_EQUAL(va.ToJson(), sa); UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } @@ -824,14 +824,14 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { NSc::TValue va = NSc::TValue::FromJson("{\"x\":\"ab\",\"y\":{\"p\":\"cd\",\"q\":\"ef\"}}"); const NSc::TValue& vb = va.Get("y"); va.CopyFrom(vb); - TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; + TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; UNIT_ASSERT_VALUES_EQUAL(va.ToJson(), sa); } { NSc::TValue va = NSc::TValue::FromJson("{\"x\":\"ab\",\"y\":{\"p\":\"cd\",\"q\":\"ef\"}}"); NSc::TValue vb = va.Get("y"); va = vb; - TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; + TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; UNIT_ASSERT_VALUES_EQUAL(va.ToJson(), sa); UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } @@ -839,7 +839,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { NSc::TValue va = NSc::TValue::FromJson("{\"x\":\"ab\",\"y\":{\"p\":\"cd\",\"q\":\"ef\"}}"); const NSc::TValue& vb = va.Get("y"); va = vb; - TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; + TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; UNIT_ASSERT_VALUES_EQUAL(va.ToJson(), sa); UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } diff --git a/library/cpp/scheme/ut_utils/scheme_ut_utils.h b/library/cpp/scheme/ut_utils/scheme_ut_utils.h index eb3ea15b2a..a22583432b 100644 --- a/library/cpp/scheme/ut_utils/scheme_ut_utils.h +++ b/library/cpp/scheme/ut_utils/scheme_ut_utils.h @@ -11,16 +11,16 @@ namespace NSc { namespace NUt { TValue AssertFromJson(TStringBuf json); - inline TString NormalizeJson(const NSc::TValue& sc) { + inline TString NormalizeJson(const NSc::TValue& sc) { return sc.ToJson(true); } - inline TString NormalizeJson(const NJson::TJsonValue& sc) { + inline TString NormalizeJson(const NJson::TJsonValue& sc) { return NJson::WriteJson(sc, false, true, false); } template <class TStr> - inline TString NormalizeJson(const TStr& val) { + inline TString NormalizeJson(const TStr& val) { return AssertFromJson(val).ToJson(true); } @@ -38,12 +38,12 @@ namespace NSc { #define UNIT_ASSERT_JSON_EQ_JSON(A, B) UNIT_ASSERT_JSON_EQ_JSON_C(A, B, "") - inline TString DumpJson(const TValue& json) { + inline TString DumpJson(const TValue& json) { return NJson::CompactifyJson(json.ToJson(true), true, true); } // deprecated - inline TString DumpJsonVS(const TValue& expected, const TValue& fact) { + inline TString DumpJsonVS(const TValue& expected, const TValue& fact) { return DumpJson(expected) + "(expected) != (fact)" + DumpJson(fact); } |