diff options
author | tkhanipov <tkhanipov@yandex-team.ru> | 2022-02-10 16:49:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:46 +0300 |
commit | 60c0dade397b9b2f9a22f5daa5b2ea5e433e6e40 (patch) | |
tree | 4acdda76eaabc40a9ee1a272dc41f7a3862409ec | |
parent | a27ec9dbf04ab9972fd470b53b8bdd41153226e5 (diff) | |
download | ydb-60c0dade397b9b2f9a22f5daa5b2ea5e433e6e40.tar.gz |
Restoring authorship annotation for <tkhanipov@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | library/cpp/http/io/stream.cpp | 16 | ||||
-rw-r--r-- | library/cpp/http/io/stream.h | 12 | ||||
-rw-r--r-- | library/cpp/http/io/stream_ut_medium.cpp | 4 | ||||
-rw-r--r-- | library/cpp/http/io/ut/medium/ya.make | 6 | ||||
-rw-r--r-- | library/cpp/testing/unittest/registar.h | 112 | ||||
-rw-r--r-- | library/cpp/testing/unittest/registar_ut.cpp | 34 | ||||
-rw-r--r-- | util/generic/yexception.h | 26 |
7 files changed, 105 insertions, 105 deletions
diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp index 6689be684f..f96ef5b1b2 100644 --- a/library/cpp/http/io/stream.cpp +++ b/library/cpp/http/io/stream.cpp @@ -619,10 +619,10 @@ public: return SupportChunkedTransfer() && IsKeepAliveEnabled() && (Request_ ? Request_->IsKeepAlive() : true); } - inline const TString& FirstLine() const noexcept { - return FirstLine_; - } - + inline const TString& FirstLine() const noexcept { + return FirstLine_; + } + inline size_t SentSize() const noexcept { return SizeCalculator_.Length(); } @@ -958,10 +958,10 @@ void THttpOutput::SendContinue() { Impl_->SendContinue(); } -const TString& THttpOutput::FirstLine() const noexcept { - return Impl_->FirstLine(); -} - +const TString& THttpOutput::FirstLine() const noexcept { + return Impl_->FirstLine(); +} + size_t THttpOutput::SentSize() const noexcept { return Impl_->SentSize(); } diff --git a/library/cpp/http/io/stream.h b/library/cpp/http/io/stream.h index 78ca4fc814..9b4c4c25f5 100644 --- a/library/cpp/http/io/stream.h +++ b/library/cpp/http/io/stream.h @@ -147,12 +147,12 @@ public: void SendContinue(); - /* - * first line - response or request - */ - /// Возвращает первую строку HTTP-запроса/ответа - const TString& FirstLine() const noexcept; - + /* + * first line - response or request + */ + /// Возвращает первую строку HTTP-запроса/ответа + const TString& FirstLine() const noexcept; + /// Возвращает размер отправленных данных (без заголовков, с учётом сжатия, без /// учёта chunked transfer encoding) size_t SentSize() const noexcept; diff --git a/library/cpp/http/io/stream_ut_medium.cpp b/library/cpp/http/io/stream_ut_medium.cpp index 2c125eb21e..8bcf1207c4 100644 --- a/library/cpp/http/io/stream_ut_medium.cpp +++ b/library/cpp/http/io/stream_ut_medium.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/stream/zlib.h> -Y_UNIT_TEST_SUITE(THttpTestMedium) { +Y_UNIT_TEST_SUITE(THttpTestMedium) { Y_UNIT_TEST(TestCodings2) { TStringBuf data = "aaaaaaaaaaaaaaaaaaaaaaa"; @@ -51,4 +51,4 @@ Y_UNIT_TEST_SUITE(THttpTestMedium) { } } -} // THttpTestMedium suite +} // THttpTestMedium suite diff --git a/library/cpp/http/io/ut/medium/ya.make b/library/cpp/http/io/ut/medium/ya.make index 235a23dcd7..9addf90942 100644 --- a/library/cpp/http/io/ut/medium/ya.make +++ b/library/cpp/http/io/ut/medium/ya.make @@ -1,11 +1,11 @@ UNITTEST_FOR(library/cpp/http/io) -SIZE(MEDIUM) - +SIZE(MEDIUM) + OWNER(g:util) SRCS( - stream_ut_medium.cpp + stream_ut_medium.cpp ) END() diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index 44517a0092..743c3ff091 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -563,68 +563,68 @@ public: \ #define UNIT_CHECK_GENERATED_NO_EXCEPTION(A, E) UNIT_CHECK_GENERATED_NO_EXCEPTION_C(A, E, "and exception message is:\n" << CurrentExceptionMessage()) -// Same as UNIT_ASSERT_EXCEPTION_SATISFIES but prints additional string C when nothing was thrown -#define UNIT_ASSERT_EXCEPTION_SATISFIES_C(A, E, pred, C) \ - do { \ - bool _thrown = false; \ - try { \ - (void)(A); \ - } catch (const ::NUnitTest::TAssertException&) { \ - throw; \ - } catch (const E& e) { \ - _thrown = true; \ - UNIT_ASSERT_C(pred(e), "Exception does not satisfy predicate '" \ - << #pred << "'"); \ - } catch (...) { \ - _thrown = true; \ - UNIT_FAIL_IMPL("exception assertion failed", \ - #A << " did not throw " << #E \ - << ", but threw other exception " \ - << "with message:\n" \ - << CurrentExceptionMessage()); \ - } \ - if (!_thrown) { \ - UNIT_FAIL_IMPL("exception assertion failed", \ - #A << " did not throw any exception" \ - << " (expected " << #E << ") " << C); \ - } \ +// Same as UNIT_ASSERT_EXCEPTION_SATISFIES but prints additional string C when nothing was thrown +#define UNIT_ASSERT_EXCEPTION_SATISFIES_C(A, E, pred, C) \ + do { \ + bool _thrown = false; \ + try { \ + (void)(A); \ + } catch (const ::NUnitTest::TAssertException&) { \ + throw; \ + } catch (const E& e) { \ + _thrown = true; \ + UNIT_ASSERT_C(pred(e), "Exception does not satisfy predicate '" \ + << #pred << "'"); \ + } catch (...) { \ + _thrown = true; \ + UNIT_FAIL_IMPL("exception assertion failed", \ + #A << " did not throw " << #E \ + << ", but threw other exception " \ + << "with message:\n" \ + << CurrentExceptionMessage()); \ + } \ + if (!_thrown) { \ + UNIT_FAIL_IMPL("exception assertion failed", \ + #A << " did not throw any exception" \ + << " (expected " << #E << ") " << C); \ + } \ } while (false) -// Assert that a specific exception is thrown and satisfies predicate pred(e), where e is the exception instance. -// Example: -// UNIT_ASSERT_EXCEPTION_SATISFIES(MakeRequest(invalidData), TError, -// [](const TError& e){ return e.Status == HTTP_BAD_REQUEST; }) -// This code validates that MakeRequest with invalidData throws TError with code 400. -#define UNIT_ASSERT_EXCEPTION_SATISFIES(A, E, pred) \ - UNIT_ASSERT_EXCEPTION_SATISFIES_C(A, E, pred, "") - -// Same as UNIT_ASSERT_EXCEPTION_CONTAINS but prints additional string C when nothing was thrown -#define UNIT_ASSERT_EXCEPTION_CONTAINS_C(A, E, substr, C) \ - do { \ - const TString _substr{substr}; \ - UNIT_ASSERT_EXCEPTION_SATISFIES_C(A, E, \ - [&_substr](const E&){ \ - if (!_substr.empty()) { \ - UNIT_ASSERT_C(CurrentExceptionMessage() \ - .Contains(_substr), \ - "Exception message does not contain \"" \ - << _substr << "\".\n" \ - << "Exception message: " \ - << CurrentExceptionMessage()); \ - } \ - return true; \ - }, \ - C); \ - } while (false) - -// Assert that a specific exception is thrown and CurrentExceptionMessage() contains substr +// Assert that a specific exception is thrown and satisfies predicate pred(e), where e is the exception instance. +// Example: +// UNIT_ASSERT_EXCEPTION_SATISFIES(MakeRequest(invalidData), TError, +// [](const TError& e){ return e.Status == HTTP_BAD_REQUEST; }) +// This code validates that MakeRequest with invalidData throws TError with code 400. +#define UNIT_ASSERT_EXCEPTION_SATISFIES(A, E, pred) \ + UNIT_ASSERT_EXCEPTION_SATISFIES_C(A, E, pred, "") + +// Same as UNIT_ASSERT_EXCEPTION_CONTAINS but prints additional string C when nothing was thrown +#define UNIT_ASSERT_EXCEPTION_CONTAINS_C(A, E, substr, C) \ + do { \ + const TString _substr{substr}; \ + UNIT_ASSERT_EXCEPTION_SATISFIES_C(A, E, \ + [&_substr](const E&){ \ + if (!_substr.empty()) { \ + UNIT_ASSERT_C(CurrentExceptionMessage() \ + .Contains(_substr), \ + "Exception message does not contain \"" \ + << _substr << "\".\n" \ + << "Exception message: " \ + << CurrentExceptionMessage()); \ + } \ + return true; \ + }, \ + C); \ + } while (false) + +// Assert that a specific exception is thrown and CurrentExceptionMessage() contains substr #define UNIT_ASSERT_EXCEPTION_CONTAINS(A, E, substr) \ UNIT_ASSERT_EXCEPTION_CONTAINS_C(A, E, substr, "") -// Same as UNIT_ASSERT_EXCEPTION but prints additional string C when nothing was thrown -#define UNIT_ASSERT_EXCEPTION_C(A, E, C) UNIT_ASSERT_EXCEPTION_SATISFIES_C(A, E, [](const E&){ return true; }, C) +// Same as UNIT_ASSERT_EXCEPTION but prints additional string C when nothing was thrown +#define UNIT_ASSERT_EXCEPTION_C(A, E, C) UNIT_ASSERT_EXCEPTION_SATISFIES_C(A, E, [](const E&){ return true; }, C) -// Assert that a specific exception is thrown +// Assert that a specific exception is thrown #define UNIT_ASSERT_EXCEPTION(A, E) UNIT_ASSERT_EXCEPTION_C(A, E, "") #define UNIT_ASSERT_NO_EXCEPTION_RESULT_C(A, C) \ diff --git a/library/cpp/testing/unittest/registar_ut.cpp b/library/cpp/testing/unittest/registar_ut.cpp index 1f36d53abb..81827e7571 100644 --- a/library/cpp/testing/unittest/registar_ut.cpp +++ b/library/cpp/testing/unittest/registar_ut.cpp @@ -301,15 +301,15 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_EXCEPTION_CONTAINS(Throw(), TExpectedException, substr); } - template <class TExpectedException, class P> - void AssertExceptionSatisfies(const P& predicate) { - UNIT_ASSERT_EXCEPTION_SATISFIES(Throw(), TExpectedException, predicate); - } - - int GetValue() const { - return 5; // just some value for predicate testing - } - + template <class TExpectedException, class P> + void AssertExceptionSatisfies(const P& predicate) { + UNIT_ASSERT_EXCEPTION_SATISFIES(Throw(), TExpectedException, predicate); + } + + int GetValue() const { + return 5; // just some value for predicate testing + } + bool ThrowMe; }; @@ -362,12 +362,12 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) { UNIT_ASSERT_EXCEPTION_CONTAINS(TTestException("abc").Throw(), TTestException, "a"); } - - Y_UNIT_TEST(ExceptionSatisfies) { - const auto goodPredicate = [](const TTestException& e) { return e.GetValue() == 5; }; - const auto badPredicate = [](const TTestException& e) { return e.GetValue() != 5; }; - UNIT_ASSERT_NO_EXCEPTION(TTestException().AssertExceptionSatisfies<TTestException>(goodPredicate)); - UNIT_ASSERT_TEST_FAILS(TTestException().AssertExceptionSatisfies<TTestException>(badPredicate)); - UNIT_ASSERT_TEST_FAILS(TTestException().AssertExceptionSatisfies<TOtherTestException>(goodPredicate)); - } + + Y_UNIT_TEST(ExceptionSatisfies) { + const auto goodPredicate = [](const TTestException& e) { return e.GetValue() == 5; }; + const auto badPredicate = [](const TTestException& e) { return e.GetValue() != 5; }; + UNIT_ASSERT_NO_EXCEPTION(TTestException().AssertExceptionSatisfies<TTestException>(goodPredicate)); + UNIT_ASSERT_TEST_FAILS(TTestException().AssertExceptionSatisfies<TTestException>(badPredicate)); + UNIT_ASSERT_TEST_FAILS(TTestException().AssertExceptionSatisfies<TOtherTestException>(goodPredicate)); + } } diff --git a/util/generic/yexception.h b/util/generic/yexception.h index b0c604e8c4..6e8c247cc7 100644 --- a/util/generic/yexception.h +++ b/util/generic/yexception.h @@ -121,23 +121,23 @@ class TFileError: public TIoSystemError { /** * TBadArgumentException should be thrown when an argument supplied to some function (or constructor) - * is invalid or incorrect. - * - * \note - * A special case when such argument is given to a function which performs type casting - * (e.g. integer from string) is covered by the TBadCastException class which is derived from - * TBadArgumentException. - */ -struct TBadArgumentException: public virtual yexception { + * is invalid or incorrect. + * + * \note + * A special case when such argument is given to a function which performs type casting + * (e.g. integer from string) is covered by the TBadCastException class which is derived from + * TBadArgumentException. + */ +struct TBadArgumentException: public virtual yexception { }; /** * TBadCastException should be thrown to indicate the failure of some type casting procedure - * (e.g. reading an integer parameter from string). - */ -struct TBadCastException: public virtual TBadArgumentException { -}; - + * (e.g. reading an integer parameter from string). + */ +struct TBadCastException: public virtual TBadArgumentException { +}; + #define ythrow throw __LOCATION__ + namespace NPrivate { |