| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 using base::FilePath; |
| 15 |
| 14 // To test Windows quoting behavior, we use a string that has some backslashes | 16 // To test Windows quoting behavior, we use a string that has some backslashes |
| 15 // and quotes. | 17 // and quotes. |
| 16 // Consider the command-line argument: q\"bs1\bs2\\bs3q\\\" | 18 // Consider the command-line argument: q\"bs1\bs2\\bs3q\\\" |
| 17 // Here it is with C-style escapes. | 19 // Here it is with C-style escapes. |
| 18 static const CommandLine::StringType kTrickyQuoted = | 20 static const CommandLine::StringType kTrickyQuoted = |
| 19 FILE_PATH_LITERAL("q\\\"bs1\\bs2\\\\bs3q\\\\\\\""); | 21 FILE_PATH_LITERAL("q\\\"bs1\\bs2\\\\bs3q\\\\\\\""); |
| 20 // It should be parsed by Windows as: q"bs1\bs2\\bs3q\" | 22 // It should be parsed by Windows as: q"bs1\bs2\\bs3q\" |
| 21 // Here that is with C-style escapes. | 23 // Here that is with C-style escapes. |
| 22 static const CommandLine::StringType kTricky = | 24 static const CommandLine::StringType kTricky = |
| 23 FILE_PATH_LITERAL("q\"bs1\\bs2\\\\bs3q\\\""); | 25 FILE_PATH_LITERAL("q\"bs1\\bs2\\\\bs3q\\\""); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 } | 351 } |
| 350 #endif | 352 #endif |
| 351 | 353 |
| 352 // Calling Init multiple times should not modify the previous CommandLine. | 354 // Calling Init multiple times should not modify the previous CommandLine. |
| 353 TEST(CommandLineTest, Init) { | 355 TEST(CommandLineTest, Init) { |
| 354 CommandLine* initial = CommandLine::ForCurrentProcess(); | 356 CommandLine* initial = CommandLine::ForCurrentProcess(); |
| 355 EXPECT_FALSE(CommandLine::Init(0, NULL)); | 357 EXPECT_FALSE(CommandLine::Init(0, NULL)); |
| 356 CommandLine* current = CommandLine::ForCurrentProcess(); | 358 CommandLine* current = CommandLine::ForCurrentProcess(); |
| 357 EXPECT_EQ(initial, current); | 359 EXPECT_EQ(initial, current); |
| 358 } | 360 } |
| OLD | NEW |