1 // Copyright (c) 2010 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.
9 #include <gtest/internal/gtest-port.h>
10 #include <gtest/internal/gtest-string.h>
11 #include <gtest/gtest.h>
15 #import <Foundation/Foundation.h>
20 // This overloaded version allows comparison between ObjC objects that conform
21 // to the NSObject protocol. Used to implement {ASSERT|EXPECT}_EQ().
22 GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression,
23 const char* actual_expression,
24 id<NSObject> expected,
25 id<NSObject> actual) {
26 if (expected == actual || [expected isEqual:actual]) {
27 return AssertionSuccess();
29 return EqFailure(expected_expression,
31 std::string([[expected description] UTF8String]),
32 std::string([[actual description] UTF8String]),
36 // This overloaded version allows comparison between ObjC objects that conform
37 // to the NSObject protocol. Used to implement {ASSERT|EXPECT}_NE().
38 GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression,
39 const char* actual_expression,
40 id<NSObject> expected,
41 id<NSObject> actual) {
42 if (expected != actual && ![expected isEqual:actual]) {
43 return AssertionSuccess();
46 msg << "Expected: (" << expected_expression << ") != (" << actual_expression
47 << "), actual: " << std::string([[expected description] UTF8String])
48 << " vs " << std::string([[actual description] UTF8String]);
49 return AssertionFailure(msg);
52 } // namespace internal
53 } // namespace testing
55 #endif // GTEST_OS_MAC