OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/install_static/install_util.h" | 5 #include "chrome/install_static/install_util.h" |
6 | 6 |
7 #include "testing/gmock/include/gmock/gmock.h" | 7 #include "testing/gmock/include/gmock/gmock.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 using ::testing::ElementsAre; | 10 using ::testing::ElementsAre; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 | 123 |
124 // Case 10. Version1 > Version2. Multiple digit numbers. | 124 // Case 10. Version1 > Version2. Multiple digit numbers. |
125 EXPECT_TRUE(CompareVersionStrings("0.0.12.1", "0.0.10.3", &result)); | 125 EXPECT_TRUE(CompareVersionStrings("0.0.12.1", "0.0.10.3", &result)); |
126 EXPECT_EQ(1, result); | 126 EXPECT_EQ(1, result); |
127 | 127 |
128 // Case 11. Version1 < Version2. Multiple digit number. | 128 // Case 11. Version1 < Version2. Multiple digit number. |
129 EXPECT_TRUE(CompareVersionStrings("10.11.12.13", "12.11.12.13", &result)); | 129 EXPECT_TRUE(CompareVersionStrings("10.11.12.13", "12.11.12.13", &result)); |
130 EXPECT_EQ(-1, result); | 130 EXPECT_EQ(-1, result); |
131 } | 131 } |
132 | 132 |
133 // Tests the install_static::GetSwitchValueFromCommandLine function. | |
134 TEST(InstallStaticTest, GetSwitchValueFromCommandLineTest) { | |
135 // Simple case with one switch. | |
136 std::string value = | |
137 GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=bar", "type"); | |
138 EXPECT_EQ(value, "bar"); | |
Lei Zhang
2016/06/15 23:20:46
The arguments are flipped around. As is, when this
ananta
2016/06/16 00:29:30
Done.
| |
139 | |
140 // Multiple switches with trailing spaces between them. | |
141 value = GetSwitchValueFromCommandLine( | |
142 "c:\\temp\\bleh.exe --type=bar --abc=def bleh", "abc"); | |
143 EXPECT_EQ(value, "def"); | |
144 | |
145 // Multiple switches with trailing spaces and tabs between them. | |
146 value = GetSwitchValueFromCommandLine( | |
147 "c:\\temp\\bleh.exe --type=bar \t\t\t --abc=def bleh", "abc"); | |
148 EXPECT_EQ(value, "def"); | |
149 | |
150 // Non existent switch. | |
151 value = GetSwitchValueFromCommandLine( | |
152 "c:\\temp\\bleh.exe --foo=bar --abc=def bleh", "type"); | |
153 EXPECT_EQ(value, ""); | |
154 | |
155 // Non existent switch. | |
156 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe", "type"); | |
157 EXPECT_EQ(value, ""); | |
158 | |
159 // Non existent switch. | |
160 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe type=bar", "type"); | |
161 EXPECT_EQ(value, ""); | |
162 | |
163 // Trailing spaces after the switch. | |
164 value = GetSwitchValueFromCommandLine( | |
165 "c:\\temp\\bleh.exe --type=bar \t\t", "type"); | |
166 EXPECT_EQ(value, "bar"); | |
167 | |
168 // Multiple switches with trailing spaces and tabs between them. | |
169 value = GetSwitchValueFromCommandLine( | |
170 "c:\\temp\\bleh.exe --type=bar \t\t --foo=bleh", "foo"); | |
171 EXPECT_EQ(value, "bleh"); | |
172 | |
173 // Nothing after a switch. | |
174 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=", "type"); | |
175 EXPECT_TRUE(value.empty()); | |
176 | |
177 // Whitespace after a switch. | |
178 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type= ", "type"); | |
179 EXPECT_TRUE(value.empty()); | |
180 | |
181 // Just tabs after a switch. | |
182 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=\t\t\t", | |
183 "type"); | |
184 EXPECT_TRUE(value.empty()); | |
185 | |
186 // Whitespace after the "=" before the value. | |
187 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type= bar", | |
188 "type"); | |
189 EXPECT_EQ(value, "bar"); | |
190 | |
191 // Tabs after the "=" before the value. | |
192 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=\t\t\tbar", | |
193 "type"); | |
194 EXPECT_EQ(value, "bar"); | |
195 } | |
196 | |
133 } // namespace install_static | 197 } // namespace install_static |
OLD | NEW |