| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 true)); | 161 true)); |
| 162 CHECK_EQ(4, argc); | 162 CHECK_EQ(4, argc); |
| 163 } | 163 } |
| 164 | 164 |
| 165 | 165 |
| 166 TEST(Flags6b) { | 166 TEST(Flags6b) { |
| 167 SetFlagsToDefault(); | 167 SetFlagsToDefault(); |
| 168 const char* str = " --testing-int-flag 0 --testing_float_flag "; | 168 const char* str = " --testing-int-flag 0 --testing_float_flag "; |
| 169 CHECK_EQ(3, FlagList::SetFlagsFromString(str, strlen(str))); | 169 CHECK_EQ(3, FlagList::SetFlagsFromString(str, strlen(str))); |
| 170 } | 170 } |
| 171 |
| 172 |
| 173 TEST(FlagsJSArguments1) { |
| 174 SetFlagsToDefault(); |
| 175 int argc = 6; |
| 176 const char* argv[] = {"TestJSArgs1", |
| 177 "--testing-int-flag", "42", |
| 178 "--", "testing-float-flag", "7"}; |
| 179 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc, |
| 180 const_cast<char **>(argv), |
| 181 true)); |
| 182 CHECK_EQ(42, FLAG_testing_int_flag); |
| 183 CHECK_EQ(2.5, FLAG_testing_float_flag); |
| 184 CHECK_EQ(2, FLAG_js_arguments.argc()); |
| 185 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); |
| 186 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); |
| 187 CHECK_EQ(1, argc); |
| 188 } |
| 189 |
| 190 |
| 191 TEST(FlagsJSArguments1b) { |
| 192 SetFlagsToDefault(); |
| 193 const char* str = "--testing-int-flag 42 -- testing-float-flag 7"; |
| 194 CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str))); |
| 195 CHECK_EQ(42, FLAG_testing_int_flag); |
| 196 CHECK_EQ(2.5, FLAG_testing_float_flag); |
| 197 CHECK_EQ(2, FLAG_js_arguments.argc()); |
| 198 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); |
| 199 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); |
| 200 } |
| 201 |
| 202 |
| 203 TEST(FlagsJSArguments2) { |
| 204 SetFlagsToDefault(); |
| 205 const char* str = "--testing-int-flag 42 --js-arguments testing-float-flag 7"; |
| 206 CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str))); |
| 207 CHECK_EQ(42, FLAG_testing_int_flag); |
| 208 CHECK_EQ(2.5, FLAG_testing_float_flag); |
| 209 CHECK_EQ(2, FLAG_js_arguments.argc()); |
| 210 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); |
| 211 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); |
| 212 } |
| 213 |
| 214 |
| 215 TEST(FlagsJSArguments3) { |
| 216 SetFlagsToDefault(); |
| 217 const char* str = "--testing-int-flag 42 --js-arguments=testing-float-flag 7"; |
| 218 CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str))); |
| 219 CHECK_EQ(42, FLAG_testing_int_flag); |
| 220 CHECK_EQ(2.5, FLAG_testing_float_flag); |
| 221 CHECK_EQ(2, FLAG_js_arguments.argc()); |
| 222 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); |
| 223 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); |
| 224 } |
| 225 |
| 226 |
| 227 TEST(FlagsJSArguments4) { |
| 228 SetFlagsToDefault(); |
| 229 const char* str = "--testing-int-flag 42 --"; |
| 230 CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str))); |
| 231 CHECK_EQ(42, FLAG_testing_int_flag); |
| 232 CHECK_EQ(0, FLAG_js_arguments.argc()); |
| 233 } |
| 234 |
| OLD | NEW |