media/webrtc/trunk/testing/gtest_mac_unittest.mm

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 // Note that while this file is in testing/ and tests GTest macros, it is built
michael@0 6 // as part of Chromium's unit_tests target because the project does not build
michael@0 7 // or run GTest's internal test suite.
michael@0 8
michael@0 9 #import "testing/gtest_mac.h"
michael@0 10
michael@0 11 #import <Foundation/Foundation.h>
michael@0 12
michael@0 13 #include "base/mac/scoped_nsautorelease_pool.h"
michael@0 14 #include "testing/gtest/include/gtest/internal/gtest-port.h"
michael@0 15 #include "testing/gtest/include/gtest/gtest.h"
michael@0 16
michael@0 17 TEST(GTestMac, ExpectNSEQ) {
michael@0 18 base::mac::ScopedNSAutoreleasePool pool;
michael@0 19
michael@0 20 EXPECT_NSEQ(@"a", @"a");
michael@0 21
michael@0 22 NSString* s1 = [NSString stringWithUTF8String:"a"];
michael@0 23 NSString* s2 = [NSString stringWithString:@"a"];
michael@0 24 EXPECT_NE(s1, s2);
michael@0 25 EXPECT_NSEQ(s1, s2);
michael@0 26 }
michael@0 27
michael@0 28 TEST(GTestMac, AssertNSEQ) {
michael@0 29 base::mac::ScopedNSAutoreleasePool pool;
michael@0 30
michael@0 31 NSNumber* n1 = [NSNumber numberWithInt:42];
michael@0 32 NSNumber* n2 = [NSNumber numberWithInt:42];
michael@0 33 EXPECT_NE(n1, n2);
michael@0 34 ASSERT_NSEQ(n1, n2);
michael@0 35 }
michael@0 36
michael@0 37 TEST(GTestMac, ExpectNSNE) {
michael@0 38 base::mac::ScopedNSAutoreleasePool pool;
michael@0 39
michael@0 40 EXPECT_NSNE([NSNumber numberWithInt:2], [NSNumber numberWithInt:42]);
michael@0 41 }
michael@0 42
michael@0 43 TEST(GTestMac, AssertNSNE) {
michael@0 44 base::mac::ScopedNSAutoreleasePool pool;
michael@0 45
michael@0 46 ASSERT_NSNE(@"a", @"b");
michael@0 47 }
michael@0 48
michael@0 49 TEST(GTestMac, ExpectNSNil) {
michael@0 50 base::mac::ScopedNSAutoreleasePool pool;
michael@0 51
michael@0 52 EXPECT_NSEQ(nil, nil);
michael@0 53 EXPECT_NSNE(nil, @"a");
michael@0 54 EXPECT_NSNE(@"a", nil);
michael@0 55
michael@0 56 // TODO(shess): Test that EXPECT_NSNE(nil, nil) fails.
michael@0 57 }

mercurial