| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 using testing::AtMost; | 45 using testing::AtMost; |
| 46 using testing::Between; | 46 using testing::Between; |
| 47 using testing::Cardinality; | 47 using testing::Cardinality; |
| 48 using testing::CardinalityInterface; | 48 using testing::CardinalityInterface; |
| 49 using testing::Exactly; | 49 using testing::Exactly; |
| 50 using testing::IsSubstring; | 50 using testing::IsSubstring; |
| 51 using testing::MakeCardinality; | 51 using testing::MakeCardinality; |
| 52 | 52 |
| 53 class MockFoo { | 53 class MockFoo { |
| 54 public: | 54 public: |
| 55 MockFoo() {} |
| 55 MOCK_METHOD0(Bar, int()); // NOLINT | 56 MOCK_METHOD0(Bar, int()); // NOLINT |
| 57 |
| 58 private: |
| 59 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); |
| 56 }; | 60 }; |
| 57 | 61 |
| 58 // Tests that Cardinality objects can be default constructed. | 62 // Tests that Cardinality objects can be default constructed. |
| 59 TEST(CardinalityTest, IsDefaultConstructable) { | 63 TEST(CardinalityTest, IsDefaultConstructable) { |
| 60 Cardinality c; | 64 Cardinality c; |
| 61 } | 65 } |
| 62 | 66 |
| 63 // Tests that Cardinality objects are copyable. | 67 // Tests that Cardinality objects are copyable. |
| 64 TEST(CardinalityTest, IsCopyable) { | 68 TEST(CardinalityTest, IsCopyable) { |
| 65 // Tests the copy constructor. | 69 // Tests the copy constructor. |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 // CardinalityInterface and calling MakeCardinality(). | 395 // CardinalityInterface and calling MakeCardinality(). |
| 392 | 396 |
| 393 class EvenCardinality : public CardinalityInterface { | 397 class EvenCardinality : public CardinalityInterface { |
| 394 public: | 398 public: |
| 395 // Returns true iff call_count calls will satisfy this cardinality. | 399 // Returns true iff call_count calls will satisfy this cardinality. |
| 396 virtual bool IsSatisfiedByCallCount(int call_count) const { | 400 virtual bool IsSatisfiedByCallCount(int call_count) const { |
| 397 return (call_count % 2 == 0); | 401 return (call_count % 2 == 0); |
| 398 } | 402 } |
| 399 | 403 |
| 400 // Returns true iff call_count calls will saturate this cardinality. | 404 // Returns true iff call_count calls will saturate this cardinality. |
| 401 virtual bool IsSaturatedByCallCount(int call_count) const { return false; } | 405 virtual bool IsSaturatedByCallCount(int /* call_count */) const { |
| 406 return false; |
| 407 } |
| 402 | 408 |
| 403 // Describes self to an ostream. | 409 // Describes self to an ostream. |
| 404 virtual void DescribeTo(::std::ostream* ss) const { | 410 virtual void DescribeTo(::std::ostream* ss) const { |
| 405 *ss << "called even number of times"; | 411 *ss << "called even number of times"; |
| 406 } | 412 } |
| 407 }; | 413 }; |
| 408 | 414 |
| 409 TEST(MakeCardinalityTest, ConstructsCardinalityFromInterface) { | 415 TEST(MakeCardinalityTest, ConstructsCardinalityFromInterface) { |
| 410 const Cardinality c = MakeCardinality(new EvenCardinality); | 416 const Cardinality c = MakeCardinality(new EvenCardinality); |
| 411 | 417 |
| 412 EXPECT_TRUE(c.IsSatisfiedByCallCount(2)); | 418 EXPECT_TRUE(c.IsSatisfiedByCallCount(2)); |
| 413 EXPECT_FALSE(c.IsSatisfiedByCallCount(3)); | 419 EXPECT_FALSE(c.IsSatisfiedByCallCount(3)); |
| 414 | 420 |
| 415 EXPECT_FALSE(c.IsSaturatedByCallCount(10000)); | 421 EXPECT_FALSE(c.IsSaturatedByCallCount(10000)); |
| 416 | 422 |
| 417 stringstream ss; | 423 stringstream ss; |
| 418 c.DescribeTo(&ss); | 424 c.DescribeTo(&ss); |
| 419 EXPECT_EQ("called even number of times", ss.str()); | 425 EXPECT_EQ("called even number of times", ss.str()); |
| 420 } | 426 } |
| 421 | 427 |
| 422 } // Unnamed namespace | 428 } // Unnamed namespace |
| OLD | NEW |