react-native-navigation的迁移库

OCMock.h 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (c) 2004-2016 Erik Doernenburg and contributors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. * not use these files except in compliance with the License. You may obtain
  6. * a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations
  14. * under the License.
  15. */
  16. #import <OCMock/OCMockObject.h>
  17. #import <OCMock/OCMRecorder.h>
  18. #import <OCMock/OCMStubRecorder.h>
  19. #import <OCMock/OCMConstraint.h>
  20. #import <OCMock/OCMArg.h>
  21. #import <OCMock/OCMLocation.h>
  22. #import <OCMock/OCMMacroState.h>
  23. #import <OCMock/NSNotificationCenter+OCMAdditions.h>
  24. #import <OCMock/OCMFunctions.h>
  25. #define OCMClassMock(cls) [OCMockObject niceMockForClass:cls]
  26. #define OCMStrictClassMock(cls) [OCMockObject mockForClass:cls]
  27. #define OCMProtocolMock(protocol) [OCMockObject niceMockForProtocol:protocol]
  28. #define OCMStrictProtocolMock(protocol) [OCMockObject mockForProtocol:protocol]
  29. #define OCMPartialMock(obj) [OCMockObject partialMockForObject:obj]
  30. #define OCMObserverMock() [OCMockObject observerMock]
  31. #define OCMStub(invocation) \
  32. ({ \
  33. _OCMSilenceWarnings( \
  34. [OCMMacroState beginStubMacro]; \
  35. OCMStubRecorder *recorder = nil; \
  36. @try{ \
  37. invocation; \
  38. }@finally{ \
  39. recorder = [OCMMacroState endStubMacro]; \
  40. } \
  41. recorder; \
  42. ); \
  43. })
  44. #define OCMExpect(invocation) \
  45. ({ \
  46. _OCMSilenceWarnings( \
  47. [OCMMacroState beginExpectMacro]; \
  48. OCMStubRecorder *recorder = nil; \
  49. @try{ \
  50. invocation; \
  51. }@finally{ \
  52. recorder = [OCMMacroState endExpectMacro]; \
  53. } \
  54. recorder; \
  55. ); \
  56. })
  57. #define OCMReject(invocation) \
  58. ({ \
  59. _OCMSilenceWarnings( \
  60. [OCMMacroState beginRejectMacro]; \
  61. OCMStubRecorder *recorder = nil; \
  62. @try{ \
  63. invocation; \
  64. }@finally{ \
  65. recorder = [OCMMacroState endRejectMacro]; \
  66. } \
  67. recorder; \
  68. ); \
  69. })
  70. #define ClassMethod(invocation) \
  71. _OCMSilenceWarnings( \
  72. [[OCMMacroState globalState] switchToClassMethod]; \
  73. invocation; \
  74. );
  75. #define OCMVerifyAll(mock) [mock verifyAtLocation:OCMMakeLocation(self, __FILE__, __LINE__)]
  76. #define OCMVerifyAllWithDelay(mock, delay) [mock verifyWithDelay:delay atLocation:OCMMakeLocation(self, __FILE__, __LINE__)]
  77. #define OCMVerify(invocation) \
  78. ({ \
  79. _OCMSilenceWarnings( \
  80. [OCMMacroState beginVerifyMacroAtLocation:OCMMakeLocation(self, __FILE__, __LINE__)]; \
  81. @try{ \
  82. invocation; \
  83. }@finally{ \
  84. [OCMMacroState endVerifyMacro]; \
  85. } \
  86. ); \
  87. })
  88. #define _OCMSilenceWarnings(macro) \
  89. ({ \
  90. _Pragma("clang diagnostic push") \
  91. _Pragma("clang diagnostic ignored \"-Wunused-value\"") \
  92. _Pragma("clang diagnostic ignored \"-Wunused-getter-return-value\"") \
  93. macro \
  94. _Pragma("clang diagnostic pop") \
  95. })