Browse Source

Restoring authorship annotation for <dancingqueue@yandex-team.ru>. Commit 2 of 2.

dancingqueue 3 years ago
parent
commit
97ccada563

+ 2 - 2
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"

+ 28 - 28
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\"");

+ 13 - 13
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()

+ 16 - 16
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)

+ 18 - 18
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.
  */

+ 37 - 37
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('''
         /**

+ 24 - 24
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) {