OLD | NEW |
1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 using testing::PolymorphicAction; | 67 using testing::PolymorphicAction; |
68 using testing::Return; | 68 using testing::Return; |
69 using testing::ReturnNull; | 69 using testing::ReturnNull; |
70 using testing::ReturnRef; | 70 using testing::ReturnRef; |
71 using testing::SetArgumentPointee; | 71 using testing::SetArgumentPointee; |
72 | 72 |
73 #if !GTEST_OS_WINDOWS_MOBILE | 73 #if !GTEST_OS_WINDOWS_MOBILE |
74 using testing::SetErrnoAndReturn; | 74 using testing::SetErrnoAndReturn; |
75 #endif | 75 #endif |
76 | 76 |
77 #if GMOCK_HAS_PROTOBUF_ | 77 #if GTEST_HAS_PROTOBUF_ |
78 using testing::internal::TestMessage; | 78 using testing::internal::TestMessage; |
79 #endif // GMOCK_HAS_PROTOBUF_ | 79 #endif // GTEST_HAS_PROTOBUF_ |
80 | 80 |
81 // Tests that BuiltInDefaultValue<T*>::Get() returns NULL. | 81 // Tests that BuiltInDefaultValue<T*>::Get() returns NULL. |
82 TEST(BuiltInDefaultValueTest, IsNullForPointerTypes) { | 82 TEST(BuiltInDefaultValueTest, IsNullForPointerTypes) { |
83 EXPECT_TRUE(BuiltInDefaultValue<int*>::Get() == NULL); | 83 EXPECT_TRUE(BuiltInDefaultValue<int*>::Get() == NULL); |
84 EXPECT_TRUE(BuiltInDefaultValue<const char*>::Get() == NULL); | 84 EXPECT_TRUE(BuiltInDefaultValue<const char*>::Get() == NULL); |
85 EXPECT_TRUE(BuiltInDefaultValue<void*>::Get() == NULL); | 85 EXPECT_TRUE(BuiltInDefaultValue<void*>::Get() == NULL); |
86 } | 86 } |
87 | 87 |
88 // Tests that BuiltInDefaultValue<T*>::Exists() return true. | 88 // Tests that BuiltInDefaultValue<T*>::Exists() return true. |
89 TEST(BuiltInDefaultValueTest, ExistsForPointerTypes) { | 89 TEST(BuiltInDefaultValueTest, ExistsForPointerTypes) { |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 EXPECT_EQ('\0', ch); | 682 EXPECT_EQ('\0', ch); |
683 | 683 |
684 a = SetArgumentPointee<2>('a'); | 684 a = SetArgumentPointee<2>('a'); |
685 n = 0; | 685 n = 0; |
686 ch = '\0'; | 686 ch = '\0'; |
687 a.Perform(make_tuple(true, &n, &ch)); | 687 a.Perform(make_tuple(true, &n, &ch)); |
688 EXPECT_EQ(0, n); | 688 EXPECT_EQ(0, n); |
689 EXPECT_EQ('a', ch); | 689 EXPECT_EQ('a', ch); |
690 } | 690 } |
691 | 691 |
692 #if GMOCK_HAS_PROTOBUF_ | 692 #if GTEST_HAS_PROTOBUF_ |
693 | 693 |
694 // Tests that SetArgumentPointee<N>(proto_buffer) sets the v1 protobuf | 694 // Tests that SetArgumentPointee<N>(proto_buffer) sets the v1 protobuf |
695 // variable pointed to by the N-th (0-based) argument to proto_buffer. | 695 // variable pointed to by the N-th (0-based) argument to proto_buffer. |
696 TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProtoBufferType) { | 696 TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProtoBufferType) { |
697 TestMessage* const msg = new TestMessage; | 697 TestMessage* const msg = new TestMessage; |
698 msg->set_member("yes"); | 698 msg->set_member("yes"); |
699 TestMessage orig_msg; | 699 TestMessage orig_msg; |
700 orig_msg.CopyFrom(*msg); | 700 orig_msg.CopyFrom(*msg); |
701 | 701 |
702 Action<void(bool, TestMessage*)> a = SetArgumentPointee<1>(*msg); | 702 Action<void(bool, TestMessage*)> a = SetArgumentPointee<1>(*msg); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 delete msg; | 779 delete msg; |
780 | 780 |
781 FooMessage dest; | 781 FooMessage dest; |
782 dest.set_int_field(0); | 782 dest.set_int_field(0); |
783 ::proto2::Message* const dest_base = &dest; | 783 ::proto2::Message* const dest_base = &dest; |
784 a.Perform(make_tuple(true, dest_base)); | 784 a.Perform(make_tuple(true, dest_base)); |
785 EXPECT_EQ(2, dest.int_field()); | 785 EXPECT_EQ(2, dest.int_field()); |
786 EXPECT_EQ("hi", dest.string_field()); | 786 EXPECT_EQ("hi", dest.string_field()); |
787 } | 787 } |
788 | 788 |
789 #endif // GMOCK_HAS_PROTOBUF_ | 789 #endif // GTEST_HAS_PROTOBUF_ |
790 | 790 |
791 // Sample functions and functors for testing Invoke() and etc. | 791 // Sample functions and functors for testing Invoke() and etc. |
792 int Nullary() { return 1; } | 792 int Nullary() { return 1; } |
793 | 793 |
794 class NullaryFunctor { | 794 class NullaryFunctor { |
795 public: | 795 public: |
796 int operator()() { return 2; } | 796 int operator()() { return 2; } |
797 }; | 797 }; |
798 | 798 |
799 bool g_done = false; | 799 bool g_done = false; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 // Tests that Google Mock prints expression ByRef(x) as a reference to x. | 1074 // Tests that Google Mock prints expression ByRef(x) as a reference to x. |
1075 TEST(ByRefTest, PrintsCorrectly) { | 1075 TEST(ByRefTest, PrintsCorrectly) { |
1076 int n = 42; | 1076 int n = 42; |
1077 ::std::stringstream expected, actual; | 1077 ::std::stringstream expected, actual; |
1078 testing::internal::UniversalPrinter<const int&>::Print(n, &expected); | 1078 testing::internal::UniversalPrinter<const int&>::Print(n, &expected); |
1079 testing::internal::UniversalPrint(ByRef(n), &actual); | 1079 testing::internal::UniversalPrint(ByRef(n), &actual); |
1080 EXPECT_EQ(expected.str(), actual.str()); | 1080 EXPECT_EQ(expected.str(), actual.str()); |
1081 } | 1081 } |
1082 | 1082 |
1083 } // Unnamed namespace | 1083 } // Unnamed namespace |
OLD | NEW |