michael@0: // Copyright (c) 2010 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #import "gtest_mac.h" michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #ifdef GTEST_OS_MAC michael@0: michael@0: #import michael@0: michael@0: namespace testing { michael@0: namespace internal { michael@0: michael@0: // This overloaded version allows comparison between ObjC objects that conform michael@0: // to the NSObject protocol. Used to implement {ASSERT|EXPECT}_EQ(). michael@0: GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression, michael@0: const char* actual_expression, michael@0: id expected, michael@0: id actual) { michael@0: if (expected == actual || [expected isEqual:actual]) { michael@0: return AssertionSuccess(); michael@0: } michael@0: return EqFailure(expected_expression, michael@0: actual_expression, michael@0: String([[expected description] UTF8String]), michael@0: String([[actual description] UTF8String]), michael@0: false); michael@0: } michael@0: michael@0: // This overloaded version allows comparison between ObjC objects that conform michael@0: // to the NSObject protocol. Used to implement {ASSERT|EXPECT}_NE(). michael@0: GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression, michael@0: const char* actual_expression, michael@0: id expected, michael@0: id actual) { michael@0: if (expected != actual && ![expected isEqual:actual]) { michael@0: return AssertionSuccess(); michael@0: } michael@0: Message msg; michael@0: msg << "Expected: (" << expected_expression << ") != (" << actual_expression michael@0: << "), actual: " << String([[expected description] UTF8String]) michael@0: << " vs " << String([[actual description] UTF8String]); michael@0: return AssertionFailure(msg); michael@0: } michael@0: michael@0: } // namespace internal michael@0: } // namespace testing michael@0: michael@0: #endif // GTEST_OS_MAC