| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "gtest_mac.h" | 5 #import "gtest_mac.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 |
| 7 #include <gtest/internal/gtest-port.h> | 9 #include <gtest/internal/gtest-port.h> |
| 8 #include <gtest/internal/gtest-string.h> | 10 #include <gtest/internal/gtest-string.h> |
| 9 #include <gtest/gtest.h> | 11 #include <gtest/gtest.h> |
| 10 | 12 |
| 11 #ifdef GTEST_OS_MAC | 13 #ifdef GTEST_OS_MAC |
| 12 | 14 |
| 13 #import <Foundation/Foundation.h> | 15 #import <Foundation/Foundation.h> |
| 14 | 16 |
| 15 namespace testing { | 17 namespace testing { |
| 16 namespace internal { | 18 namespace internal { |
| 17 | 19 |
| 18 // This overloaded version allows comparison between ObjC objects that conform | 20 // This overloaded version allows comparison between ObjC objects that conform |
| 19 // to the NSObject protocol. Used to implement {ASSERT|EXPECT}_EQ(). | 21 // to the NSObject protocol. Used to implement {ASSERT|EXPECT}_EQ(). |
| 20 GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression, | 22 GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression, |
| 21 const char* actual_expression, | 23 const char* actual_expression, |
| 22 id<NSObject> expected, | 24 id<NSObject> expected, |
| 23 id<NSObject> actual) { | 25 id<NSObject> actual) { |
| 24 if (expected == actual || [expected isEqual:actual]) { | 26 if (expected == actual || [expected isEqual:actual]) { |
| 25 return AssertionSuccess(); | 27 return AssertionSuccess(); |
| 26 } | 28 } |
| 27 return EqFailure(expected_expression, | 29 return EqFailure(expected_expression, |
| 28 actual_expression, | 30 actual_expression, |
| 29 String([[expected description] UTF8String]), | 31 std::string([[expected description] UTF8String]), |
| 30 String([[actual description] UTF8String]), | 32 std::string([[actual description] UTF8String]), |
| 31 false); | 33 false); |
| 32 } | 34 } |
| 33 | 35 |
| 34 // This overloaded version allows comparison between ObjC objects that conform | 36 // This overloaded version allows comparison between ObjC objects that conform |
| 35 // to the NSObject protocol. Used to implement {ASSERT|EXPECT}_NE(). | 37 // to the NSObject protocol. Used to implement {ASSERT|EXPECT}_NE(). |
| 36 GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression, | 38 GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression, |
| 37 const char* actual_expression, | 39 const char* actual_expression, |
| 38 id<NSObject> expected, | 40 id<NSObject> expected, |
| 39 id<NSObject> actual) { | 41 id<NSObject> actual) { |
| 40 if (expected != actual && ![expected isEqual:actual]) { | 42 if (expected != actual && ![expected isEqual:actual]) { |
| 41 return AssertionSuccess(); | 43 return AssertionSuccess(); |
| 42 } | 44 } |
| 43 Message msg; | 45 Message msg; |
| 44 msg << "Expected: (" << expected_expression << ") != (" << actual_expression | 46 msg << "Expected: (" << expected_expression << ") != (" << actual_expression |
| 45 << "), actual: " << String([[expected description] UTF8String]) | 47 << "), actual: " << std::string([[expected description] UTF8String]) |
| 46 << " vs " << String([[actual description] UTF8String]); | 48 << " vs " << std::string([[actual description] UTF8String]); |
| 47 return AssertionFailure(msg); | 49 return AssertionFailure(msg); |
| 48 } | 50 } |
| 49 | 51 |
| 50 } // namespace internal | 52 } // namespace internal |
| 51 } // namespace testing | 53 } // namespace testing |
| 52 | 54 |
| 53 #endif // GTEST_OS_MAC | 55 #endif // GTEST_OS_MAC |
| OLD | NEW |