[email protected] | 662430b | 2012-03-14 20:30:07 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | ecebcc9 | 2010-08-06 02:39:26 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Note that while this file is in testing/ and tests GTest macros, it is built |
| 6 | // as part of Chromium's unit_tests target because the project does not build |
| 7 | // or run GTest's internal test suite. |
| 8 | |
| 9 | #import "testing/gtest_mac.h" |
| 10 | |
| 11 | #import <Foundation/Foundation.h> |
| 12 | |
[email protected] | c2818d4 | 2010-10-18 02:47:39 | [diff] [blame] | 13 | #include "base/mac/scoped_nsautorelease_pool.h" |
[email protected] | ecebcc9 | 2010-08-06 02:39:26 | [diff] [blame] | 14 | #include "testing/gtest/include/gtest/gtest.h" |
tapted | 574f09c | 2015-05-19 13:08:08 | [diff] [blame] | 15 | #include "testing/gtest/include/gtest/internal/gtest-port.h" |
[email protected] | ecebcc9 | 2010-08-06 02:39:26 | [diff] [blame] | 16 | |
| 17 | TEST(GTestMac, ExpectNSEQ) { |
[email protected] | c2818d4 | 2010-10-18 02:47:39 | [diff] [blame] | 18 | base::mac::ScopedNSAutoreleasePool pool; |
[email protected] | ecebcc9 | 2010-08-06 02:39:26 | [diff] [blame] | 19 | |
| 20 | EXPECT_NSEQ(@"a", @"a"); |
| 21 | |
| 22 | NSString* s1 = [NSString stringWithUTF8String:"a"]; |
[email protected] | 662430b | 2012-03-14 20:30:07 | [diff] [blame] | 23 | NSString* s2 = @"a"; |
[email protected] | ecebcc9 | 2010-08-06 02:39:26 | [diff] [blame] | 24 | EXPECT_NE(s1, s2); |
| 25 | EXPECT_NSEQ(s1, s2); |
| 26 | } |
| 27 | |
| 28 | TEST(GTestMac, AssertNSEQ) { |
[email protected] | c2818d4 | 2010-10-18 02:47:39 | [diff] [blame] | 29 | base::mac::ScopedNSAutoreleasePool pool; |
[email protected] | ecebcc9 | 2010-08-06 02:39:26 | [diff] [blame] | 30 | |
[email protected] | cee49d2 | 2013-05-29 19:50:01 | [diff] [blame] | 31 | NSString* s1 = [NSString stringWithUTF8String:"a"]; |
| 32 | NSString* s2 = @"a"; |
| 33 | EXPECT_NE(s1, s2); |
| 34 | ASSERT_NSEQ(s1, s2); |
[email protected] | ecebcc9 | 2010-08-06 02:39:26 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | TEST(GTestMac, ExpectNSNE) { |
[email protected] | c2818d4 | 2010-10-18 02:47:39 | [diff] [blame] | 38 | base::mac::ScopedNSAutoreleasePool pool; |
[email protected] | ecebcc9 | 2010-08-06 02:39:26 | [diff] [blame] | 39 | |
| 40 | EXPECT_NSNE([NSNumber numberWithInt:2], [NSNumber numberWithInt:42]); |
| 41 | } |
| 42 | |
| 43 | TEST(GTestMac, AssertNSNE) { |
[email protected] | c2818d4 | 2010-10-18 02:47:39 | [diff] [blame] | 44 | base::mac::ScopedNSAutoreleasePool pool; |
[email protected] | ecebcc9 | 2010-08-06 02:39:26 | [diff] [blame] | 45 | |
| 46 | ASSERT_NSNE(@"a", @"b"); |
| 47 | } |
[email protected] | 22f7359 | 2010-11-10 21:50:38 | [diff] [blame] | 48 | |
| 49 | TEST(GTestMac, ExpectNSNil) { |
| 50 | base::mac::ScopedNSAutoreleasePool pool; |
| 51 | |
| 52 | EXPECT_NSEQ(nil, nil); |
| 53 | EXPECT_NSNE(nil, @"a"); |
| 54 | EXPECT_NSNE(@"a", nil); |
| 55 | |
| 56 | // TODO(shess): Test that EXPECT_NSNE(nil, nil) fails. |
| 57 | } |
jackhou | b22ade8 | 2015-07-01 00:44:39 | [diff] [blame] | 58 | |
| 59 | #if !defined(GTEST_OS_IOS) |
| 60 | |
| 61 | TEST(GTestMac, ExpectNSEQRect) { |
| 62 | base::mac::ScopedNSAutoreleasePool pool; |
| 63 | |
| 64 | EXPECT_NSEQ(NSMakeRect(1, 2, 3, 4), NSMakeRect(1, 2, 3, 4)); |
| 65 | } |
| 66 | |
| 67 | TEST(GTestMac, AssertNSEQRect) { |
| 68 | base::mac::ScopedNSAutoreleasePool pool; |
| 69 | |
| 70 | ASSERT_NSEQ(NSMakeRect(1, 2, 3, 4), NSMakeRect(1, 2, 3, 4)); |
| 71 | } |
| 72 | |
| 73 | TEST(GTestMac, ExpectNSNERect) { |
| 74 | base::mac::ScopedNSAutoreleasePool pool; |
| 75 | |
| 76 | EXPECT_NSNE(NSMakeRect(1, 2, 3, 4), NSMakeRect(5, 6, 7, 8)); |
| 77 | } |
| 78 | |
| 79 | TEST(GTestMac, AssertNSNERect) { |
| 80 | base::mac::ScopedNSAutoreleasePool pool; |
| 81 | |
| 82 | ASSERT_NSNE(NSMakeRect(1, 2, 3, 4), NSMakeRect(5, 6, 7, 8)); |
| 83 | } |
| 84 | |
| 85 | TEST(GTestMac, ExpectNSEQPoint) { |
| 86 | base::mac::ScopedNSAutoreleasePool pool; |
| 87 | |
| 88 | EXPECT_NSEQ(NSMakePoint(1, 2), NSMakePoint(1, 2)); |
| 89 | } |
| 90 | |
| 91 | TEST(GTestMac, AssertNSEQPoint) { |
| 92 | base::mac::ScopedNSAutoreleasePool pool; |
| 93 | |
| 94 | ASSERT_NSEQ(NSMakePoint(1, 2), NSMakePoint(1, 2)); |
| 95 | } |
| 96 | |
| 97 | TEST(GTestMac, ExpectNSNEPoint) { |
| 98 | base::mac::ScopedNSAutoreleasePool pool; |
| 99 | |
| 100 | EXPECT_NSNE(NSMakePoint(1, 2), NSMakePoint(3, 4)); |
| 101 | } |
| 102 | |
| 103 | TEST(GTestMac, AssertNSNEPoint) { |
| 104 | base::mac::ScopedNSAutoreleasePool pool; |
| 105 | |
| 106 | ASSERT_NSNE(NSMakePoint(1, 2), NSMakePoint(3, 4)); |
| 107 | } |
| 108 | |
| 109 | #endif // !GTEST_OS_IOS |