gtest_support.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef THIRD_PARTY_OCMOCK_GTEST_SUPPORT_H_
  5. #define THIRD_PARTY_OCMOCK_GTEST_SUPPORT_H_
  6. #include "testing/gtest/include/gtest/gtest.h"
  7. @class OCMockObject;
  8. namespace testing {
  9. namespace internal {
  10. bool VerifyOCMock(OCMockObject* mock, const char* file, int line);
  11. } // namespace internal
  12. } // namespace testing
  13. // Calls -verify of the mock and traps the Objective-C exception that is
  14. // generated, adding it to the gtest failures and returning true/false
  15. // for if there was an exception. The result should be used in normal
  16. // gtest EXECPT_TRUE/ASSERT_TRUE fashion.
  17. //
  18. // So code that would do:
  19. //
  20. // id mockFoo = [OCMockObject mockForClass:[Foo class]];
  21. // ...
  22. // [mockFoo verify];
  23. //
  24. // Should instead do:
  25. //
  26. // id mockFoo = [OCMockObject mockForClass:[Foo class]];
  27. // ...
  28. // EXPECT_OCMOCK_VERIFY(mockFoo);
  29. //
  30. #define EXPECT_OCMOCK_VERIFY(m) \
  31. EXPECT_TRUE(testing::internal::VerifyOCMock((m), __FILE__, __LINE__))
  32. #define ASSERT_OCMOCK_VERIFY(m) \
  33. ASSERT_TRUE(testing::internal::VerifyOCMock((m), __FILE__, __LINE__))
  34. #endif // THIRD_PARTY_OCMOCK_GTEST_SUPPORT_H_