33 using namespace v8::internal;
37 CHECK(FLAG_testing_bool_flag);
39 CHECK_EQ(2.5, FLAG_testing_float_flag);
40 CHECK_EQ(0, strcmp(FLAG_testing_string_flag,
"Hello, world!"));
44 static void SetFlagsToDefault() {
45 FlagList::ResetAllFlags();
51 FlagList::PrintHelp();
58 const char* argv[] = {
"Test2",
"-notesting-bool-flag",
"notaflag",
59 "--testing_int_flag=77",
"-testing_float_flag=.25",
60 "--testing_string_flag",
"no way!" };
61 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
62 const_cast<char **>(argv),
65 CHECK(!FLAG_testing_bool_flag);
67 CHECK_EQ(.25, FLAG_testing_float_flag);
68 CHECK_EQ(0, strcmp(FLAG_testing_string_flag,
"no way!"));
75 " -notesting-bool-flag notaflag --testing_int_flag=77 "
76 "-testing_float_flag=.25 "
77 "--testing_string_flag no_way! ";
79 CHECK(!FLAG_testing_bool_flag);
81 CHECK_EQ(.25, FLAG_testing_float_flag);
82 CHECK_EQ(0, strcmp(FLAG_testing_string_flag,
"no_way!"));
90 {
"Test3",
"--testing_bool_flag",
"notaflag",
91 "--testing_int_flag",
"-666",
92 "--testing_float_flag",
"-12E10",
"-testing-string-flag=foo-bar" };
93 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
94 const_cast<char **>(argv),
97 CHECK(FLAG_testing_bool_flag);
98 CHECK_EQ(-666, FLAG_testing_int_flag);
99 CHECK_EQ(-12E10, FLAG_testing_float_flag);
100 CHECK_EQ(0, strcmp(FLAG_testing_string_flag,
"foo-bar"));
107 "--testing_bool_flag notaflag --testing_int_flag -666 "
108 "--testing_float_flag -12E10 "
109 "-testing-string-flag=foo-bar";
111 CHECK(FLAG_testing_bool_flag);
112 CHECK_EQ(-666, FLAG_testing_int_flag);
113 CHECK_EQ(-12E10, FLAG_testing_float_flag);
114 CHECK_EQ(0, strcmp(FLAG_testing_string_flag,
"foo-bar"));
121 const char* argv[] = {
"Test4",
"--testing_bool_flag",
"--foo" };
122 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
123 const_cast<char **>(argv),
131 const char* str =
"--testing_bool_flag --foo";
139 const char* argv[] = {
"Test5",
"--testing_int_flag=\"foobar\"" };
140 CHECK_EQ(1, FlagList::SetFlagsFromCommandLine(&argc,
141 const_cast<char **>(argv),
149 const char* str =
" --testing_int_flag=\"foobar\"";
157 const char* argv[] = {
"Test5",
"--testing-int-flag",
"0",
158 "--testing_float_flag" };
159 CHECK_EQ(3, FlagList::SetFlagsFromCommandLine(&argc,
160 const_cast<char **>(argv),
168 const char* str =
" --testing-int-flag 0 --testing_float_flag ";
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),
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"));
193 const char* str =
"--testing-int-flag 42 -- testing-float-flag 7";
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"));
205 const char* str =
"--testing-int-flag 42 --js-arguments testing-float-flag 7";
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"));
217 const char* str =
"--testing-int-flag 42 --js-arguments=testing-float-flag 7";
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"));
229 const char* str =
"--testing-int-flag 42 --";
231 CHECK_EQ(42, FLAG_testing_int_flag);
232 CHECK_EQ(0, FLAG_js_arguments.argc());
#define CHECK_EQ(expected, value)
int StrLength(const char *string)