blob: 1376ed1eb2a908e8526b039f5699f7179ad62a14 [file] [log] [blame]
[email protected]ecebcc92010-08-06 02:39:261// 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// 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]c2818d42010-10-18 02:47:3913#include "base/mac/scoped_nsautorelease_pool.h"
[email protected]ecebcc92010-08-06 02:39:2614#include "testing/gtest/include/gtest/internal/gtest-port.h"
15#include "testing/gtest/include/gtest/gtest.h"
16
17TEST(GTestMac, ExpectNSEQ) {
[email protected]c2818d42010-10-18 02:47:3918 base::mac::ScopedNSAutoreleasePool pool;
[email protected]ecebcc92010-08-06 02:39:2619
20 EXPECT_NSEQ(@"a", @"a");
21
22 NSString* s1 = [NSString stringWithUTF8String:"a"];
23 NSString* s2 = [NSString stringWithString:@"a"];
24 EXPECT_NE(s1, s2);
25 EXPECT_NSEQ(s1, s2);
26}
27
28TEST(GTestMac, AssertNSEQ) {
[email protected]c2818d42010-10-18 02:47:3929 base::mac::ScopedNSAutoreleasePool pool;
[email protected]ecebcc92010-08-06 02:39:2630
31 NSNumber* n1 = [NSNumber numberWithInt:42];
32 NSNumber* n2 = [NSNumber numberWithInt:42];
33 EXPECT_NE(n1, n2);
34 ASSERT_NSEQ(n1, n2);
35}
36
37TEST(GTestMac, ExpectNSNE) {
[email protected]c2818d42010-10-18 02:47:3938 base::mac::ScopedNSAutoreleasePool pool;
[email protected]ecebcc92010-08-06 02:39:2639
40 EXPECT_NSNE([NSNumber numberWithInt:2], [NSNumber numberWithInt:42]);
41}
42
43TEST(GTestMac, AssertNSNE) {
[email protected]c2818d42010-10-18 02:47:3944 base::mac::ScopedNSAutoreleasePool pool;
[email protected]ecebcc92010-08-06 02:39:2645
46 ASSERT_NSNE(@"a", @"b");
47}
[email protected]22f73592010-11-10 21:50:3848
49TEST(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}