summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-10 21:50:38 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-10 21:50:38 +0000
commit22f73595a4c5cdb62e398dc7915524528128db38 (patch)
treea1bff971c48b56118de01ee826a95c51654de521 /testing
parent3ed5a02c88c9176e62e290928f0796a853ca14a2 (diff)
downloadchromium_src-22f73595a4c5cdb62e398dc7915524528128db38.zip
chromium_src-22f73595a4c5cdb62e398dc7915524528128db38.tar.gz
chromium_src-22f73595a4c5cdb62e398dc7915524528128db38.tar.bz2
[Mac] Better handling of nil for testing macros.
EXPECT_NSEQ() and EXPECT_NSNE() were implemented in terms of [x isEqual:y]. This meant that EXPECT_NSEQ(nil, nil) failed, and EXPECT_NSNE(nil, nil) succeeded. Add additional tests against the raw pointers to resolve this. BUG=none TEST=none Review URL: http://codereview.chromium.org/4697004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65710 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'testing')
-rw-r--r--testing/gtest_mac.mm4
-rw-r--r--testing/gtest_mac_unittest.mm10
2 files changed, 12 insertions, 2 deletions
diff --git a/testing/gtest_mac.mm b/testing/gtest_mac.mm
index 3caacdf..94c9a20 100644
--- a/testing/gtest_mac.mm
+++ b/testing/gtest_mac.mm
@@ -21,7 +21,7 @@ GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression,
const char* actual_expression,
id<NSObject> expected,
id<NSObject> actual) {
- if ([expected isEqual:actual]) {
+ if (expected == actual || [expected isEqual:actual]) {
return AssertionSuccess();
}
return EqFailure(expected_expression,
@@ -37,7 +37,7 @@ GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression,
const char* actual_expression,
id<NSObject> expected,
id<NSObject> actual) {
- if (![expected isEqual:actual]) {
+ if (expected != actual && ![expected isEqual:actual]) {
return AssertionSuccess();
}
Message msg;
diff --git a/testing/gtest_mac_unittest.mm b/testing/gtest_mac_unittest.mm
index c5bc47f..1376ed1 100644
--- a/testing/gtest_mac_unittest.mm
+++ b/testing/gtest_mac_unittest.mm
@@ -45,3 +45,13 @@ TEST(GTestMac, AssertNSNE) {
ASSERT_NSNE(@"a", @"b");
}
+
+TEST(GTestMac, ExpectNSNil) {
+ base::mac::ScopedNSAutoreleasePool pool;
+
+ EXPECT_NSEQ(nil, nil);
+ EXPECT_NSNE(nil, @"a");
+ EXPECT_NSNE(@"a", nil);
+
+ // TODO(shess): Test that EXPECT_NSNE(nil, nil) fails.
+}