diff options
| author | paxakor <[email protected]> | 2022-02-10 16:47:32 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:47:32 +0300 | 
| commit | 40d35c046ee3a61ee2a581f42499c5ce56ac589a (patch) | |
| tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp | |
| parent | 7fdbed62e54b804e2c12b86a2c2bab12f61065df (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
| -rw-r--r-- | library/cpp/deprecated/mapped_file/mapped_file.cpp | 6 | ||||
| -rw-r--r-- | library/cpp/deprecated/mapped_file/mapped_file.h | 14 | ||||
| -rw-r--r-- | library/cpp/deprecated/mapped_file/ya.make | 16 | ||||
| -rw-r--r-- | library/cpp/deprecated/split/delim_string_iter.cpp | 16 | ||||
| -rw-r--r-- | library/cpp/deprecated/split/delim_string_iter.h | 50 | ||||
| -rw-r--r-- | library/cpp/deprecated/split/delim_string_iter_ut.cpp | 10 | ||||
| -rw-r--r-- | library/cpp/deprecated/split/split_iterator.h | 4 | ||||
| -rw-r--r-- | library/cpp/deprecated/split/split_iterator_ut.cpp | 72 | ||||
| -rw-r--r-- | library/cpp/deprecated/ya.make | 8 | ||||
| -rw-r--r-- | library/cpp/messagebus/config/session_config.cpp | 2 | ||||
| -rw-r--r-- | library/cpp/protobuf/interop/cast.cpp | 38 | ||||
| -rw-r--r-- | library/cpp/protobuf/interop/cast.h | 30 | ||||
| -rw-r--r-- | library/cpp/protobuf/interop/ut/cast_ut.cpp | 96 | ||||
| -rw-r--r-- | library/cpp/protobuf/interop/ut/ya.make | 26 | ||||
| -rw-r--r-- | library/cpp/protobuf/interop/ya.make | 30 | 
15 files changed, 209 insertions, 209 deletions
diff --git a/library/cpp/deprecated/mapped_file/mapped_file.cpp b/library/cpp/deprecated/mapped_file/mapped_file.cpp index 6e0e0123398..b0e4511299b 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.cpp +++ b/library/cpp/deprecated/mapped_file/mapped_file.cpp @@ -1,9 +1,9 @@ -#include "mapped_file.h"  +#include "mapped_file.h"  #include <util/generic/yexception.h> -#include <util/system/defaults.h>  +#include <util/system/defaults.h>  #include <util/system/hi_lo.h> -#include <util/system/filemap.h>  +#include <util/system/filemap.h>  TMappedFile::TMappedFile(TFileMap* map, const char* dbgName) {      Map_ = map; diff --git a/library/cpp/deprecated/mapped_file/mapped_file.h b/library/cpp/deprecated/mapped_file/mapped_file.h index 0e29b74f2c6..45859ed65a0 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.h +++ b/library/cpp/deprecated/mapped_file/mapped_file.h @@ -1,16 +1,16 @@  #pragma once -#include <util/generic/flags.h>  +#include <util/generic/flags.h>  #include <util/generic/ptr.h> -#include <util/generic/string.h>  +#include <util/generic/string.h>  #include <util/generic/utility.h>  #include <util/generic/yexception.h> -#include <util/system/align.h>  -#include <util/system/file.h>  -#include <util/system/filemap.h>  -#include <util/system/yassert.h>  +#include <util/system/align.h> +#include <util/system/file.h> +#include <util/system/filemap.h> +#include <util/system/yassert.h> -#include <cstdio>  +#include <cstdio>  #include <new>  /// Deprecated (by pg@), use TFileMap or TMemoryMap instead diff --git a/library/cpp/deprecated/mapped_file/ya.make b/library/cpp/deprecated/mapped_file/ya.make index a84d9589901..415c4383823 100644 --- a/library/cpp/deprecated/mapped_file/ya.make +++ b/library/cpp/deprecated/mapped_file/ya.make @@ -1,9 +1,9 @@ -LIBRARY()  -  +LIBRARY() +  OWNER(g:util) -  -SRCS(  -    mapped_file.cpp  -)  -  -END()  + +SRCS( +    mapped_file.cpp +) + +END() diff --git a/library/cpp/deprecated/split/delim_string_iter.cpp b/library/cpp/deprecated/split/delim_string_iter.cpp index f1f43ccc2ed..af418c5bfb9 100644 --- a/library/cpp/deprecated/split/delim_string_iter.cpp +++ b/library/cpp/deprecated/split/delim_string_iter.cpp @@ -1,10 +1,10 @@ -#include "delim_string_iter.h"  +#include "delim_string_iter.h"  // -// TKeyValueDelimStringIter  +// TKeyValueDelimStringIter  // -void TKeyValueDelimStringIter::ReadKeyAndValue() {  +void TKeyValueDelimStringIter::ReadKeyAndValue() {      TStringBuf currentToken(*DelimIter);      size_t pos = currentToken.find('='); @@ -17,18 +17,18 @@ void TKeyValueDelimStringIter::ReadKeyAndValue() {      }  } -TKeyValueDelimStringIter::TKeyValueDelimStringIter(const TStringBuf str, const TStringBuf delim)  +TKeyValueDelimStringIter::TKeyValueDelimStringIter(const TStringBuf str, const TStringBuf delim)      : DelimIter(str, delim)  {      if (DelimIter.Valid())          ReadKeyAndValue();  } -bool TKeyValueDelimStringIter::Valid() const {  +bool TKeyValueDelimStringIter::Valid() const {      return DelimIter.Valid();  } -TKeyValueDelimStringIter& TKeyValueDelimStringIter::operator++() {  +TKeyValueDelimStringIter& TKeyValueDelimStringIter::operator++() {      ++DelimIter;      if (DelimIter.Valid())          ReadKeyAndValue(); @@ -36,10 +36,10 @@ TKeyValueDelimStringIter& TKeyValueDelimStringIter::operator++() {      return *this;  } -const TStringBuf& TKeyValueDelimStringIter::Key() const {  +const TStringBuf& TKeyValueDelimStringIter::Key() const {      return ChunkKey;  } -const TStringBuf& TKeyValueDelimStringIter::Value() const {  +const TStringBuf& TKeyValueDelimStringIter::Value() const {      return ChunkValue;  } diff --git a/library/cpp/deprecated/split/delim_string_iter.h b/library/cpp/deprecated/split/delim_string_iter.h index 030caaf7806..8e4ca171a09 100644 --- a/library/cpp/deprecated/split/delim_string_iter.h +++ b/library/cpp/deprecated/split/delim_string_iter.h @@ -8,7 +8,7 @@  #include <iterator> -class TDelimStringIter {  +class TDelimStringIter {  public:      using value_type = TStringBuf;      using difference_type = ptrdiff_t; @@ -16,12 +16,12 @@ public:      using reference = const TStringBuf&;      using iterator_category = std::forward_iterator_tag; -    inline TDelimStringIter(const char* begin, const char* strEnd, TStringBuf delim)  -        : TDelimStringIter(TStringBuf(begin, strEnd), delim)  +    inline TDelimStringIter(const char* begin, const char* strEnd, TStringBuf delim) +        : TDelimStringIter(TStringBuf(begin, strEnd), delim)      {      } -    inline TDelimStringIter(TStringBuf str, TStringBuf delim)  +    inline TDelimStringIter(TStringBuf str, TStringBuf delim)          : IsValid(true)          , Str(str)          , Delim(delim) @@ -29,7 +29,7 @@ public:          UpdateCurrent();      } -    inline TDelimStringIter()  +    inline TDelimStringIter()          : IsValid(false)      {      } @@ -39,7 +39,7 @@ public:      }      // NOTE: this is a potentially unsafe operation (no overrun check) -    inline TDelimStringIter& operator++() {  +    inline TDelimStringIter& operator++() {          if (Current.end() != Str.end()) {              Str.Skip(Current.length() + Delim.length());              UpdateCurrent(); @@ -57,11 +57,11 @@ public:          }      } -    inline bool operator==(const TDelimStringIter& rhs) const {  +    inline bool operator==(const TDelimStringIter& rhs) const {          return (IsValid == rhs.IsValid) && (!IsValid || (Current.begin() == rhs.Current.begin()));      } -    inline bool operator!=(const TDelimStringIter& rhs) const {  +    inline bool operator!=(const TDelimStringIter& rhs) const {          return !(*this == rhs);      } @@ -86,7 +86,7 @@ public:      }      template <class T> -    inline TDelimStringIter& Next(T& t) // Get & advance  +    inline TDelimStringIter& Next(T& t) // Get & advance      {          if (!TryNext(t))              ythrow yexception() << "No valid field"; @@ -117,8 +117,8 @@ public:          return Str.SubStr(Current.length() + Delim.length());      } -    inline TDelimStringIter IterEnd() const {  -        return TDelimStringIter();  +    inline TDelimStringIter IterEnd() const { +        return TDelimStringIter();      }  private: @@ -147,37 +147,37 @@ struct TDelimStroka {      {      } -    inline TDelimStringIter begin() const {  -        return TDelimStringIter(S, Delim);  +    inline TDelimStringIter begin() const { +        return TDelimStringIter(S, Delim);      } -    inline TDelimStringIter end() const {  -        return TDelimStringIter();  +    inline TDelimStringIter end() const { +        return TDelimStringIter();      }  }; -inline TDelimStringIter begin_delim(const TString& str, TStringBuf delim) {  -    return TDelimStringIter(str, delim);  +inline TDelimStringIter begin_delim(const TString& str, TStringBuf delim) { +    return TDelimStringIter(str, delim);  } -inline TDelimStringIter begin_delim(TStringBuf str, TStringBuf delim) {  -    return TDelimStringIter(str.begin(), str.end(), delim);  +inline TDelimStringIter begin_delim(TStringBuf str, TStringBuf delim) { +    return TDelimStringIter(str.begin(), str.end(), delim);  } -inline TDelimStringIter end_delim(const TString& /*str*/, TStringBuf /*delim*/) {  -    return TDelimStringIter();  +inline TDelimStringIter end_delim(const TString& /*str*/, TStringBuf /*delim*/) { +    return TDelimStringIter();  } -class TKeyValueDelimStringIter {  +class TKeyValueDelimStringIter {  public: -    TKeyValueDelimStringIter(const TStringBuf str, const TStringBuf delim);  +    TKeyValueDelimStringIter(const TStringBuf str, const TStringBuf delim);      bool Valid() const; -    TKeyValueDelimStringIter& operator++();  +    TKeyValueDelimStringIter& operator++();      const TStringBuf& Key() const;      const TStringBuf& Value() const;  private: -    TDelimStringIter DelimIter;  +    TDelimStringIter DelimIter;      TStringBuf ChunkKey, ChunkValue;  private: diff --git a/library/cpp/deprecated/split/delim_string_iter_ut.cpp b/library/cpp/deprecated/split/delim_string_iter_ut.cpp index d3a966915ff..18a8b2a1604 100644 --- a/library/cpp/deprecated/split/delim_string_iter_ut.cpp +++ b/library/cpp/deprecated/split/delim_string_iter_ut.cpp @@ -1,10 +1,10 @@ -#include "delim_string_iter.h"  +#include "delim_string_iter.h"  #include <util/generic/vector.h>  #include <library/cpp/testing/unittest/registar.h> -/// Test that TDelimStringIter build on top of given string and delimeter will produce expected sequence  +/// Test that TDelimStringIter build on top of given string and delimeter will produce expected sequence  static void AssertStringSplit(const TString& str, const TString& delim, const TVector<TString>& expected) { -    TDelimStringIter it(str, delim);  +    TDelimStringIter it(str, delim);      // test iterator invariants      for (const auto& expectedString : expected) { @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) {      }      Y_UNIT_TEST(Cdr) { -        TDelimStringIter it("a\tc\t", "\t");  +        TDelimStringIter it("a\tc\t", "\t");          UNIT_ASSERT_STRINGS_EQUAL(*it, "a");          UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), "c\t");          ++it; @@ -55,7 +55,7 @@ static void AssertKeyValueStringSplit(      const TStringBuf str,      const TStringBuf delim,      const TVector<std::pair<TStringBuf, TStringBuf>>& expected) { -    TKeyValueDelimStringIter it(str, delim);  +    TKeyValueDelimStringIter it(str, delim);      for (const auto& expectedKeyValue : expected) {          UNIT_ASSERT(it.Valid()); diff --git a/library/cpp/deprecated/split/split_iterator.h b/library/cpp/deprecated/split/split_iterator.h index d6c0ab5fbc3..0eacc29228e 100644 --- a/library/cpp/deprecated/split/split_iterator.h +++ b/library/cpp/deprecated/split/split_iterator.h @@ -284,7 +284,7 @@ public:          return TStringBuf(Split.Str + region.Begin, region.End - region.Begin);      } -    const TString& NextString() {  +    const TString& NextString() {          if (!CurrentStroka)              CurrentStroka = new TString();          TSizeTRegion region = Next(); @@ -313,5 +313,5 @@ void Split(const TSplit& split, TSplitTokens* words) {      words->clear();      TSplitIterator<TSplit> it(split);      while (!it.Eof()) -        words->push_back(it.NextString());  +        words->push_back(it.NextString());  } diff --git a/library/cpp/deprecated/split/split_iterator_ut.cpp b/library/cpp/deprecated/split/split_iterator_ut.cpp index de8ddef925d..be5069c4be4 100644 --- a/library/cpp/deprecated/split/split_iterator_ut.cpp +++ b/library/cpp/deprecated/split/split_iterator_ut.cpp @@ -95,22 +95,22 @@ void TSplitIteratorTest::TestScreenedDelimitersSplit() {          const TSplitDelimiters screens("\"[]");          const TScreenedDelimitersSplit splitter(s, delims, screens);          TScreenedDelimitersSplit::TIterator it = splitter.Iterator(); -        UNIT_ASSERT_EQUAL(it.NextString(), "77.88.58.91");  -        UNIT_ASSERT_EQUAL(it.NextString(), "-");  -        UNIT_ASSERT_EQUAL(it.NextString(), "-");  -        UNIT_ASSERT_EQUAL(it.NextString(), "[28/Aug/2008:00:08:07 +0400]");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"GET /export/mordashka.tgz HTTP/1.1\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "304");  -        UNIT_ASSERT_EQUAL(it.NextString(), "-");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"libwww-perl/5.805\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"news.yandex.ru,80\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "1219867687");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"0\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "3283");  -        UNIT_ASSERT_EQUAL(it.NextString(), "2");  +        UNIT_ASSERT_EQUAL(it.NextString(), "77.88.58.91"); +        UNIT_ASSERT_EQUAL(it.NextString(), "-"); +        UNIT_ASSERT_EQUAL(it.NextString(), "-"); +        UNIT_ASSERT_EQUAL(it.NextString(), "[28/Aug/2008:00:08:07 +0400]"); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"GET /export/mordashka.tgz HTTP/1.1\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "304"); +        UNIT_ASSERT_EQUAL(it.NextString(), "-"); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"libwww-perl/5.805\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"news.yandex.ru,80\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "1219867687"); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"0\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "3283"); +        UNIT_ASSERT_EQUAL(it.NextString(), "2");      }      {          const TString s = "77.88.58.91 - - [28/Aug/2008:00:08:07 +0400] \"GET /export/mordashka.tgz HTTP/1.1\" 304 - \"-\" \"libwww-perl/5.805\" \"news.yandex.ru,80\" \"-\" \"-\" 1219867687 \"0\" 3283 2"; @@ -118,22 +118,22 @@ void TSplitIteratorTest::TestScreenedDelimitersSplit() {          const TSplitDelimiters screens("\"[]");          const TScreenedDelimitersSplit splitter(s.Data(), s.Size(), delims, screens);          TScreenedDelimitersSplit::TIterator it = splitter.Iterator(); -        UNIT_ASSERT_EQUAL(it.NextString(), "77.88.58.91");  -        UNIT_ASSERT_EQUAL(it.NextString(), "-");  -        UNIT_ASSERT_EQUAL(it.NextString(), "-");  -        UNIT_ASSERT_EQUAL(it.NextString(), "[28/Aug/2008:00:08:07 +0400]");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"GET /export/mordashka.tgz HTTP/1.1\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "304");  -        UNIT_ASSERT_EQUAL(it.NextString(), "-");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"libwww-perl/5.805\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"news.yandex.ru,80\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "1219867687");  -        UNIT_ASSERT_EQUAL(it.NextString(), "\"0\"");  -        UNIT_ASSERT_EQUAL(it.NextString(), "3283");  -        UNIT_ASSERT_EQUAL(it.NextString(), "2");  +        UNIT_ASSERT_EQUAL(it.NextString(), "77.88.58.91"); +        UNIT_ASSERT_EQUAL(it.NextString(), "-"); +        UNIT_ASSERT_EQUAL(it.NextString(), "-"); +        UNIT_ASSERT_EQUAL(it.NextString(), "[28/Aug/2008:00:08:07 +0400]"); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"GET /export/mordashka.tgz HTTP/1.1\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "304"); +        UNIT_ASSERT_EQUAL(it.NextString(), "-"); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"libwww-perl/5.805\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"news.yandex.ru,80\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"-\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "1219867687"); +        UNIT_ASSERT_EQUAL(it.NextString(), "\"0\""); +        UNIT_ASSERT_EQUAL(it.NextString(), "3283"); +        UNIT_ASSERT_EQUAL(it.NextString(), "2");      }  } @@ -142,10 +142,10 @@ void TSplitIteratorTest::TestSubstringDelimiter() {      static const TSubstringSplitDelimiter delimiter("@@");      const TSubstringSplit splitter(s, delimiter);      TSubstringSplit::TIterator it = splitter.Iterator(); -    UNIT_ASSERT_EQUAL(it.NextString(), "a");  -    UNIT_ASSERT_EQUAL(it.NextString(), "bb");  -    UNIT_ASSERT_EQUAL(it.NextString(), "[email protected]");  -    UNIT_ASSERT_EQUAL(it.NextString(), "r");  +    UNIT_ASSERT_EQUAL(it.NextString(), "a"); +    UNIT_ASSERT_EQUAL(it.NextString(), "bb"); +    UNIT_ASSERT_EQUAL(it.NextString(), "[email protected]"); +    UNIT_ASSERT_EQUAL(it.NextString(), "r");      UNIT_ASSERT(it.Eof());  } diff --git a/library/cpp/deprecated/ya.make b/library/cpp/deprecated/ya.make index a464905ee78..6c753f68a9b 100644 --- a/library/cpp/deprecated/ya.make +++ b/library/cpp/deprecated/ya.make @@ -12,16 +12,16 @@ RECURSE(      enum_codegen/ut      fgood      fgood/ut -    histogram  +    histogram      ipreg1      ipreg1/ut      ipreg1/ut_full      ipreg1/util -    iter  +    iter      kmp      kmp/ut -    mapped_file  -    mapped_file/ut  +    mapped_file +    mapped_file/ut      mbitmap      omni      text_norm diff --git a/library/cpp/messagebus/config/session_config.cpp b/library/cpp/messagebus/config/session_config.cpp index 6bc273b7547..fbbbb106c9d 100644 --- a/library/cpp/messagebus/config/session_config.cpp +++ b/library/cpp/messagebus/config/session_config.cpp @@ -32,7 +32,7 @@ static int ParseToSForMessageBus(const char* option) {      if (str.StartsWith("0x")) {          str = str.Tail(2);          Y_VERIFY(str.length() == 2, "ToS must be a number between 0x00 and 0xFF"); -        tos = String2Byte(str.data());  +        tos = String2Byte(str.data());      } else {          tos = FromString<int>(option);      } diff --git a/library/cpp/protobuf/interop/cast.cpp b/library/cpp/protobuf/interop/cast.cpp index 999b48a7cb9..c4cd59b417e 100644 --- a/library/cpp/protobuf/interop/cast.cpp +++ b/library/cpp/protobuf/interop/cast.cpp @@ -1,23 +1,23 @@  #include <library/cpp/protobuf/interop/cast.h> -  +  #include <google/protobuf/duration.pb.h>  #include <google/protobuf/timestamp.pb.h>  #include <google/protobuf/util/time_util.h> -  -namespace NProtoInterop {  -    google::protobuf::Duration CastToProto(TDuration duration) {  -        return google::protobuf::util::TimeUtil::MicrosecondsToDuration(duration.MicroSeconds());  -    }  -  -    google::protobuf::Timestamp CastToProto(TInstant instant) {  -        return google::protobuf::util::TimeUtil::MicrosecondsToTimestamp(instant.MicroSeconds());  -    }  -  -    TDuration CastFromProto(const google::protobuf::Duration& duration) {  -        return TDuration::MicroSeconds(google::protobuf::util::TimeUtil::DurationToMicroseconds(duration));  -    }  -  -    TInstant CastFromProto(const google::protobuf::Timestamp& timestamp) {  -        return TInstant::MicroSeconds(google::protobuf::util::TimeUtil::TimestampToMicroseconds(timestamp));  -    }  -}  + +namespace NProtoInterop { +    google::protobuf::Duration CastToProto(TDuration duration) { +        return google::protobuf::util::TimeUtil::MicrosecondsToDuration(duration.MicroSeconds()); +    } + +    google::protobuf::Timestamp CastToProto(TInstant instant) { +        return google::protobuf::util::TimeUtil::MicrosecondsToTimestamp(instant.MicroSeconds()); +    } + +    TDuration CastFromProto(const google::protobuf::Duration& duration) { +        return TDuration::MicroSeconds(google::protobuf::util::TimeUtil::DurationToMicroseconds(duration)); +    } + +    TInstant CastFromProto(const google::protobuf::Timestamp& timestamp) { +        return TInstant::MicroSeconds(google::protobuf::util::TimeUtil::TimestampToMicroseconds(timestamp)); +    } +} diff --git a/library/cpp/protobuf/interop/cast.h b/library/cpp/protobuf/interop/cast.h index 4d2bc52b923..b1c295236eb 100644 --- a/library/cpp/protobuf/interop/cast.h +++ b/library/cpp/protobuf/interop/cast.h @@ -1,15 +1,15 @@ -#pragma once  -  -#include <util/datetime/base.h>  -  -namespace google::protobuf {  -    class Duration;  -    class Timestamp;  -}  -  -namespace NProtoInterop {  -    google::protobuf::Duration CastToProto(TDuration duration);  -    google::protobuf::Timestamp CastToProto(TInstant instant);  -    TDuration CastFromProto(const google::protobuf::Duration& message);  -    TInstant CastFromProto(const google::protobuf::Timestamp& message);  -}  +#pragma once + +#include <util/datetime/base.h> + +namespace google::protobuf { +    class Duration; +    class Timestamp; +} + +namespace NProtoInterop { +    google::protobuf::Duration CastToProto(TDuration duration); +    google::protobuf::Timestamp CastToProto(TInstant instant); +    TDuration CastFromProto(const google::protobuf::Duration& message); +    TInstant CastFromProto(const google::protobuf::Timestamp& message); +} diff --git a/library/cpp/protobuf/interop/ut/cast_ut.cpp b/library/cpp/protobuf/interop/ut/cast_ut.cpp index 27bf79a6c47..6ef055b6512 100644 --- a/library/cpp/protobuf/interop/ut/cast_ut.cpp +++ b/library/cpp/protobuf/interop/ut/cast_ut.cpp @@ -1,52 +1,52 @@  #include <library/cpp/protobuf/interop/cast.h>  #include <library/cpp/testing/unittest/registar.h> -  +  #include <google/protobuf/duration.pb.h>  #include <google/protobuf/timestamp.pb.h> -  -static constexpr ui64 MicroSecondsInSecond = 1000 * 1000;  -static constexpr ui64 NanoSecondsInMicroSecond = 1000;  -  -Y_UNIT_TEST_SUITE(TCastTest) {  -    Y_UNIT_TEST(TimestampFromProto) {  -        const ui64 now = TInstant::Now().MicroSeconds();  -  -        google::protobuf::Timestamp timestamp;  -        timestamp.set_seconds(now / MicroSecondsInSecond);  -        timestamp.set_nanos((now % MicroSecondsInSecond) * NanoSecondsInMicroSecond);  -  -        const TInstant instant = NProtoInterop::CastFromProto(timestamp);  -        UNIT_ASSERT_EQUAL(instant.MicroSeconds(), now);  -    }  -  -    Y_UNIT_TEST(DurationFromProto) {  -        const ui64 now = TInstant::Now().MicroSeconds();  -  -        google::protobuf::Duration message;  -        message.set_seconds(now / MicroSecondsInSecond);  -        message.set_nanos((now % MicroSecondsInSecond) * NanoSecondsInMicroSecond);  -  -        const TDuration duration = NProtoInterop::CastFromProto(message);  -        UNIT_ASSERT_EQUAL(duration.MicroSeconds(), now);  -    }  -  -    Y_UNIT_TEST(TimestampToProto) {  -        const TInstant instant = TInstant::Now();  -  -        google::protobuf::Timestamp timestamp = NProtoInterop::CastToProto(instant);  -        const ui64 microSeconds = timestamp.seconds() * MicroSecondsInSecond +  -                                  timestamp.nanos() / NanoSecondsInMicroSecond;  -  -        UNIT_ASSERT_EQUAL(instant.MicroSeconds(), microSeconds);  -    }  -  -    Y_UNIT_TEST(DurationToProto) {  -        const TDuration duration = TDuration::Seconds(TInstant::Now().Seconds() / 2);  -  -        google::protobuf::Duration message = NProtoInterop::CastToProto(duration);  -        const ui64 microSeconds = message.seconds() * MicroSecondsInSecond +  -                                  message.nanos() / NanoSecondsInMicroSecond;  -  -        UNIT_ASSERT_EQUAL(duration.MicroSeconds(), microSeconds);  -    }  -}  + +static constexpr ui64 MicroSecondsInSecond = 1000 * 1000; +static constexpr ui64 NanoSecondsInMicroSecond = 1000; + +Y_UNIT_TEST_SUITE(TCastTest) { +    Y_UNIT_TEST(TimestampFromProto) { +        const ui64 now = TInstant::Now().MicroSeconds(); + +        google::protobuf::Timestamp timestamp; +        timestamp.set_seconds(now / MicroSecondsInSecond); +        timestamp.set_nanos((now % MicroSecondsInSecond) * NanoSecondsInMicroSecond); + +        const TInstant instant = NProtoInterop::CastFromProto(timestamp); +        UNIT_ASSERT_EQUAL(instant.MicroSeconds(), now); +    } + +    Y_UNIT_TEST(DurationFromProto) { +        const ui64 now = TInstant::Now().MicroSeconds(); + +        google::protobuf::Duration message; +        message.set_seconds(now / MicroSecondsInSecond); +        message.set_nanos((now % MicroSecondsInSecond) * NanoSecondsInMicroSecond); + +        const TDuration duration = NProtoInterop::CastFromProto(message); +        UNIT_ASSERT_EQUAL(duration.MicroSeconds(), now); +    } + +    Y_UNIT_TEST(TimestampToProto) { +        const TInstant instant = TInstant::Now(); + +        google::protobuf::Timestamp timestamp = NProtoInterop::CastToProto(instant); +        const ui64 microSeconds = timestamp.seconds() * MicroSecondsInSecond + +                                  timestamp.nanos() / NanoSecondsInMicroSecond; + +        UNIT_ASSERT_EQUAL(instant.MicroSeconds(), microSeconds); +    } + +    Y_UNIT_TEST(DurationToProto) { +        const TDuration duration = TDuration::Seconds(TInstant::Now().Seconds() / 2); + +        google::protobuf::Duration message = NProtoInterop::CastToProto(duration); +        const ui64 microSeconds = message.seconds() * MicroSecondsInSecond + +                                  message.nanos() / NanoSecondsInMicroSecond; + +        UNIT_ASSERT_EQUAL(duration.MicroSeconds(), microSeconds); +    } +} diff --git a/library/cpp/protobuf/interop/ut/ya.make b/library/cpp/protobuf/interop/ut/ya.make index ab8686bf112..b9c634cb6b3 100644 --- a/library/cpp/protobuf/interop/ut/ya.make +++ b/library/cpp/protobuf/interop/ut/ya.make @@ -1,15 +1,15 @@  UNITTEST_FOR(library/cpp/protobuf/interop) -  -OWNER(  -    paxakor  -)  -  -SRCS(  -    cast_ut.cpp  -)  -  -PEERDIR(  + +OWNER( +    paxakor +) + +SRCS( +    cast_ut.cpp +) + +PEERDIR(      library/cpp/protobuf/interop -)  -  -END()  +) + +END() diff --git a/library/cpp/protobuf/interop/ya.make b/library/cpp/protobuf/interop/ya.make index 0bba0b01461..618b5534597 100644 --- a/library/cpp/protobuf/interop/ya.make +++ b/library/cpp/protobuf/interop/ya.make @@ -1,15 +1,15 @@ -LIBRARY()  -  -OWNER(  -    paxakor  -)  -  -SRCS(  -    cast.cpp  -)  -  -PEERDIR(  -    contrib/libs/protobuf  -)  -  -END()  +LIBRARY() + +OWNER( +    paxakor +) + +SRCS( +    cast.cpp +) + +PEERDIR( +    contrib/libs/protobuf +) + +END()  | 
