0
Files
android_webview
apps
ash
base
build
build_overrides
buildtools
cc
chrome
chromecast
chromeos
clank
codelabs
components
content
crypto
dbus
device
docs
extensions
fuchsia_web
gin
google_apis
gpu
headless
infra
internal
ios
ios_internal
ipc
media
mojo
native_client
native_client_sdk
net
pdf
ppapi
printing
remoting
rlz
sandbox
services
signing_keys
skia
sql
storage
styleguide
testing
android
buildbot
chromoting
clusterfuzz
data_driven_testing
flake_suppressor_common
gmock
gtest
gtest_ios
iossim
libfuzzer
merge_scripts
perf
pytype_common
rust_gtest_interop
scripts
trigger_scripts
unexpected_passes_common
variations
.style.yapf
BUILD.gn
DIR_METADATA
OWNERS
PRESUBMIT.py
__init__.py
coverage_util_ios.h
coverage_util_ios.mm
empty_main.cc
generate_location_tags.py
gtest_mac.h
gtest_mac.mm
gtest_mac_unittest.mm
multiprocess_func_list.cc
multiprocess_func_list.h
platform_test.h
platform_test_mac.mm
pylintrc
run_pytype.py
run_with_dummy_home.py
test.gni
test_env.py
test_env_test_script.py
test_env_unittest.py
test_env_user_script.py
xvfb.py
xvfb_test_script.py
xvfb_unittest.py
third_party
tools
ui
url
v8
webkit
.clang-format
.clang-tidy
.clangd
.git-blame-ignore-revs
.gitallowed
.gitattributes
.gitignore
.gitmodules
.gn
.mailmap
.rustfmt.toml
.vpython3
.yapfignore
ATL_OWNERS
AUTHORS
BUILD.gn
CODE_OF_CONDUCT.md
CPPLINT.cfg
CRYPTO_OWNERS
DEPS
DIR_METADATA
LICENSE
LICENSE.chromium_os
OWNERS
PRESUBMIT.py
PRESUBMIT_test.py
PRESUBMIT_test_mocks.py
README.md
WATCHLISTS
codereview.settings
src/testing/gtest_mac_unittest.mm
Avi Drissman 73454f7952 Remove ARC boilerplate in /testing
ARC is now enabled by default, so there’s no need to enforce it
against files being put into non-ARC targets.

Bug: 1468376
Change-Id: I37301595ee8b96525f491622cc272d062c76526e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4742578
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: Adrian Taylor <adetaylor@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Reviewed-by: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1179056}
2023-08-03 15:44:16 +00:00

88 lines
2.7 KiB
Plaintext

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Note that while this file is in testing/ and tests GTest macros, it is built
// as part of Chromium's unit_tests target because the project does not build
// or run GTest's internal test suite.
#import "testing/gtest_mac.h"
#import <Foundation/Foundation.h>
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h"
namespace testing {
namespace internal {
// This function is tested within this file, but it's not part of the public
// API, and since it's a free function there's no way to friend the test for it.
extern std::string StringDescription(id<NSObject> obj);
}
}
TEST(GTestMac, NSStringComparators) {
// This test wants to really guarantee that s1 and s2 aren't the same address,
// so it constructs a string this way. In theory this could be done via
// [NSString stringWithString:] but that causes an error about using a
// redundant literal :)
NSString* s1 = [NSString stringWithFormat:@"%@", @"a"];
NSString* s2 = @"a";
EXPECT_NSEQ(@"a", @"a");
EXPECT_NE(s1, s2);
EXPECT_NSEQ(s1, s2);
ASSERT_NE(s1, s2);
ASSERT_NSEQ(s1, s2);
ASSERT_NSNE(@"a", @"b");
EXPECT_NSEQ(nil, nil);
EXPECT_NSNE(nil, @"a");
EXPECT_NSNE(@"a", nil);
}
TEST(GTestMac, NSNumberComparators) {
EXPECT_NSNE(@2, @42);
EXPECT_NSEQ(@42, @42);
}
#if !defined(GTEST_OS_IOS)
TEST(GTestMac, NSRectComparators) {
ASSERT_NSEQ(NSMakeRect(1, 2, 3, 4), NSMakeRect(1, 2, 3, 4));
ASSERT_NSNE(NSMakeRect(1, 2, 3, 4), NSMakeRect(5, 6, 7, 8));
EXPECT_NSEQ(NSMakeRect(1, 2, 3, 4), NSMakeRect(1, 2, 3, 4));
EXPECT_NSNE(NSMakeRect(1, 2, 3, 4), NSMakeRect(5, 6, 7, 8));
}
TEST(GTestMac, NSPointComparators) {
ASSERT_NSEQ(NSMakePoint(1, 2), NSMakePoint(1, 2));
ASSERT_NSNE(NSMakePoint(1, 2), NSMakePoint(1, 3));
ASSERT_NSNE(NSMakePoint(1, 2), NSMakePoint(2, 2));
EXPECT_NSEQ(NSMakePoint(3, 4), NSMakePoint(3, 4));
EXPECT_NSNE(NSMakePoint(3, 4), NSMakePoint(3, 3));
EXPECT_NSNE(NSMakePoint(3, 4), NSMakePoint(4, 3));
}
TEST(GTestMac, NSRangeComparators) {
ASSERT_NSEQ(NSMakeRange(1, 2), NSMakeRange(1, 2));
ASSERT_NSNE(NSMakeRange(1, 2), NSMakeRange(1, 3));
ASSERT_NSNE(NSMakeRange(1, 2), NSMakeRange(2, 2));
EXPECT_NSEQ(NSMakeRange(3, 4), NSMakeRange(3, 4));
EXPECT_NSNE(NSMakeRange(3, 4), NSMakeRange(3, 3));
EXPECT_NSNE(NSMakeRange(3, 4), NSMakeRange(4, 4));
}
TEST(GTestMac, StringDescription) {
using testing::internal::StringDescription;
EXPECT_EQ(StringDescription(@4), "4");
EXPECT_EQ(StringDescription(@"foo"), "foo");
EXPECT_EQ(StringDescription(nil), "(null)");
}
#endif // !GTEST_OS_IOS