Overload EXPECT_NSEQ to handle NSRect/NSPoint.
Previously, the typical pattern is:
EXPECT_TRUE(NSEqualRects(expected_rect, actual_rect));
But this does not print useful information upon failure.
This CL allows tests to compare NSRects with:
EXPECT_NSEQ(expected_rect, actual_rect);
which prints the NSRect upon failure.
Similarly for NSPoint.
BUG=None
Review URL: https://codereview.chromium.org/1211283003
Cr-Commit-Position: refs/heads/master@{#336939}
diff --git a/testing/gtest_mac_unittest.mm b/testing/gtest_mac_unittest.mm
index 01f14979..2dfa24e 100644
--- a/testing/gtest_mac_unittest.mm
+++ b/testing/gtest_mac_unittest.mm
@@ -55,3 +55,55 @@
// TODO(shess): Test that EXPECT_NSNE(nil, nil) fails.
}
+
+#if !defined(GTEST_OS_IOS)
+
+TEST(GTestMac, ExpectNSEQRect) {
+ base::mac::ScopedNSAutoreleasePool pool;
+
+ EXPECT_NSEQ(NSMakeRect(1, 2, 3, 4), NSMakeRect(1, 2, 3, 4));
+}
+
+TEST(GTestMac, AssertNSEQRect) {
+ base::mac::ScopedNSAutoreleasePool pool;
+
+ ASSERT_NSEQ(NSMakeRect(1, 2, 3, 4), NSMakeRect(1, 2, 3, 4));
+}
+
+TEST(GTestMac, ExpectNSNERect) {
+ base::mac::ScopedNSAutoreleasePool pool;
+
+ EXPECT_NSNE(NSMakeRect(1, 2, 3, 4), NSMakeRect(5, 6, 7, 8));
+}
+
+TEST(GTestMac, AssertNSNERect) {
+ base::mac::ScopedNSAutoreleasePool pool;
+
+ ASSERT_NSNE(NSMakeRect(1, 2, 3, 4), NSMakeRect(5, 6, 7, 8));
+}
+
+TEST(GTestMac, ExpectNSEQPoint) {
+ base::mac::ScopedNSAutoreleasePool pool;
+
+ EXPECT_NSEQ(NSMakePoint(1, 2), NSMakePoint(1, 2));
+}
+
+TEST(GTestMac, AssertNSEQPoint) {
+ base::mac::ScopedNSAutoreleasePool pool;
+
+ ASSERT_NSEQ(NSMakePoint(1, 2), NSMakePoint(1, 2));
+}
+
+TEST(GTestMac, ExpectNSNEPoint) {
+ base::mac::ScopedNSAutoreleasePool pool;
+
+ EXPECT_NSNE(NSMakePoint(1, 2), NSMakePoint(3, 4));
+}
+
+TEST(GTestMac, AssertNSNEPoint) {
+ base::mac::ScopedNSAutoreleasePool pool;
+
+ ASSERT_NSNE(NSMakePoint(1, 2), NSMakePoint(3, 4));
+}
+
+#endif // !GTEST_OS_IOS