aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordancingqueue <dancingqueue@yandex-team.ru>2022-02-10 16:50:06 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:06 +0300
commit3c712c7c680d2b93fae03957df9561bd08eb5b7c (patch)
tree67c4d640d22500fe4daafe7144095c91d77424b1
parent0ba74a57f9d49cfef11e512659c5847b98867342 (diff)
downloadydb-3c712c7c680d2b93fae03957df9561bd08eb5b7c.tar.gz
Restoring authorship annotation for <dancingqueue@yandex-team.ru>. Commit 1 of 2.
-rw-r--r--library/cpp/testing/gtest_extensions/gtest_extensions.h4
-rw-r--r--library/cpp/testing/gtest_extensions/ut/gtest_extensions_ut.cpp56
-rw-r--r--library/cpp/testing/gtest_extensions/ut/ya.make26
-rw-r--r--library/cpp/testing/gtest_extensions/ya.make32
-rw-r--r--util/generic/va_args.h36
-rwxr-xr-xutil/generic/va_args_gen.py74
-rw-r--r--util/generic/va_args_ut.cpp48
7 files changed, 138 insertions, 138 deletions
diff --git a/library/cpp/testing/gtest_extensions/gtest_extensions.h b/library/cpp/testing/gtest_extensions/gtest_extensions.h
index e20532241e..0859000800 100644
--- a/library/cpp/testing/gtest_extensions/gtest_extensions.h
+++ b/library/cpp/testing/gtest_extensions/gtest_extensions.h
@@ -1,5 +1,5 @@
-#pragma once
-
+#pragma once
+
#include "assertions.h"
#include "matchers.h"
#include "pretty_printers.h"
diff --git a/library/cpp/testing/gtest_extensions/ut/gtest_extensions_ut.cpp b/library/cpp/testing/gtest_extensions/ut/gtest_extensions_ut.cpp
index 81cdfd0427..4c1f48e593 100644
--- a/library/cpp/testing/gtest_extensions/ut/gtest_extensions_ut.cpp
+++ b/library/cpp/testing/gtest_extensions/ut/gtest_extensions_ut.cpp
@@ -1,49 +1,49 @@
#include <library/cpp/testing/gtest/gtest.h>
-
+
#include <util/generic/string.h>
#include <util/generic/maybe.h>
#include <util/stream/output.h>
#include <util/stream/str.h>
-
-namespace {
- class IMock {
- public:
- virtual void M1(const TStringBuf&) = 0;
- virtual void M2(TStringBuf) = 0;
- virtual void M3(const TString&) = 0;
- virtual void M4(TString) = 0;
- };
-
- class TSampleMock : IMock {
- public:
- MOCK_METHOD(void, M1, (const TStringBuf&));
- MOCK_METHOD(void, M2, (TStringBuf));
- MOCK_METHOD(void, M3, (const TString&));
- MOCK_METHOD(void, M4, (TString));
- };
-}
-
-
+
+namespace {
+ class IMock {
+ public:
+ virtual void M1(const TStringBuf&) = 0;
+ virtual void M2(TStringBuf) = 0;
+ virtual void M3(const TString&) = 0;
+ virtual void M4(TString) = 0;
+ };
+
+ class TSampleMock : IMock {
+ public:
+ MOCK_METHOD(void, M1, (const TStringBuf&));
+ MOCK_METHOD(void, M2, (TStringBuf));
+ MOCK_METHOD(void, M3, (const TString&));
+ MOCK_METHOD(void, M4, (TString));
+ };
+}
+
+
TEST(MatchersSpecializations, String) {
TSampleMock mock;
-
+
TStringBuf simpleStringBuf = "SimpleStringBuf";
const TStringBuf constSimpleStringBuf = "ConstSimpleStringBuf";
-
+
TString simpleString = "SimpleString";
const TString constSimpleString = "ConstSimpleString";
-
+
EXPECT_CALL(mock, M1("ConstSimpleStringBuf")).Times(1);
EXPECT_CALL(mock, M2("SimpleStringBuf")).Times(1);
EXPECT_CALL(mock, M3("ConstSimpleString")).Times(1);
EXPECT_CALL(mock, M4("SimpleString")).Times(1);
-
+
mock.M1(constSimpleStringBuf);
mock.M2(simpleStringBuf);
mock.M3(constSimpleString);
mock.M4(simpleString);
}
-
+
template <typename T, typename M>
std::pair<bool, std::string> Match(T&& t, M&& m) {
testing::StringMatchResultListener listener;
@@ -233,9 +233,9 @@ struct TThrowsOnMove {
TThrowsOnMove() = default;
TThrowsOnMove(TThrowsOnMove&&) {
ythrow yexception() << "move failed";
- }
+ }
};
-
+
TEST(PrettyPrinters, String) {
EXPECT_EQ(GtestPrint(TString("hello world")), "\"hello world\"");
EXPECT_EQ(GtestPrint(TStringBuf("hello world")), "\"hello world\"");
diff --git a/library/cpp/testing/gtest_extensions/ut/ya.make b/library/cpp/testing/gtest_extensions/ut/ya.make
index 39b41cecfd..58df6b0dcb 100644
--- a/library/cpp/testing/gtest_extensions/ut/ya.make
+++ b/library/cpp/testing/gtest_extensions/ut/ya.make
@@ -1,20 +1,20 @@
GTEST()
-OWNER(
+OWNER(
amatanhead
- bulatman
- dancingqueue
+ bulatman
+ dancingqueue
prettyboy
thegeorg
- g:cpp-contrib
-)
-
-SRCS(
+ g:cpp-contrib
+)
+
+SRCS(
gtest_extensions_ut.cpp
probe_ut.cpp
-)
-
-PEERDIR(
+)
+
+PEERDIR(
library/cpp/testing/gtest_extensions
-)
-
-END()
+)
+
+END()
diff --git a/library/cpp/testing/gtest_extensions/ya.make b/library/cpp/testing/gtest_extensions/ya.make
index e24e81e8bd..6a9a9ecca5 100644
--- a/library/cpp/testing/gtest_extensions/ya.make
+++ b/library/cpp/testing/gtest_extensions/ya.make
@@ -1,26 +1,26 @@
-LIBRARY()
-OWNER(
+LIBRARY()
+OWNER(
amatanhead
- bulatman
- dancingqueue
+ bulatman
+ dancingqueue
prettyboy
thegeorg
- g:cpp-contrib
-)
-
-PEERDIR(
+ g:cpp-contrib
+)
+
+PEERDIR(
contrib/restricted/googletest/googlemock
contrib/restricted/googletest/googletest
-)
-
-SRCS(
+)
+
+SRCS(
assertions.cpp
gtest_extensions.cpp
matchers.cpp
pretty_printers.cpp
probe.cpp
-)
-
-END()
-
-RECURSE_FOR_TESTS(ut)
+)
+
+END()
+
+RECURSE_FOR_TESTS(ut)
diff --git a/util/generic/va_args.h b/util/generic/va_args.h
index 33498d47ed..4c7ec54c97 100644
--- a/util/generic/va_args.h
+++ b/util/generic/va_args.h
@@ -237,13 +237,13 @@
Y_PASS_VA_ARGS(__Y_MAP_ARGS_49(ACTION, __VA_ARGS__))
/**
- * Expands a macro for each of the variable arguments with it's sequence number and value.
- * Corresponding sequence numbers will expand in descending order.
- * Doesn't work with empty arguments list.
- */
-#define Y_MAP_ARGS_N(ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(Y_CAT(__Y_MAP_ARGS_N_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, __VA_ARGS__))
-#define __Y_MAP_ARGS_N_0(...)
-#define __Y_MAP_ARGS_N_1(ACTION, x, ...) ACTION(1, x)
+ * Expands a macro for each of the variable arguments with it's sequence number and value.
+ * Corresponding sequence numbers will expand in descending order.
+ * Doesn't work with empty arguments list.
+ */
+#define Y_MAP_ARGS_N(ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(Y_CAT(__Y_MAP_ARGS_N_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, __VA_ARGS__))
+#define __Y_MAP_ARGS_N_0(...)
+#define __Y_MAP_ARGS_N_1(ACTION, x, ...) ACTION(1, x)
#define __Y_MAP_ARGS_N_2(ACTION, x, ...) \
ACTION(2, x) \
Y_PASS_VA_ARGS(__Y_MAP_ARGS_N_1(ACTION, __VA_ARGS__))
@@ -391,8 +391,8 @@
#define __Y_MAP_ARGS_N_50(ACTION, x, ...) \
ACTION(50, x) \
Y_PASS_VA_ARGS(__Y_MAP_ARGS_N_49(ACTION, __VA_ARGS__))
-
-/**
+
+/**
* Expands a macro for each of the variable arguments.
* Doesn't work with empty arguments list.
*/
@@ -548,13 +548,13 @@
Y_PASS_VA_ARGS(__Y_MAP_ARGS_WITH_LAST_49(ACTION, LAST_ACTION, __VA_ARGS__))
/**
- * Expands a macro for each of the variable arguments with it's sequence number and value.
- * Corresponding sequence numbers will expand in descending order.
- * Doesn't work with empty arguments list.
- */
-#define Y_MAP_ARGS_WITH_LAST_N(ACTION, LAST_ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(Y_CAT(__Y_MAP_ARGS_WITH_LAST_N_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, LAST_ACTION, __VA_ARGS__))
-#define __Y_MAP_ARGS_WITH_LAST_N_0(...)
-#define __Y_MAP_ARGS_WITH_LAST_N_1(ACTION, LAST_ACTION, x, ...) LAST_ACTION(1, x)
+ * Expands a macro for each of the variable arguments with it's sequence number and value.
+ * Corresponding sequence numbers will expand in descending order.
+ * Doesn't work with empty arguments list.
+ */
+#define Y_MAP_ARGS_WITH_LAST_N(ACTION, LAST_ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(Y_CAT(__Y_MAP_ARGS_WITH_LAST_N_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, LAST_ACTION, __VA_ARGS__))
+#define __Y_MAP_ARGS_WITH_LAST_N_0(...)
+#define __Y_MAP_ARGS_WITH_LAST_N_1(ACTION, LAST_ACTION, x, ...) LAST_ACTION(1, x)
#define __Y_MAP_ARGS_WITH_LAST_N_2(ACTION, LAST_ACTION, x, ...) \
ACTION(2, x) \
Y_PASS_VA_ARGS(__Y_MAP_ARGS_WITH_LAST_N_1(ACTION, LAST_ACTION, __VA_ARGS__))
@@ -702,8 +702,8 @@
#define __Y_MAP_ARGS_WITH_LAST_N_50(ACTION, LAST_ACTION, x, ...) \
ACTION(50, x) \
Y_PASS_VA_ARGS(__Y_MAP_ARGS_WITH_LAST_N_49(ACTION, LAST_ACTION, __VA_ARGS__))
-
-/**
+
+/**
* Get all elements but the last one from `__VA_ARGS__`.
* Doesn't work with empty arguments list.
*/
diff --git a/util/generic/va_args_gen.py b/util/generic/va_args_gen.py
index 232b53fca6..bacdc10859 100755
--- a/util/generic/va_args_gen.py
+++ b/util/generic/va_args_gen.py
@@ -33,9 +33,9 @@ def generate(limit):
count(limit)
get_elem(limit)
map_args(limit)
- map_args_n(limit)
+ map_args_n(limit)
map_args_with_last(limit)
- map_args_with_last_n(limit)
+ map_args_with_last_n(limit)
all_but_last(limit)
last(limit)
impl_dispatcher()
@@ -96,23 +96,23 @@ def map_args(limit):
'ACTION, __VA_ARGS__))'.format(i, i - 1))
-def map_args_n(limit):
- print(textwrap.dedent('''
- /**
- * Expands a macro for each of the variable arguments with it's sequence number and value.
- * Corresponding sequence numbers will expand in descending order.
- * Doesn't work with empty arguments list.
- */
- '''.rstrip()))
- print('#define Y_MAP_ARGS_N(ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(Y_CAT('
- '__Y_MAP_ARGS_N_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, __VA_ARGS__))')
- print('#define __Y_MAP_ARGS_N_0(...)')
- print('#define __Y_MAP_ARGS_N_1(ACTION, x, ...) ACTION(1, x)')
- for i in xrange(2, limit + 1):
- print('#define __Y_MAP_ARGS_N_{}(ACTION, x, ...) ACTION({}, x) Y_PASS_VA_ARGS(__Y_MAP_ARGS_N_{}('
- 'ACTION, __VA_ARGS__))'.format(i, i, i - 1))
-
-
+def map_args_n(limit):
+ print(textwrap.dedent('''
+ /**
+ * Expands a macro for each of the variable arguments with it's sequence number and value.
+ * Corresponding sequence numbers will expand in descending order.
+ * Doesn't work with empty arguments list.
+ */
+ '''.rstrip()))
+ print('#define Y_MAP_ARGS_N(ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(Y_CAT('
+ '__Y_MAP_ARGS_N_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, __VA_ARGS__))')
+ print('#define __Y_MAP_ARGS_N_0(...)')
+ print('#define __Y_MAP_ARGS_N_1(ACTION, x, ...) ACTION(1, x)')
+ for i in xrange(2, limit + 1):
+ print('#define __Y_MAP_ARGS_N_{}(ACTION, x, ...) ACTION({}, x) Y_PASS_VA_ARGS(__Y_MAP_ARGS_N_{}('
+ 'ACTION, __VA_ARGS__))'.format(i, i, i - 1))
+
+
def map_args_with_last(limit):
print(textwrap.dedent('''
/**
@@ -130,24 +130,24 @@ def map_args_with_last(limit):
'__Y_MAP_ARGS_WITH_LAST_{}(ACTION, LAST_ACTION, __VA_ARGS__))'.format(i, i - 1))
-def map_args_with_last_n(limit):
- print(textwrap.dedent('''
- /**
- * Expands a macro for each of the variable arguments with it's sequence number and value.
- * Corresponding sequence numbers will expand in descending order.
- * Doesn't work with empty arguments list.
- */
- '''.rstrip()))
- print('#define Y_MAP_ARGS_WITH_LAST_N(ACTION, LAST_ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS('
- 'Y_CAT(__Y_MAP_ARGS_WITH_LAST_N_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, LAST_ACTION, '
- '__VA_ARGS__))')
- print('#define __Y_MAP_ARGS_WITH_LAST_N_0(...)')
- print('#define __Y_MAP_ARGS_WITH_LAST_N_1(ACTION, LAST_ACTION, x, ...) LAST_ACTION(1, x)')
- for i in xrange(2, limit + 1):
- print('#define __Y_MAP_ARGS_WITH_LAST_N_{}(ACTION, LAST_ACTION, x, ...) ACTION({}, x) Y_PASS_VA_ARGS('
- '__Y_MAP_ARGS_WITH_LAST_N_{}(ACTION, LAST_ACTION, __VA_ARGS__))'.format(i, i, i - 1))
-
-
+def map_args_with_last_n(limit):
+ print(textwrap.dedent('''
+ /**
+ * Expands a macro for each of the variable arguments with it's sequence number and value.
+ * Corresponding sequence numbers will expand in descending order.
+ * Doesn't work with empty arguments list.
+ */
+ '''.rstrip()))
+ print('#define Y_MAP_ARGS_WITH_LAST_N(ACTION, LAST_ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS('
+ 'Y_CAT(__Y_MAP_ARGS_WITH_LAST_N_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, LAST_ACTION, '
+ '__VA_ARGS__))')
+ print('#define __Y_MAP_ARGS_WITH_LAST_N_0(...)')
+ print('#define __Y_MAP_ARGS_WITH_LAST_N_1(ACTION, LAST_ACTION, x, ...) LAST_ACTION(1, x)')
+ for i in xrange(2, limit + 1):
+ print('#define __Y_MAP_ARGS_WITH_LAST_N_{}(ACTION, LAST_ACTION, x, ...) ACTION({}, x) Y_PASS_VA_ARGS('
+ '__Y_MAP_ARGS_WITH_LAST_N_{}(ACTION, LAST_ACTION, __VA_ARGS__))'.format(i, i, i - 1))
+
+
def all_but_last(limit):
print(textwrap.dedent('''
/**
diff --git a/util/generic/va_args_ut.cpp b/util/generic/va_args_ut.cpp
index a9c96a0f55..f3264bf1f3 100644
--- a/util/generic/va_args_ut.cpp
+++ b/util/generic/va_args_ut.cpp
@@ -16,30 +16,30 @@ Y_UNIT_TEST_SUITE(TMacroVarargMapTest) {
#undef ADD
#undef ID
}
-
- Y_UNIT_TEST(TestMapArgsN) {
-#define MAP_ARG(INDEX, X) Y_STRINGIZE(X)
-#define MAP_INDEX(INDEX, X) Y_STRINGIZE(INDEX)
- static const char COMBINED_ARGS[] = Y_MAP_ARGS_N(MAP_ARG, 1, 2, 3);
- UNIT_ASSERT_STRINGS_EQUAL(COMBINED_ARGS, "123");
- static const char COMBINED_INDEXES[] = Y_MAP_ARGS_N(MAP_INDEX, 1, 2, 3);
- UNIT_ASSERT_STRINGS_EQUAL(COMBINED_INDEXES, "321");
-#undef MAP_INDEX
-#undef MAP_ARG
- }
-
- Y_UNIT_TEST(TestMapArgsWithLastN) {
-#define ADD_ARG(INDEX, X) X +
-#define ID_ARG(INDEX, X) X
-#define MAP_INDEX(INDEX, X) Y_STRINGIZE(INDEX)
- static const int SUM = Y_MAP_ARGS_WITH_LAST_N(ADD_ARG, ID_ARG, 1, 2, 3, 4 + 5);
- UNIT_ASSERT_VALUES_EQUAL(SUM, 1 + 2 + 3 + 4 + 5);
- static const char COMBINED_INDEXES[] = Y_MAP_ARGS_WITH_LAST_N(MAP_INDEX, MAP_INDEX, 1, 2, 3, 4 + 5);
- UNIT_ASSERT_STRINGS_EQUAL(COMBINED_INDEXES, "4321");
-#undef MAP_INDEX
-#undef ADD_ARG
-#undef ID_ARG
- }
+
+ Y_UNIT_TEST(TestMapArgsN) {
+#define MAP_ARG(INDEX, X) Y_STRINGIZE(X)
+#define MAP_INDEX(INDEX, X) Y_STRINGIZE(INDEX)
+ static const char COMBINED_ARGS[] = Y_MAP_ARGS_N(MAP_ARG, 1, 2, 3);
+ UNIT_ASSERT_STRINGS_EQUAL(COMBINED_ARGS, "123");
+ static const char COMBINED_INDEXES[] = Y_MAP_ARGS_N(MAP_INDEX, 1, 2, 3);
+ UNIT_ASSERT_STRINGS_EQUAL(COMBINED_INDEXES, "321");
+#undef MAP_INDEX
+#undef MAP_ARG
+ }
+
+ Y_UNIT_TEST(TestMapArgsWithLastN) {
+#define ADD_ARG(INDEX, X) X +
+#define ID_ARG(INDEX, X) X
+#define MAP_INDEX(INDEX, X) Y_STRINGIZE(INDEX)
+ static const int SUM = Y_MAP_ARGS_WITH_LAST_N(ADD_ARG, ID_ARG, 1, 2, 3, 4 + 5);
+ UNIT_ASSERT_VALUES_EQUAL(SUM, 1 + 2 + 3 + 4 + 5);
+ static const char COMBINED_INDEXES[] = Y_MAP_ARGS_WITH_LAST_N(MAP_INDEX, MAP_INDEX, 1, 2, 3, 4 + 5);
+ UNIT_ASSERT_STRINGS_EQUAL(COMBINED_INDEXES, "4321");
+#undef MAP_INDEX
+#undef ADD_ARG
+#undef ID_ARG
+ }
}
Y_UNIT_TEST_SUITE(TestVaArgs) {