media/webrtc/trunk/testing/gtest_mac_unittest.mm

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/trunk/testing/gtest_mac_unittest.mm	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +// Copyright (c) 2010 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +// Note that while this file is in testing/ and tests GTest macros, it is built
     1.9 +// as part of Chromium's unit_tests target because the project does not build
    1.10 +// or run GTest's internal test suite.
    1.11 +
    1.12 +#import "testing/gtest_mac.h"
    1.13 +
    1.14 +#import <Foundation/Foundation.h>
    1.15 +
    1.16 +#include "base/mac/scoped_nsautorelease_pool.h"
    1.17 +#include "testing/gtest/include/gtest/internal/gtest-port.h"
    1.18 +#include "testing/gtest/include/gtest/gtest.h"
    1.19 +
    1.20 +TEST(GTestMac, ExpectNSEQ) {
    1.21 +  base::mac::ScopedNSAutoreleasePool pool;
    1.22 +
    1.23 +  EXPECT_NSEQ(@"a", @"a");
    1.24 +
    1.25 +  NSString* s1 = [NSString stringWithUTF8String:"a"];
    1.26 +  NSString* s2 = [NSString stringWithString:@"a"];
    1.27 +  EXPECT_NE(s1, s2);
    1.28 +  EXPECT_NSEQ(s1, s2);
    1.29 +}
    1.30 +
    1.31 +TEST(GTestMac, AssertNSEQ) {
    1.32 +  base::mac::ScopedNSAutoreleasePool pool;
    1.33 +
    1.34 +  NSNumber* n1 = [NSNumber numberWithInt:42];
    1.35 +  NSNumber* n2 = [NSNumber numberWithInt:42];
    1.36 +  EXPECT_NE(n1, n2);
    1.37 +  ASSERT_NSEQ(n1, n2);
    1.38 +}
    1.39 +
    1.40 +TEST(GTestMac, ExpectNSNE) {
    1.41 +  base::mac::ScopedNSAutoreleasePool pool;
    1.42 +
    1.43 +  EXPECT_NSNE([NSNumber numberWithInt:2], [NSNumber numberWithInt:42]);
    1.44 +}
    1.45 +
    1.46 +TEST(GTestMac, AssertNSNE) {
    1.47 +  base::mac::ScopedNSAutoreleasePool pool;
    1.48 +
    1.49 +  ASSERT_NSNE(@"a", @"b");
    1.50 +}
    1.51 +
    1.52 +TEST(GTestMac, ExpectNSNil) {
    1.53 +  base::mac::ScopedNSAutoreleasePool pool;
    1.54 +
    1.55 +  EXPECT_NSEQ(nil, nil);
    1.56 +  EXPECT_NSNE(nil, @"a");
    1.57 +  EXPECT_NSNE(@"a", nil);
    1.58 +
    1.59 +  // TODO(shess): Test that EXPECT_NSNE(nil, nil) fails.
    1.60 +}

mercurial