Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2918)

Unified Diff: base/command_line_unittest.cc

Issue 645133002: Prefix CommandLine usege with base namespace (Part 1: base/) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/i18n/build_utf8_validator_tables.cc » ('j') | base/test/launcher/test_results_tracker.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/command_line_unittest.cc
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc
index 8fdd605db79249f31179fababa00c706f9cbb263..1384fdc7956f6aacd64ea87ff7186c7b4b0d7541 100644
--- a/base/command_line_unittest.cc
+++ b/base/command_line_unittest.cc
@@ -17,15 +17,15 @@ using base::FilePath;
// and quotes.
// Consider the command-line argument: q\"bs1\bs2\\bs3q\\\"
// Here it is with C-style escapes.
-static const CommandLine::StringType kTrickyQuoted =
+static const base::CommandLine::StringType kTrickyQuoted =
FILE_PATH_LITERAL("q\\\"bs1\\bs2\\\\bs3q\\\\\\\"");
// It should be parsed by Windows as: q"bs1\bs2\\bs3q\"
// Here that is with C-style escapes.
-static const CommandLine::StringType kTricky =
+static const base::CommandLine::StringType kTricky =
FILE_PATH_LITERAL("q\"bs1\\bs2\\\\bs3q\\\"");
TEST(CommandLineTest, CommandLineConstructor) {
- const CommandLine::CharType* argv[] = {
+ const base::CommandLine::CharType* argv[] = {
FILE_PATH_LITERAL("program"),
FILE_PATH_LITERAL("--foo="),
FILE_PATH_LITERAL("-bAr"),
@@ -44,7 +44,7 @@ TEST(CommandLineTest, CommandLineConstructor) {
FILE_PATH_LITERAL("--not-a-switch"),
FILE_PATH_LITERAL("\"in the time of submarines...\""),
FILE_PATH_LITERAL("unquoted arg-with-space")};
- CommandLine cl(arraysize(argv), argv);
+ base::CommandLine cl(arraysize(argv), argv);
EXPECT_FALSE(cl.GetCommandLineString().empty());
EXPECT_FALSE(cl.HasSwitch("cruller"));
@@ -77,10 +77,11 @@ TEST(CommandLineTest, CommandLineConstructor) {
"other-switches"));
EXPECT_EQ("45--output-rotation", cl.GetSwitchValueASCII("input-translation"));
- const CommandLine::StringVector& args = cl.GetArgs();
+ const base::CommandLine::StringVector& args = cl.GetArgs();
ASSERT_EQ(8U, args.size());
- std::vector<CommandLine::StringType>::const_iterator iter = args.begin();
+ std::vector<base::CommandLine::StringType>::const_iterator iter =
+ args.begin();
EXPECT_EQ(FILE_PATH_LITERAL("flim"), *iter);
++iter;
EXPECT_EQ(FILE_PATH_LITERAL("-"), *iter);
@@ -102,7 +103,7 @@ TEST(CommandLineTest, CommandLineConstructor) {
TEST(CommandLineTest, CommandLineFromString) {
#if defined(OS_WIN)
- CommandLine cl = CommandLine::FromString(
+ base::CommandLine cl = base::CommandLine::FromString(
L"program --foo= -bAr /Spaetzel=pierogi /Baz flim "
L"--other-switches=\"--dog=canine --cat=feline\" "
L"-spaetzle=Crepe -=loosevalue FLAN "
@@ -142,10 +143,11 @@ TEST(CommandLineTest, CommandLineFromString) {
EXPECT_EQ("45--output-rotation", cl.GetSwitchValueASCII("input-translation"));
EXPECT_EQ(kTricky, cl.GetSwitchValueNative("quotes"));
- const CommandLine::StringVector& args = cl.GetArgs();
+ const base::CommandLine::StringVector& args = cl.GetArgs();
ASSERT_EQ(5U, args.size());
- std::vector<CommandLine::StringType>::const_iterator iter = args.begin();
+ std::vector<base::CommandLine::StringType>::const_iterator iter =
+ args.begin();
EXPECT_EQ(FILE_PATH_LITERAL("flim"), *iter);
++iter;
EXPECT_EQ(FILE_PATH_LITERAL("FLAN"), *iter);
@@ -159,7 +161,8 @@ TEST(CommandLineTest, CommandLineFromString) {
EXPECT_TRUE(iter == args.end());
// Check that a generated string produces an equivalent command line.
- CommandLine cl_duplicate = CommandLine::FromString(cl.GetCommandLineString());
+ base::CommandLine cl_duplicate =
+ base::CommandLine::FromString(cl.GetCommandLineString());
EXPECT_EQ(cl.GetCommandLineString(), cl_duplicate.GetCommandLineString());
#endif
}
@@ -167,13 +170,13 @@ TEST(CommandLineTest, CommandLineFromString) {
// Tests behavior with an empty input string.
TEST(CommandLineTest, EmptyString) {
#if defined(OS_WIN)
- CommandLine cl_from_string = CommandLine::FromString(L"");
+ base::CommandLine cl_from_string = base::CommandLine::FromString(L"");
EXPECT_TRUE(cl_from_string.GetCommandLineString().empty());
EXPECT_TRUE(cl_from_string.GetProgram().empty());
EXPECT_EQ(1U, cl_from_string.argv().size());
EXPECT_TRUE(cl_from_string.GetArgs().empty());
#endif
- CommandLine cl_from_argv(0, NULL);
+ base::CommandLine cl_from_argv(0, NULL);
EXPECT_TRUE(cl_from_argv.GetCommandLineString().empty());
EXPECT_TRUE(cl_from_argv.GetProgram().empty());
EXPECT_EQ(1U, cl_from_argv.argv().size());
@@ -192,7 +195,7 @@ TEST(CommandLineTest, GetArgumentsString) {
static const char kFourthArgName[] = "nospace";
static const char kFifthArgName[] = "%1";
- CommandLine cl(CommandLine::NO_PROGRAM);
+ base::CommandLine cl(base::CommandLine::NO_PROGRAM);
cl.AppendSwitchPath(kFirstArgName, FilePath(kPath1));
cl.AppendSwitchPath(kSecondArgName, FilePath(kPath2));
cl.AppendArg(kThirdArgName);
@@ -200,21 +203,22 @@ TEST(CommandLineTest, GetArgumentsString) {
cl.AppendArg(kFifthArgName);
#if defined(OS_WIN)
- CommandLine::StringType expected_first_arg(
+ base::CommandLine::StringType expected_first_arg(
base::UTF8ToUTF16(kFirstArgName));
- CommandLine::StringType expected_second_arg(
+ base::CommandLine::StringType expected_second_arg(
base::UTF8ToUTF16(kSecondArgName));
- CommandLine::StringType expected_third_arg(
+ base::CommandLine::StringType expected_third_arg(
base::UTF8ToUTF16(kThirdArgName));
- CommandLine::StringType expected_fourth_arg(
+ base::CommandLine::StringType expected_fourth_arg(
base::UTF8ToUTF16(kFourthArgName));
- CommandLine::StringType expected_fifth_arg(base::UTF8ToUTF16(kFifthArgName));
+ base::CommandLine::StringType expected_fifth_arg(
+ base::UTF8ToUTF16(kFifthArgName));
#elif defined(OS_POSIX)
- CommandLine::StringType expected_first_arg(kFirstArgName);
- CommandLine::StringType expected_second_arg(kSecondArgName);
- CommandLine::StringType expected_third_arg(kThirdArgName);
- CommandLine::StringType expected_fourth_arg(kFourthArgName);
- CommandLine::StringType expected_fifth_arg(kFifthArgName);
+ base::CommandLine::StringType expected_first_arg(kFirstArgName);
+ base::CommandLine::StringType expected_second_arg(kSecondArgName);
+ base::CommandLine::StringType expected_third_arg(kThirdArgName);
+ base::CommandLine::StringType expected_fourth_arg(kFourthArgName);
+ base::CommandLine::StringType expected_fifth_arg(kFifthArgName);
#endif
#if defined(OS_WIN)
@@ -223,7 +227,7 @@ TEST(CommandLineTest, GetArgumentsString) {
#define QUOTE_ON_WIN FILE_PATH_LITERAL("")
#endif // OS_WIN
- CommandLine::StringType expected_str;
+ base::CommandLine::StringType expected_str;
expected_str.append(FILE_PATH_LITERAL("--"))
.append(expected_first_arg)
.append(FILE_PATH_LITERAL("="))
@@ -245,12 +249,13 @@ TEST(CommandLineTest, GetArgumentsString) {
.append(expected_fourth_arg)
.append(FILE_PATH_LITERAL(" "));
- CommandLine::StringType expected_str_no_quote_placeholders(expected_str);
+ base::CommandLine::StringType expected_str_no_quote_placeholders(
+ expected_str);
expected_str_no_quote_placeholders.append(expected_fifth_arg);
EXPECT_EQ(expected_str_no_quote_placeholders, cl.GetArgumentsString());
#if defined(OS_WIN)
- CommandLine::StringType expected_str_quote_placeholders(expected_str);
+ base::CommandLine::StringType expected_str_quote_placeholders(expected_str);
expected_str_quote_placeholders.append(QUOTE_ON_WIN)
.append(expected_fifth_arg)
.append(QUOTE_ON_WIN);
@@ -269,9 +274,9 @@ TEST(CommandLineTest, AppendSwitches) {
std::string switch4 = "switch4";
std::string value4 = "\"a value with quotes\"";
std::string switch5 = "quotes";
- CommandLine::StringType value5 = kTricky;
+ base::CommandLine::StringType value5 = kTricky;
- CommandLine cl(FilePath(FILE_PATH_LITERAL("Program")));
+ base::CommandLine cl(FilePath(FILE_PATH_LITERAL("Program")));
cl.AppendSwitch(switch1);
cl.AppendSwitchASCII(switch2, value2);
@@ -301,10 +306,10 @@ TEST(CommandLineTest, AppendSwitches) {
}
TEST(CommandLineTest, AppendSwitchesDashDash) {
- const CommandLine::CharType* raw_argv[] = { FILE_PATH_LITERAL("prog"),
+ const base::CommandLine::CharType* raw_argv[] = { FILE_PATH_LITERAL("prog"),
FILE_PATH_LITERAL("--"),
FILE_PATH_LITERAL("--arg1") };
- CommandLine cl(arraysize(raw_argv), raw_argv);
+ base::CommandLine cl(arraysize(raw_argv), raw_argv);
cl.AppendSwitch("switch1");
cl.AppendSwitchASCII("switch2", "foo");
@@ -313,7 +318,7 @@ TEST(CommandLineTest, AppendSwitchesDashDash) {
EXPECT_EQ(FILE_PATH_LITERAL("prog --switch1 --switch2=foo -- --arg1 --arg2"),
cl.GetCommandLineString());
- CommandLine::StringVector cl_argv = cl.argv();
+ base::CommandLine::StringVector cl_argv = cl.argv();
EXPECT_EQ(FILE_PATH_LITERAL("prog"), cl_argv[0]);
EXPECT_EQ(FILE_PATH_LITERAL("--switch1"), cl_argv[1]);
EXPECT_EQ(FILE_PATH_LITERAL("--switch2=foo"), cl_argv[2]);
@@ -326,18 +331,18 @@ TEST(CommandLineTest, AppendSwitchesDashDash) {
// on the target CommandLine object and the switches from the source
// CommandLine are added to the target.
TEST(CommandLineTest, AppendArguments) {
- CommandLine cl1(FilePath(FILE_PATH_LITERAL("Program")));
+ base::CommandLine cl1(FilePath(FILE_PATH_LITERAL("Program")));
cl1.AppendSwitch("switch1");
cl1.AppendSwitchASCII("switch2", "foo");
- CommandLine cl2(CommandLine::NO_PROGRAM);
+ base::CommandLine cl2(base::CommandLine::NO_PROGRAM);
cl2.AppendArguments(cl1, true);
EXPECT_EQ(cl1.GetProgram().value(), cl2.GetProgram().value());
EXPECT_EQ(cl1.GetCommandLineString(), cl2.GetCommandLineString());
- CommandLine c1(FilePath(FILE_PATH_LITERAL("Program1")));
+ base::CommandLine c1(FilePath(FILE_PATH_LITERAL("Program1")));
c1.AppendSwitch("switch1");
- CommandLine c2(FilePath(FILE_PATH_LITERAL("Program2")));
+ base::CommandLine c2(FilePath(FILE_PATH_LITERAL("Program2")));
c2.AppendSwitch("switch2");
c1.AppendArguments(c2, true);
@@ -353,22 +358,23 @@ TEST(CommandLineTest, AppendArguments) {
TEST(CommandLineTest, ProgramQuotes) {
// Check that quotes are not added for paths without spaces.
const FilePath kProgram(L"Program");
- CommandLine cl_program(kProgram);
+ base::CommandLine cl_program(kProgram);
EXPECT_EQ(kProgram.value(), cl_program.GetProgram().value());
EXPECT_EQ(kProgram.value(), cl_program.GetCommandLineString());
const FilePath kProgramPath(L"Program Path");
// Check that quotes are not returned from GetProgram().
- CommandLine cl_program_path(kProgramPath);
+ base::CommandLine cl_program_path(kProgramPath);
EXPECT_EQ(kProgramPath.value(), cl_program_path.GetProgram().value());
// Check that quotes are added to command line string paths containing spaces.
- CommandLine::StringType cmd_string(cl_program_path.GetCommandLineString());
+ base::CommandLine::StringType cmd_string(
+ cl_program_path.GetCommandLineString());
EXPECT_EQ(L"\"Program Path\"", cmd_string);
// Check the optional quoting of placeholders in programs.
- CommandLine cl_quote_placeholder(base::FilePath(L"%1"));
+ base::CommandLine cl_quote_placeholder(base::FilePath(L"%1"));
EXPECT_EQ(L"%1", cl_quote_placeholder.GetCommandLineString());
EXPECT_EQ(L"\"%1\"",
cl_quote_placeholder.GetCommandLineStringWithPlaceholders());
@@ -377,8 +383,8 @@ TEST(CommandLineTest, ProgramQuotes) {
// Calling Init multiple times should not modify the previous CommandLine.
TEST(CommandLineTest, Init) {
- CommandLine* initial = CommandLine::ForCurrentProcess();
- EXPECT_FALSE(CommandLine::Init(0, NULL));
- CommandLine* current = CommandLine::ForCurrentProcess();
+ base::CommandLine* initial = base::CommandLine::ForCurrentProcess();
+ EXPECT_FALSE(base::CommandLine::Init(0, NULL));
+ base::CommandLine* current = base::CommandLine::ForCurrentProcess();
EXPECT_EQ(initial, current);
}
« no previous file with comments | « no previous file | base/i18n/build_utf8_validator_tables.cc » ('j') | base/test/launcher/test_results_tracker.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698