1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/webrtc/trunk/testing/gtest_mac.mm Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +// Copyright (c) 2010 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#import "gtest_mac.h" 1.9 + 1.10 +#include <gtest/internal/gtest-port.h> 1.11 +#include <gtest/internal/gtest-string.h> 1.12 +#include <gtest/gtest.h> 1.13 + 1.14 +#ifdef GTEST_OS_MAC 1.15 + 1.16 +#import <Foundation/Foundation.h> 1.17 + 1.18 +namespace testing { 1.19 +namespace internal { 1.20 + 1.21 +// This overloaded version allows comparison between ObjC objects that conform 1.22 +// to the NSObject protocol. Used to implement {ASSERT|EXPECT}_EQ(). 1.23 +GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression, 1.24 + const char* actual_expression, 1.25 + id<NSObject> expected, 1.26 + id<NSObject> actual) { 1.27 + if (expected == actual || [expected isEqual:actual]) { 1.28 + return AssertionSuccess(); 1.29 + } 1.30 + return EqFailure(expected_expression, 1.31 + actual_expression, 1.32 + String([[expected description] UTF8String]), 1.33 + String([[actual description] UTF8String]), 1.34 + false); 1.35 +} 1.36 + 1.37 +// This overloaded version allows comparison between ObjC objects that conform 1.38 +// to the NSObject protocol. Used to implement {ASSERT|EXPECT}_NE(). 1.39 +GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression, 1.40 + const char* actual_expression, 1.41 + id<NSObject> expected, 1.42 + id<NSObject> actual) { 1.43 + if (expected != actual && ![expected isEqual:actual]) { 1.44 + return AssertionSuccess(); 1.45 + } 1.46 + Message msg; 1.47 + msg << "Expected: (" << expected_expression << ") != (" << actual_expression 1.48 + << "), actual: " << String([[expected description] UTF8String]) 1.49 + << " vs " << String([[actual description] UTF8String]); 1.50 + return AssertionFailure(msg); 1.51 +} 1.52 + 1.53 +} // namespace internal 1.54 +} // namespace testing 1.55 + 1.56 +#endif // GTEST_OS_MAC