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"); | |
grt (UTC plus 2)
2016/06/15 15:49:21
\b -> \\b here and below
ananta
2016/06/15 22:10:28
Done.
| |
138 EXPECT_EQ(value, "bar"); | |
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 } | |
grt (UTC plus 2)
2016/06/15 15:49:21
please add tests for:
- nothing after =: "c:\\temp
ananta
2016/06/15 22:10:28
Done.
| |
173 | |
133 } // namespace install_static | 174 } // namespace install_static |
OLD | NEW |