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

Side by Side Diff: base/command_line_unittest.cc

Issue 1046363002: Enforce lowercase switches when calling CommandLine::HasSwitch(const char*). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test on Linux. Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « base/command_line.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 EXPECT_FALSE(cl.HasSwitch("dog")); 53 EXPECT_FALSE(cl.HasSwitch("dog"));
54 EXPECT_FALSE(cl.HasSwitch("cat")); 54 EXPECT_FALSE(cl.HasSwitch("cat"));
55 EXPECT_FALSE(cl.HasSwitch("output-rotation")); 55 EXPECT_FALSE(cl.HasSwitch("output-rotation"));
56 EXPECT_FALSE(cl.HasSwitch("not-a-switch")); 56 EXPECT_FALSE(cl.HasSwitch("not-a-switch"));
57 EXPECT_FALSE(cl.HasSwitch("--")); 57 EXPECT_FALSE(cl.HasSwitch("--"));
58 58
59 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("program")).value(), 59 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("program")).value(),
60 cl.GetProgram().value()); 60 cl.GetProgram().value());
61 61
62 EXPECT_TRUE(cl.HasSwitch("foo")); 62 EXPECT_TRUE(cl.HasSwitch("foo"));
63 EXPECT_TRUE(cl.HasSwitch("bAr")); 63 #if defined(OS_WIN)
64 EXPECT_TRUE(cl.HasSwitch("bar"));
65 #else
66 EXPECT_FALSE(cl.HasSwitch("bar"));
67 #endif
64 EXPECT_TRUE(cl.HasSwitch("baz")); 68 EXPECT_TRUE(cl.HasSwitch("baz"));
65 EXPECT_TRUE(cl.HasSwitch("spaetzle")); 69 EXPECT_TRUE(cl.HasSwitch("spaetzle"));
66 #if defined(OS_WIN)
67 EXPECT_TRUE(cl.HasSwitch("SPAETZLE"));
68 #endif
69 EXPECT_TRUE(cl.HasSwitch("other-switches")); 70 EXPECT_TRUE(cl.HasSwitch("other-switches"));
70 EXPECT_TRUE(cl.HasSwitch("input-translation")); 71 EXPECT_TRUE(cl.HasSwitch("input-translation"));
71 72
72 EXPECT_EQ("Crepe", cl.GetSwitchValueASCII("spaetzle")); 73 EXPECT_EQ("Crepe", cl.GetSwitchValueASCII("spaetzle"));
73 EXPECT_EQ("", cl.GetSwitchValueASCII("Foo")); 74 EXPECT_EQ("", cl.GetSwitchValueASCII("Foo"));
74 EXPECT_EQ("", cl.GetSwitchValueASCII("bar")); 75 EXPECT_EQ("", cl.GetSwitchValueASCII("bar"));
75 EXPECT_EQ("", cl.GetSwitchValueASCII("cruller")); 76 EXPECT_EQ("", cl.GetSwitchValueASCII("cruller"));
76 EXPECT_EQ("--dog=canine --cat=feline", cl.GetSwitchValueASCII( 77 EXPECT_EQ("--dog=canine --cat=feline", cl.GetSwitchValueASCII(
77 "other-switches")); 78 "other-switches"));
78 EXPECT_EQ("45--output-rotation", cl.GetSwitchValueASCII("input-translation")); 79 EXPECT_EQ("45--output-rotation", cl.GetSwitchValueASCII("input-translation"));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 EXPECT_FALSE(cl.HasSwitch("not-a-switch")); 122 EXPECT_FALSE(cl.HasSwitch("not-a-switch"));
122 EXPECT_FALSE(cl.HasSwitch("--")); 123 EXPECT_FALSE(cl.HasSwitch("--"));
123 124
124 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("program")).value(), 125 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("program")).value(),
125 cl.GetProgram().value()); 126 cl.GetProgram().value());
126 127
127 EXPECT_TRUE(cl.HasSwitch("foo")); 128 EXPECT_TRUE(cl.HasSwitch("foo"));
128 EXPECT_TRUE(cl.HasSwitch("bar")); 129 EXPECT_TRUE(cl.HasSwitch("bar"));
129 EXPECT_TRUE(cl.HasSwitch("baz")); 130 EXPECT_TRUE(cl.HasSwitch("baz"));
130 EXPECT_TRUE(cl.HasSwitch("spaetzle")); 131 EXPECT_TRUE(cl.HasSwitch("spaetzle"));
131 EXPECT_TRUE(cl.HasSwitch("SPAETZLE"));
132 EXPECT_TRUE(cl.HasSwitch("other-switches")); 132 EXPECT_TRUE(cl.HasSwitch("other-switches"));
133 EXPECT_TRUE(cl.HasSwitch("input-translation")); 133 EXPECT_TRUE(cl.HasSwitch("input-translation"));
134 EXPECT_TRUE(cl.HasSwitch("quotes")); 134 EXPECT_TRUE(cl.HasSwitch("quotes"));
135 135
136 EXPECT_EQ("Crepe", cl.GetSwitchValueASCII("spaetzle")); 136 EXPECT_EQ("Crepe", cl.GetSwitchValueASCII("spaetzle"));
137 EXPECT_EQ("", cl.GetSwitchValueASCII("Foo")); 137 EXPECT_EQ("", cl.GetSwitchValueASCII("Foo"));
138 EXPECT_EQ("", cl.GetSwitchValueASCII("bar")); 138 EXPECT_EQ("", cl.GetSwitchValueASCII("bar"));
139 EXPECT_EQ("", cl.GetSwitchValueASCII("cruller")); 139 EXPECT_EQ("", cl.GetSwitchValueASCII("cruller"));
140 EXPECT_EQ("--dog=canine --cat=feline", cl.GetSwitchValueASCII( 140 EXPECT_EQ("--dog=canine --cat=feline", cl.GetSwitchValueASCII(
141 "other-switches")); 141 "other-switches"));
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 373
374 // Calling Init multiple times should not modify the previous CommandLine. 374 // Calling Init multiple times should not modify the previous CommandLine.
375 TEST(CommandLineTest, Init) { 375 TEST(CommandLineTest, Init) {
376 CommandLine* initial = CommandLine::ForCurrentProcess(); 376 CommandLine* initial = CommandLine::ForCurrentProcess();
377 EXPECT_FALSE(CommandLine::Init(0, NULL)); 377 EXPECT_FALSE(CommandLine::Init(0, NULL));
378 CommandLine* current = CommandLine::ForCurrentProcess(); 378 CommandLine* current = CommandLine::ForCurrentProcess();
379 EXPECT_EQ(initial, current); 379 EXPECT_EQ(initial, current);
380 } 380 }
381 381
382 } // namespace base 382 } // namespace base
OLDNEW
« no previous file with comments | « base/command_line.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698