Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: testing/gtest_mac.mm

Issue 3028047: This adds adds four macros when compiling using GTEST_OS_MAC: (Closed)
Patch Set: Fix compile Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #import "gtest_mac.h"
6
7 #include <gtest/internal/gtest-port.h>
8 #include <gtest/internal/gtest-string.h>
9 #include <gtest/gtest.h>
10
11 #ifdef GTEST_OS_MAC
12
13 #import <Foundation/Foundation.h>
14
15 namespace testing {
16 namespace internal {
17
18 // This overloaded version allows comparison between ObjC objects that conform
19 // to the NSObject protocol. Used to implement {ASSERT|EXPECT}_EQ().
20 GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression,
21 const char* actual_expression,
22 id<NSObject> expected,
23 id<NSObject> actual) {
Scott Hess - ex-Googler 2010/08/10 00:00:34 Suggest you add something like: if (!expected &
24 if ([expected isEqual:actual]) {
25 return AssertionSuccess();
26 }
27 return EqFailure(expected_expression,
28 actual_expression,
29 String([[expected description] UTF8String]),
30 String([[actual description] UTF8String]),
31 false);
32 }
33
34 // This overloaded version allows comparison between ObjC objects that conform
35 // to the NSObject protocol. Used to implement {ASSERT|EXPECT}_NE().
36 GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression,
37 const char* actual_expression,
38 id<NSObject> expected,
39 id<NSObject> actual) {
40 if (![expected isEqual:actual]) {
Scott Hess - ex-Googler 2010/08/10 00:00:34 This isn't right if !expected && !actual. And lik
41 return AssertionSuccess();
42 }
43 Message msg;
44 msg << "Expected: (" << expected_expression << ") != (" << actual_expression
45 << "), actual: " << String([[expected description] UTF8String])
46 << " vs " << String([[actual description] UTF8String]);
47 return AssertionFailure(msg);
48 }
49
50 } // namespace internal
51 } // namespace testing
52
53 #endif // GTEST_OS_MAC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698