aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/binsaver/ut
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/binsaver/ut
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/binsaver/ut')
-rw-r--r--library/cpp/binsaver/ut/binsaver_ut.cpp158
1 files changed, 79 insertions, 79 deletions
diff --git a/library/cpp/binsaver/ut/binsaver_ut.cpp b/library/cpp/binsaver/ut/binsaver_ut.cpp
index 37eba5406f..e4237e0875 100644
--- a/library/cpp/binsaver/ut/binsaver_ut.cpp
+++ b/library/cpp/binsaver/ut/binsaver_ut.cpp
@@ -27,14 +27,14 @@ struct TCustomOuterSerializer {
TString StrData;
};
-void operator&(TCustomOuterSerializer& s, IBinSaver& f);
+void operator&(TCustomOuterSerializer& s, IBinSaver& f);
struct TCustomOuterSerializerTmpl {
ui32 Data = 0;
TString StrData;
};
-struct TCustomOuterSerializerTmplDerived: public TCustomOuterSerializerTmpl {
+struct TCustomOuterSerializerTmplDerived: public TCustomOuterSerializerTmpl {
ui32 Data = 0;
TString StrData;
};
@@ -45,7 +45,7 @@ struct TMoveOnlyType {
TMoveOnlyType() = default;
TMoveOnlyType(TMoveOnlyType&&) = default;
- bool operator==(const TMoveOnlyType& obj) const {
+ bool operator==(const TMoveOnlyType& obj) const {
return Data == obj.Data;
}
};
@@ -55,13 +55,13 @@ struct TTypeWithArray {
TString Array[2][2]{{"test", "data"}, {"and", "more"}};
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]);
+ 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);
+template <typename T, typename = std::enable_if_t<std::is_base_of<TCustomOuterSerializerTmpl, T>::value>>
+int operator&(T& s, IBinSaver& f);
static bool operator==(const TBlob& l, const TBlob& r) {
return TStringBuf(l.AsCharPtr(), l.Size()) == TStringBuf(r.AsCharPtr(), r.Size());
@@ -69,45 +69,45 @@ static bool operator==(const TBlob& l, const TBlob& r) {
Y_UNIT_TEST_SUITE(BinSaver){
Y_UNIT_TEST(HasTrivialSerializer){
- UNIT_ASSERT(!IBinSaver::HasNonTrivialSerializer<TBinarySerializable>(0u));
-UNIT_ASSERT(!IBinSaver::HasNonTrivialSerializer<TNonBinarySerializable>(0u));
-UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomSerializer>(0u));
-UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomOuterSerializer>(0u));
-UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomOuterSerializerTmpl>(0u));
-UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomOuterSerializerTmplDerived>(0u));
-UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TVector<TCustomSerializer>>(0u));
-}
+ UNIT_ASSERT(!IBinSaver::HasNonTrivialSerializer<TBinarySerializable>(0u));
+UNIT_ASSERT(!IBinSaver::HasNonTrivialSerializer<TNonBinarySerializable>(0u));
+UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomSerializer>(0u));
+UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomOuterSerializer>(0u));
+UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomOuterSerializerTmpl>(0u));
+UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomOuterSerializerTmplDerived>(0u));
+UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TVector<TCustomSerializer>>(0u));
+}
Y_UNIT_TEST(TestStroka) {
TestBinSaverSerialization(TString("QWERTY"));
-}
+}
Y_UNIT_TEST(TestMoveOnlyType) {
TestBinSaverSerializationToBuffer(TMoveOnlyType());
-}
+}
Y_UNIT_TEST(TestVectorStrok) {
TestBinSaverSerialization(TVector<TString>{"A", "B", "C"});
-}
+}
Y_UNIT_TEST(TestCArray) {
TestBinSaverSerialization(TTypeWithArray());
-}
+}
Y_UNIT_TEST(TestSets) {
TestBinSaverSerialization(THashSet<TString>{"A", "B", "C"});
TestBinSaverSerialization(TSet<TString>{"A", "B", "C"});
-}
+}
Y_UNIT_TEST(TestMaps) {
TestBinSaverSerialization(THashMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}});
TestBinSaverSerialization(TMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}});
-}
+}
Y_UNIT_TEST(TestBlob) {
TestBinSaverSerialization(TBlob::FromStringSingleThreaded("qwerty"));
-}
+}
Y_UNIT_TEST(TestVariant) {
{
@@ -126,73 +126,73 @@ Y_UNIT_TEST(TestVariant) {
}
Y_UNIT_TEST(TestPod) {
- struct TPod {
- ui32 A = 5;
- ui64 B = 7;
- bool operator==(const TPod& other) const {
- return A == other.A && B == other.B;
- }
- };
+ struct TPod {
+ ui32 A = 5;
+ ui64 B = 7;
+ bool operator==(const TPod& other) const {
+ return A == other.A && B == other.B;
+ }
+ };
TestBinSaverSerialization(TPod());
- TPod custom;
- custom.A = 25;
- custom.B = 37;
+ TPod custom;
+ custom.A = 25;
+ custom.B = 37;
TestBinSaverSerialization(custom);
TestBinSaverSerialization(TVector<TPod>{custom});
-}
+}
Y_UNIT_TEST(TestSubPod) {
- struct TPod {
- struct TSub {
- ui32 X = 10;
- bool operator==(const TSub& other) const {
- return X == other.X;
+ struct TPod {
+ struct TSub {
+ ui32 X = 10;
+ bool operator==(const TSub& other) const {
+ return X == other.X;
}
};
- TVector<TSub> B;
- int operator&(IBinSaver& f) {
- f.Add(0, &B);
- return 0;
- }
- bool operator==(const TPod& other) const {
- return B == other.B;
- }
- };
+ TVector<TSub> B;
+ int operator&(IBinSaver& f) {
+ f.Add(0, &B);
+ return 0;
+ }
+ bool operator==(const TPod& other) const {
+ return B == other.B;
+ }
+ };
TestBinSaverSerialization(TPod());
- TPod::TSub sub;
- sub.X = 1;
- TPod custom;
- custom.B = {sub};
+ TPod::TSub sub;
+ sub.X = 1;
+ TPod custom;
+ custom.B = {sub};
TestBinSaverSerialization(TVector<TPod>{custom});
-}
+}
Y_UNIT_TEST(TestMemberAndOpIsMain) {
- struct TBase {
- TString S;
- virtual int operator&(IBinSaver& f) {
- f.Add(0, &S);
- return 0;
- }
- virtual ~TBase() = default;
- };
-
- struct TDerived: public TBase {
- int A = 0;
- int operator&(IBinSaver& f)override {
- f.Add(0, static_cast<TBase*>(this));
- f.Add(0, &A);
- return 0;
- }
- bool operator==(const TDerived& other) const {
- return A == other.A && S == other.S;
- }
- };
-
- TDerived obj;
- obj.S = "TString";
- obj.A = 42;
+ struct TBase {
+ TString S;
+ virtual int operator&(IBinSaver& f) {
+ f.Add(0, &S);
+ return 0;
+ }
+ virtual ~TBase() = default;
+ };
+
+ struct TDerived: public TBase {
+ int A = 0;
+ int operator&(IBinSaver& f)override {
+ f.Add(0, static_cast<TBase*>(this));
+ f.Add(0, &A);
+ return 0;
+ }
+ bool operator==(const TDerived& other) const {
+ return A == other.A && S == other.S;
+ }
+ };
+
+ TDerived obj;
+ obj.S = "TString";
+ obj.A = 42;
TestBinSaverSerialization(obj);
-}
-}
-;
+}
+}
+;