diff options
author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-12-23 00:13:23 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-12-23 00:13:23 +0000 |
commit | 32de5f53763125925e078498250f7e73a88de9ed (patch) | |
tree | cb5de0206e38598a12f10403de146faadcf9cdb0 /test/gmock-more-actions_test.cc | |
parent | 284b54d3047254a8787e4f5eb9ba62a866caaabd (diff) | |
download | googletest-32de5f53763125925e078498250f7e73a88de9ed.tar.gz googletest-32de5f53763125925e078498250f7e73a88de9ed.tar.bz2 googletest-32de5f53763125925e078498250f7e73a88de9ed.zip |
Fixes a slew of compiler warnings and turns on "warning as error" in the scons build.
Diffstat (limited to 'test/gmock-more-actions_test.cc')
-rw-r--r-- | test/gmock-more-actions_test.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/test/gmock-more-actions_test.cc b/test/gmock-more-actions_test.cc index f5dab5bf..b3b17d33 100644 --- a/test/gmock-more-actions_test.cc +++ b/test/gmock-more-actions_test.cc @@ -65,6 +65,10 @@ using testing::Unused; using testing::WithArg; using testing::WithoutArgs; +// For suppressing compiler warnings on conversion possibly losing precision. +inline short Short(short n) { return n; } // NOLINT +inline char Char(char ch) { return ch; } + // Sample functions and functors for testing Invoke() and etc. int Nullary() { return 1; } @@ -85,7 +89,7 @@ bool Unary(int x) { return x < 0; } const char* Plus1(const char* s) { return s + 1; } -void VoidUnary(int n) { g_done = true; } +void VoidUnary(int /* n */) { g_done = true; } bool ByConstRef(const string& s) { return s == "Hi"; } @@ -239,13 +243,13 @@ TEST(InvokeTest, Unary) { TEST(InvokeTest, Binary) { Action<const char*(const char*, short)> a = Invoke(Binary); // NOLINT const char* p = "Hello"; - EXPECT_EQ(p + 2, a.Perform(make_tuple(p, 2))); + EXPECT_EQ(p + 2, a.Perform(make_tuple(p, Short(2)))); } // Tests using Invoke() with a ternary function. TEST(InvokeTest, Ternary) { Action<int(int, char, short)> a = Invoke(Ternary); // NOLINT - EXPECT_EQ(6, a.Perform(make_tuple(1, '\2', 3))); + EXPECT_EQ(6, a.Perform(make_tuple(1, '\2', Short(3)))); } // Tests using Invoke() with a 4-argument function. @@ -340,14 +344,14 @@ TEST(InvokeTest, MethodWithUnusedParameters) { // Tests using Invoke() with a functor. TEST(InvokeTest, Functor) { - Action<int(short, char)> a = Invoke(plus<short>()); // NOLINT - EXPECT_EQ(3, a.Perform(make_tuple(1, 2))); + Action<long(long, int)> a = Invoke(plus<long>()); // NOLINT + EXPECT_EQ(3L, a.Perform(make_tuple(1, 2))); } // Tests using Invoke(f) as an action of a compatible type. TEST(InvokeTest, FunctionWithCompatibleType) { Action<long(int, short, char, bool)> a = Invoke(SumOf4); // NOLINT - EXPECT_EQ(4321, a.Perform(make_tuple(4000, 300, 20, true))); + EXPECT_EQ(4321, a.Perform(make_tuple(4000, Short(300), Char(20), true))); } // Tests using Invoke() with an object pointer and a method pointer. @@ -378,7 +382,7 @@ TEST(InvokeMethodTest, Binary) { TEST(InvokeMethodTest, Ternary) { Foo foo; Action<int(int, bool, char)> a = Invoke(&foo, &Foo::Ternary); // NOLINT - EXPECT_EQ(1124, a.Perform(make_tuple(1000, true, 1))); + EXPECT_EQ(1124, a.Perform(make_tuple(1000, true, Char(1)))); } // Tests using Invoke() with a 4-argument method. @@ -457,7 +461,7 @@ TEST(InvokeMethodTest, MethodWithCompatibleType) { Foo foo; Action<long(int, short, char, bool)> a = // NOLINT Invoke(&foo, &Foo::SumOf4); - EXPECT_EQ(4444, a.Perform(make_tuple(4000, 300, 20, true))); + EXPECT_EQ(4444, a.Perform(make_tuple(4000, Short(300), Char(20), true))); } // Tests using WithoutArgs with an action that takes no argument. |