7#include <gtest/gtest.h>
8#include <gtest/internal/gtest-port.h>
9#include <gtest/internal/gtest-string.h>
11#import <Foundation/Foundation.h>
16static inline const char* StringDescription(id<NSObject> obj) {
17 return [[NSString stringWithFormat:@
"%@", obj] UTF8String];
21GTEST_API_ AssertionResult CmpHelperNSEQ(
const char* expected_expression,
22 const char* actual_expression,
23 id<NSObject> expected,
24 id<NSObject> actual) {
25 if (expected == actual || [expected isEqual:actual]) {
26 return AssertionSuccess();
28 return EqFailure(expected_expression, actual_expression,
29 std::string(StringDescription(expected)),
30 std::string(StringDescription(actual)),
false);
34GTEST_API_ AssertionResult CmpHelperNSNE(
const char* expected_expression,
35 const char* actual_expression,
36 id<NSObject> expected,
37 id<NSObject> actual) {
38 if (expected != actual && ![expected isEqual:actual]) {
39 return AssertionSuccess();
42 msg <<
"Expected: (" << expected_expression <<
") != (" << actual_expression
43 <<
"), actual: " << StringDescription(expected) <<
" vs "
44 << StringDescription(actual);
45 return AssertionFailure(msg);
47#if !defined(GTEST_OS_IOS)
48GTEST_API_ AssertionResult CmpHelperNSEQ(
const char* expected_expression,
49 const char* actual_expression,
50 const NSRect& expected,
51 const NSRect& actual) {
52 if (NSEqualRects(expected, actual)) {
53 return AssertionSuccess();
55 return EqFailure(expected_expression, actual_expression,
56 [NSStringFromRect(expected) UTF8String],
57 [NSStringFromRect(actual) UTF8String],
false);
59GTEST_API_ AssertionResult CmpHelperNSNE(
const char* expected_expression,
60 const char* actual_expression,
61 const NSRect& expected,
62 const NSRect& actual) {
63 if (!NSEqualRects(expected, actual)) {
64 return AssertionSuccess();
67 msg <<
"Expected: (" << expected_expression <<
") != (" << actual_expression
68 <<
"), actual: " << [NSStringFromRect(expected) UTF8String] <<
" vs "
69 << [NSStringFromRect(actual) UTF8String];
70 return AssertionFailure(msg);
72GTEST_API_ AssertionResult CmpHelperNSEQ(
const char* expected_expression,
73 const char* actual_expression,
74 const NSPoint& expected,
75 const NSPoint& actual) {
76 if (NSEqualPoints(expected, actual)) {
77 return AssertionSuccess();
79 return EqFailure(expected_expression, actual_expression,
80 [NSStringFromPoint(expected) UTF8String],
81 [NSStringFromPoint(actual) UTF8String],
false);
83GTEST_API_ AssertionResult CmpHelperNSNE(
const char* expected_expression,
84 const char* actual_expression,
85 const NSPoint& expected,
86 const NSPoint& actual) {
87 if (!NSEqualPoints(expected, actual)) {
88 return AssertionSuccess();
91 msg <<
"Expected: (" << expected_expression <<
") != (" << actual_expression
92 <<
"), actual: " << [NSStringFromPoint(expected) UTF8String] <<
" vs "
93 << [NSStringFromPoint(actual) UTF8String];
94 return AssertionFailure(msg);