Fix emulator build error
[platform/framework/web/chromium-efl.git] / testing / gtest_mac_unittest.mm
1 // Copyright 2012 The Chromium Authors
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
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h"
15
16 namespace testing {
17 namespace internal {
18 // This function is tested within this file, but it's not part of the public
19 // API, and since it's a free function there's no way to friend the test for it.
20 extern std::string StringDescription(id<NSObject> obj);
21 }
22 }
23
24 TEST(GTestMac, NSStringComparators) {
25   // This test wants to really guarantee that s1 and s2 aren't the same address,
26   // so it constructs a string this way. In theory this could be done via
27   // [NSString stringWithString:] but that causes an error about using a
28   // redundant literal :)
29   NSString* s1 = [NSString stringWithFormat:@"%@", @"a"];
30   NSString* s2 = @"a";
31
32   EXPECT_NSEQ(@"a", @"a");
33   EXPECT_NE(s1, s2);
34   EXPECT_NSEQ(s1, s2);
35   ASSERT_NE(s1, s2);
36   ASSERT_NSEQ(s1, s2);
37
38   ASSERT_NSNE(@"a", @"b");
39
40   EXPECT_NSEQ(nil, nil);
41   EXPECT_NSNE(nil, @"a");
42   EXPECT_NSNE(@"a", nil);
43 }
44
45 TEST(GTestMac, NSNumberComparators) {
46   EXPECT_NSNE(@2, @42);
47   EXPECT_NSEQ(@42, @42);
48 }
49
50 #if !defined(GTEST_OS_IOS)
51
52 TEST(GTestMac, NSRectComparators) {
53   ASSERT_NSEQ(NSMakeRect(1, 2, 3, 4), NSMakeRect(1, 2, 3, 4));
54   ASSERT_NSNE(NSMakeRect(1, 2, 3, 4), NSMakeRect(5, 6, 7, 8));
55
56   EXPECT_NSEQ(NSMakeRect(1, 2, 3, 4), NSMakeRect(1, 2, 3, 4));
57   EXPECT_NSNE(NSMakeRect(1, 2, 3, 4), NSMakeRect(5, 6, 7, 8));
58 }
59
60 TEST(GTestMac, NSPointComparators) {
61   ASSERT_NSEQ(NSMakePoint(1, 2), NSMakePoint(1, 2));
62   ASSERT_NSNE(NSMakePoint(1, 2), NSMakePoint(1, 3));
63   ASSERT_NSNE(NSMakePoint(1, 2), NSMakePoint(2, 2));
64
65   EXPECT_NSEQ(NSMakePoint(3, 4), NSMakePoint(3, 4));
66   EXPECT_NSNE(NSMakePoint(3, 4), NSMakePoint(3, 3));
67   EXPECT_NSNE(NSMakePoint(3, 4), NSMakePoint(4, 3));
68 }
69
70 TEST(GTestMac, NSRangeComparators) {
71   ASSERT_NSEQ(NSMakeRange(1, 2), NSMakeRange(1, 2));
72   ASSERT_NSNE(NSMakeRange(1, 2), NSMakeRange(1, 3));
73   ASSERT_NSNE(NSMakeRange(1, 2), NSMakeRange(2, 2));
74
75   EXPECT_NSEQ(NSMakeRange(3, 4), NSMakeRange(3, 4));
76   EXPECT_NSNE(NSMakeRange(3, 4), NSMakeRange(3, 3));
77   EXPECT_NSNE(NSMakeRange(3, 4), NSMakeRange(4, 4));
78 }
79
80 TEST(GTestMac, StringDescription) {
81   using testing::internal::StringDescription;
82   EXPECT_EQ(StringDescription(@4), "4");
83   EXPECT_EQ(StringDescription(@"foo"), "foo");
84   EXPECT_EQ(StringDescription(nil), "(null)");
85 }
86
87 #endif  // !GTEST_OS_IOS