| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/mac/foundation_util.h" | 5 #include "base/mac/foundation_util.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 EXPECT_NSEQ(nil, FilePathToNSString(FilePath())); | 310 EXPECT_NSEQ(nil, FilePathToNSString(FilePath())); |
| 311 EXPECT_NSEQ(@"/a/b", FilePathToNSString(FilePath("/a/b"))); | 311 EXPECT_NSEQ(@"/a/b", FilePathToNSString(FilePath("/a/b"))); |
| 312 } | 312 } |
| 313 | 313 |
| 314 TEST(FoundationUtilTest, NSStringToFilePath) { | 314 TEST(FoundationUtilTest, NSStringToFilePath) { |
| 315 EXPECT_EQ(FilePath(), NSStringToFilePath(nil)); | 315 EXPECT_EQ(FilePath(), NSStringToFilePath(nil)); |
| 316 EXPECT_EQ(FilePath(), NSStringToFilePath(@"")); | 316 EXPECT_EQ(FilePath(), NSStringToFilePath(@"")); |
| 317 EXPECT_EQ(FilePath("/a/b"), NSStringToFilePath(@"/a/b")); | 317 EXPECT_EQ(FilePath("/a/b"), NSStringToFilePath(@"/a/b")); |
| 318 } | 318 } |
| 319 | 319 |
| 320 TEST(FoundationUtilTest, CFRangeToNSRange) { |
| 321 NSRange range_out; |
| 322 EXPECT_TRUE(CFRangeToNSRange(CFRangeMake(10, 5), &range_out)); |
| 323 EXPECT_EQ(10UL, range_out.location); |
| 324 EXPECT_EQ(5UL, range_out.length); |
| 325 EXPECT_FALSE(CFRangeToNSRange(CFRangeMake(-1, 5), &range_out)); |
| 326 EXPECT_FALSE(CFRangeToNSRange(CFRangeMake(5, -1), &range_out)); |
| 327 EXPECT_FALSE(CFRangeToNSRange(CFRangeMake(-1, -1), &range_out)); |
| 328 EXPECT_FALSE(CFRangeToNSRange(CFRangeMake(LONG_MAX, LONG_MAX), &range_out)); |
| 329 EXPECT_FALSE(CFRangeToNSRange(CFRangeMake(LONG_MIN, LONG_MAX), &range_out)); |
| 330 } |
| 331 |
| 320 TEST(StringNumberConversionsTest, FormatNSInteger) { | 332 TEST(StringNumberConversionsTest, FormatNSInteger) { |
| 321 // The PRI[dxu]NS macro assumes that NSInteger is a typedef to "int" on | 333 // The PRI[dxu]NS macro assumes that NSInteger is a typedef to "int" on |
| 322 // 32-bit architecture and a typedef to "long" on 64-bit architecture | 334 // 32-bit architecture and a typedef to "long" on 64-bit architecture |
| 323 // (respectively "unsigned int" and "unsigned long" for NSUInteger). Use | 335 // (respectively "unsigned int" and "unsigned long" for NSUInteger). Use |
| 324 // pointer incompatibility to validate this at compilation. | 336 // pointer incompatibility to validate this at compilation. |
| 325 #if defined(ARCH_CPU_64_BITS) | 337 #if defined(ARCH_CPU_64_BITS) |
| 326 typedef long FormatNSIntegerAsType; | 338 typedef long FormatNSIntegerAsType; |
| 327 typedef unsigned long FormatNSUIntegerAsType; | 339 typedef unsigned long FormatNSUIntegerAsType; |
| 328 #else | 340 #else |
| 329 typedef int FormatNSIntegerAsType; | 341 typedef int FormatNSIntegerAsType; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 for (size_t i = 0; i < arraysize(nsuinteger_cases); ++i) { | 394 for (size_t i = 0; i < arraysize(nsuinteger_cases); ++i) { |
| 383 EXPECT_EQ(nsuinteger_cases[i].expected, | 395 EXPECT_EQ(nsuinteger_cases[i].expected, |
| 384 StringPrintf("%" PRIuNS, nsuinteger_cases[i].value)); | 396 StringPrintf("%" PRIuNS, nsuinteger_cases[i].value)); |
| 385 EXPECT_EQ(nsuinteger_cases[i].expected_hex, | 397 EXPECT_EQ(nsuinteger_cases[i].expected_hex, |
| 386 StringPrintf("%" PRIxNS, nsuinteger_cases[i].value)); | 398 StringPrintf("%" PRIxNS, nsuinteger_cases[i].value)); |
| 387 } | 399 } |
| 388 } | 400 } |
| 389 | 401 |
| 390 } // namespace mac | 402 } // namespace mac |
| 391 } // namespace base | 403 } // namespace base |
| OLD | NEW |