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/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/format_macros.h" | |
9 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
10 #include "base/mac/scoped_nsautorelease_pool.h" | 11 #include "base/mac/scoped_nsautorelease_pool.h" |
12 #include "base/strings/stringprintf.h" | |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 #import "testing/gtest_mac.h" | 14 #import "testing/gtest_mac.h" |
13 | 15 |
14 namespace base { | 16 namespace base { |
15 namespace mac { | 17 namespace mac { |
16 | 18 |
17 TEST(FoundationUtilTest, CFCast) { | 19 TEST(FoundationUtilTest, CFCast) { |
18 // Build out the CF types to be tested as empty containers. | 20 // Build out the CF types to be tested as empty containers. |
19 ScopedCFTypeRef<CFTypeRef> test_array( | 21 ScopedCFTypeRef<CFTypeRef> test_array( |
20 CFArrayCreate(NULL, NULL, 0, &kCFTypeArrayCallBacks)); | 22 CFArrayCreate(NULL, NULL, 0, &kCFTypeArrayCallBacks)); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 EXPECT_NSEQ(nil, FilePathToNSString(FilePath())); | 309 EXPECT_NSEQ(nil, FilePathToNSString(FilePath())); |
308 EXPECT_NSEQ(@"/a/b", FilePathToNSString(FilePath("/a/b"))); | 310 EXPECT_NSEQ(@"/a/b", FilePathToNSString(FilePath("/a/b"))); |
309 } | 311 } |
310 | 312 |
311 TEST(FoundationUtilTest, NSStringToFilePath) { | 313 TEST(FoundationUtilTest, NSStringToFilePath) { |
312 EXPECT_EQ(FilePath(), NSStringToFilePath(nil)); | 314 EXPECT_EQ(FilePath(), NSStringToFilePath(nil)); |
313 EXPECT_EQ(FilePath(), NSStringToFilePath(@"")); | 315 EXPECT_EQ(FilePath(), NSStringToFilePath(@"")); |
314 EXPECT_EQ(FilePath("/a/b"), NSStringToFilePath(@"/a/b")); | 316 EXPECT_EQ(FilePath("/a/b"), NSStringToFilePath(@"/a/b")); |
315 } | 317 } |
316 | 318 |
319 TEST(StringNumberConversionsTest, FormatNSInteger) { | |
320 const NSInteger kNSInteger = 12345678; | |
321 const NSUInteger kNSUInteger = 12345678u; | |
322 EXPECT_EQ("12345678", StringPrintf("%" PRIdNS, kNSInteger)); | |
Mark Mentovai
2014/03/06 14:44:57
Test that PRIdNS formats negative signed numbers p
sdefresne
2014/03/06 16:27:05
Done.
| |
323 EXPECT_EQ("12345678", StringPrintf("%" PRIuNS, kNSUInteger)); | |
324 EXPECT_EQ("bc614e", StringPrintf("%" PRIxNS, kNSInteger)); | |
325 } | |
Mark Mentovai
2014/03/06 14:44:57
#ifdef __LP64__, do a couple of tests with things
sdefresne
2014/03/06 16:27:05
Done.
| |
326 | |
317 } // namespace mac | 327 } // namespace mac |
318 } // namespace base | 328 } // namespace base |
OLD | NEW |