Index: ext/googletest/googlemock/test/gmock-generated-actions_test.cc =================================================================== diff -u -N -r4a481bbe77043e0bda2435c6d62a02700b3e46c5 -r2e4eacb299f21d06196fe13140b4b0d095abdca9 --- ext/googletest/googlemock/test/gmock-generated-actions_test.cc (.../gmock-generated-actions_test.cc) (revision 4a481bbe77043e0bda2435c6d62a02700b3e46c5) +++ ext/googletest/googlemock/test/gmock-generated-actions_test.cc (.../gmock-generated-actions_test.cc) (revision 2e4eacb299f21d06196fe13140b4b0d095abdca9) @@ -26,9 +26,8 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) + // Google Mock - a framework for writing C++ mock classes. // // This file tests the built-in actions generated by a script. @@ -81,12 +80,12 @@ const char* Plus1(const char* s) { return s + 1; } -bool ByConstRef(const string& s) { return s == "Hi"; } +bool ByConstRef(const std::string& s) { return s == "Hi"; } const double g_double = 0; bool ReferencesGlobalDouble(const double& x) { return &x == &g_double; } -string ByNonConstRef(string& s) { return s += "+"; } // NOLINT +std::string ByNonConstRef(std::string& s) { return s += "+"; } // NOLINT struct UnaryFunctor { int operator()(bool x) { return x ? 1 : -1; } @@ -102,9 +101,9 @@ int SumOf4(int a, int b, int c, int d) { return a + b + c + d; } -string Concat4(const char* s1, const char* s2, const char* s3, - const char* s4) { - return string(s1) + s2 + s3 + s4; +std::string Concat4(const char* s1, const char* s2, const char* s3, + const char* s4) { + return std::string(s1) + s2 + s3 + s4; } int SumOf5(int a, int b, int c, int d, int e) { return a + b + c + d + e; } @@ -115,9 +114,9 @@ } }; -string Concat5(const char* s1, const char* s2, const char* s3, - const char* s4, const char* s5) { - return string(s1) + s2 + s3 + s4 + s5; +std::string Concat5(const char* s1, const char* s2, const char* s3, + const char* s4, const char* s5) { + return std::string(s1) + s2 + s3 + s4 + s5; } int SumOf6(int a, int b, int c, int d, int e, int f) { @@ -130,34 +129,34 @@ } }; -string Concat6(const char* s1, const char* s2, const char* s3, - const char* s4, const char* s5, const char* s6) { - return string(s1) + s2 + s3 + s4 + s5 + s6; +std::string Concat6(const char* s1, const char* s2, const char* s3, + const char* s4, const char* s5, const char* s6) { + return std::string(s1) + s2 + s3 + s4 + s5 + s6; } -string Concat7(const char* s1, const char* s2, const char* s3, - const char* s4, const char* s5, const char* s6, - const char* s7) { - return string(s1) + s2 + s3 + s4 + s5 + s6 + s7; +std::string Concat7(const char* s1, const char* s2, const char* s3, + const char* s4, const char* s5, const char* s6, + const char* s7) { + return std::string(s1) + s2 + s3 + s4 + s5 + s6 + s7; } -string Concat8(const char* s1, const char* s2, const char* s3, - const char* s4, const char* s5, const char* s6, - const char* s7, const char* s8) { - return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8; +std::string Concat8(const char* s1, const char* s2, const char* s3, + const char* s4, const char* s5, const char* s6, + const char* s7, const char* s8) { + return std::string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8; } -string Concat9(const char* s1, const char* s2, const char* s3, - const char* s4, const char* s5, const char* s6, - const char* s7, const char* s8, const char* s9) { - return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9; +std::string Concat9(const char* s1, const char* s2, const char* s3, + const char* s4, const char* s5, const char* s6, + const char* s7, const char* s8, const char* s9) { + return std::string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9; } -string Concat10(const char* s1, const char* s2, const char* s3, - const char* s4, const char* s5, const char* s6, - const char* s7, const char* s8, const char* s9, - const char* s10) { - return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10; +std::string Concat10(const char* s1, const char* s2, const char* s3, + const char* s4, const char* s5, const char* s6, + const char* s7, const char* s8, const char* s9, + const char* s10) { + return std::string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10; } // A helper that turns the type of a C-string literal from const @@ -208,38 +207,37 @@ // Tests using InvokeArgument with a 7-ary function. TEST(InvokeArgumentTest, Function7) { - Action a = - InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7"); + Action + a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7"); EXPECT_EQ("1234567", a.Perform(make_tuple(&Concat7))); } // Tests using InvokeArgument with a 8-ary function. TEST(InvokeArgumentTest, Function8) { - Action a = - InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8"); + Action + a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8"); EXPECT_EQ("12345678", a.Perform(make_tuple(&Concat8))); } // Tests using InvokeArgument with a 9-ary function. TEST(InvokeArgumentTest, Function9) { - Action a = - InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8", "9"); + Action + a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8", "9"); EXPECT_EQ("123456789", a.Perform(make_tuple(&Concat9))); } // Tests using InvokeArgument with a 10-ary function. TEST(InvokeArgumentTest, Function10) { - Action a = - InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); + Action + a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); EXPECT_EQ("1234567890", a.Perform(make_tuple(&Concat10))); } @@ -260,8 +258,8 @@ // Tests using InvokeArgument with a function that takes a const reference. TEST(InvokeArgumentTest, ByConstReferenceFunction) { - Action a = // NOLINT - InvokeArgument<0>(string("Hi")); + Action a = // NOLINT + InvokeArgument<0>(std::string("Hi")); // When action 'a' is constructed, it makes a copy of the temporary // string object passed to it, so it's OK to use 'a' later, when the // temporary object has already died. @@ -305,33 +303,34 @@ // Tests using WithArgs with an action that takes 4 arguments. TEST(WithArgsTest, FourArgs) { - Action a = - WithArgs<4, 3, 1, 0>(Invoke(Concat4)); + Action + a = WithArgs<4, 3, 1, 0>(Invoke(Concat4)); EXPECT_EQ("4310", a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), 2.5, CharPtr("3"), CharPtr("4")))); } // Tests using WithArgs with an action that takes 5 arguments. TEST(WithArgsTest, FiveArgs) { - Action a = - WithArgs<4, 3, 2, 1, 0>(Invoke(Concat5)); + Action + a = WithArgs<4, 3, 2, 1, 0>(Invoke(Concat5)); EXPECT_EQ("43210", a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"), CharPtr("3"), CharPtr("4")))); } // Tests using WithArgs with an action that takes 6 arguments. TEST(WithArgsTest, SixArgs) { - Action a = + Action a = WithArgs<0, 1, 2, 2, 1, 0>(Invoke(Concat6)); EXPECT_EQ("012210", a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2")))); } // Tests using WithArgs with an action that takes 7 arguments. TEST(WithArgsTest, SevenArgs) { - Action a = + Action a = WithArgs<0, 1, 2, 3, 2, 1, 0>(Invoke(Concat7)); EXPECT_EQ("0123210", a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"), @@ -340,7 +339,7 @@ // Tests using WithArgs with an action that takes 8 arguments. TEST(WithArgsTest, EightArgs) { - Action a = + Action a = WithArgs<0, 1, 2, 3, 0, 1, 2, 3>(Invoke(Concat8)); EXPECT_EQ("01230123", a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"), @@ -349,7 +348,7 @@ // Tests using WithArgs with an action that takes 9 arguments. TEST(WithArgsTest, NineArgs) { - Action a = + Action a = WithArgs<0, 1, 2, 3, 1, 2, 3, 2, 3>(Invoke(Concat9)); EXPECT_EQ("012312323", a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"), @@ -358,7 +357,7 @@ // Tests using WithArgs with an action that takes 10 arguments. TEST(WithArgsTest, TenArgs) { - Action a = + Action a = WithArgs<0, 1, 2, 3, 2, 1, 0, 1, 2, 3>(Invoke(Concat10)); EXPECT_EQ("0123210123", a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"), @@ -374,10 +373,10 @@ }; TEST(WithArgsTest, NonInvokeAction) { - Action a = // NOLINT + Action a = // NOLINT WithArgs<2, 1>(MakeAction(new SubstractAction)); - string s("hello"); - EXPECT_EQ(8, a.Perform(tuple(s, 2, 10))); + tuple dummy = make_tuple(std::string("hi"), 2, 10); + EXPECT_EQ(8, a.Perform(dummy)); } // Tests using WithArgs to pass all original arguments in the original order. @@ -754,7 +753,8 @@ TEST(ActionPMacroTest, WorksInCompatibleMockFunction) { Action a1 = Plus("tail"); const std::string re = "re"; - EXPECT_EQ("retail", a1.Perform(tuple(re))); + tuple dummy = make_tuple(re); + EXPECT_EQ("retail", a1.Perform(dummy)); } // Tests that we can use ACTION*() to define actions overloaded on the @@ -796,7 +796,8 @@ Action a2 = Plus("tail", "-", ">"); const std::string re = "re"; - EXPECT_EQ("retail->", a2.Perform(tuple(re))); + tuple dummy = make_tuple(re); + EXPECT_EQ("retail->", a2.Perform(dummy)); } ACTION_P4(Plus, p0, p1, p2, p3) { return arg0 + p0 + p1 + p2 + p3; }