Revision f230a1cf deps/v8/test/cctest/test-flags.cc
deps/v8/test/cctest/test-flags.cc | ||
---|---|---|
54 | 54 |
|
55 | 55 |
TEST(Flags2) { |
56 | 56 |
SetFlagsToDefault(); |
57 |
int argc = 7; |
|
58 |
const char* argv[] = { "Test2", "-notesting-bool-flag", "notaflag", |
|
57 |
int argc = 8; |
|
58 |
const char* argv[] = { "Test2", "-notesting-bool-flag", |
|
59 |
"--notesting-maybe-bool-flag", "notaflag", |
|
59 | 60 |
"--testing_int_flag=77", "-testing_float_flag=.25", |
60 | 61 |
"--testing_string_flag", "no way!" }; |
61 | 62 |
CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc, |
62 | 63 |
const_cast<char **>(argv), |
63 | 64 |
false)); |
64 |
CHECK_EQ(7, argc);
|
|
65 |
CHECK_EQ(8, argc);
|
|
65 | 66 |
CHECK(!FLAG_testing_bool_flag); |
67 |
CHECK(FLAG_testing_maybe_bool_flag.has_value); |
|
68 |
CHECK(!FLAG_testing_maybe_bool_flag.value); |
|
66 | 69 |
CHECK_EQ(77, FLAG_testing_int_flag); |
67 | 70 |
CHECK_EQ(.25, FLAG_testing_float_flag); |
68 | 71 |
CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no way!")); |
... | ... | |
73 | 76 |
SetFlagsToDefault(); |
74 | 77 |
const char* str = |
75 | 78 |
" -notesting-bool-flag notaflag --testing_int_flag=77 " |
79 |
"-notesting-maybe-bool-flag " |
|
76 | 80 |
"-testing_float_flag=.25 " |
77 | 81 |
"--testing_string_flag no_way! "; |
78 | 82 |
CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str))); |
79 | 83 |
CHECK(!FLAG_testing_bool_flag); |
84 |
CHECK(FLAG_testing_maybe_bool_flag.has_value); |
|
85 |
CHECK(!FLAG_testing_maybe_bool_flag.value); |
|
80 | 86 |
CHECK_EQ(77, FLAG_testing_int_flag); |
81 | 87 |
CHECK_EQ(.25, FLAG_testing_float_flag); |
82 | 88 |
CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no_way!")); |
... | ... | |
85 | 91 |
|
86 | 92 |
TEST(Flags3) { |
87 | 93 |
SetFlagsToDefault(); |
88 |
int argc = 8;
|
|
94 |
int argc = 9;
|
|
89 | 95 |
const char* argv[] = |
90 |
{ "Test3", "--testing_bool_flag", "notaflag", |
|
96 |
{ "Test3", "--testing_bool_flag", "--testing-maybe-bool-flag", "notaflag",
|
|
91 | 97 |
"--testing_int_flag", "-666", |
92 | 98 |
"--testing_float_flag", "-12E10", "-testing-string-flag=foo-bar" }; |
93 | 99 |
CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc, |
... | ... | |
95 | 101 |
true)); |
96 | 102 |
CHECK_EQ(2, argc); |
97 | 103 |
CHECK(FLAG_testing_bool_flag); |
104 |
CHECK(FLAG_testing_maybe_bool_flag.has_value); |
|
105 |
CHECK(FLAG_testing_maybe_bool_flag.value); |
|
98 | 106 |
CHECK_EQ(-666, FLAG_testing_int_flag); |
99 | 107 |
CHECK_EQ(-12E10, FLAG_testing_float_flag); |
100 | 108 |
CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar")); |
... | ... | |
104 | 112 |
TEST(Flags3b) { |
105 | 113 |
SetFlagsToDefault(); |
106 | 114 |
const char* str = |
107 |
"--testing_bool_flag notaflag --testing_int_flag -666 " |
|
115 |
"--testing_bool_flag --testing-maybe-bool-flag notaflag " |
|
116 |
"--testing_int_flag -666 " |
|
108 | 117 |
"--testing_float_flag -12E10 " |
109 | 118 |
"-testing-string-flag=foo-bar"; |
110 | 119 |
CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str))); |
111 | 120 |
CHECK(FLAG_testing_bool_flag); |
121 |
CHECK(FLAG_testing_maybe_bool_flag.has_value); |
|
122 |
CHECK(FLAG_testing_maybe_bool_flag.value); |
|
112 | 123 |
CHECK_EQ(-666, FLAG_testing_int_flag); |
113 | 124 |
CHECK_EQ(-12E10, FLAG_testing_float_flag); |
114 | 125 |
CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar")); |
... | ... | |
123 | 134 |
const_cast<char **>(argv), |
124 | 135 |
true)); |
125 | 136 |
CHECK_EQ(2, argc); |
137 |
CHECK(!FLAG_testing_maybe_bool_flag.has_value); |
|
126 | 138 |
} |
127 | 139 |
|
128 | 140 |
|
... | ... | |
130 | 142 |
SetFlagsToDefault(); |
131 | 143 |
const char* str = "--testing_bool_flag --foo"; |
132 | 144 |
CHECK_EQ(2, FlagList::SetFlagsFromString(str, StrLength(str))); |
145 |
CHECK(!FLAG_testing_maybe_bool_flag.has_value); |
|
133 | 146 |
} |
134 | 147 |
|
135 | 148 |
|
... | ... | |
181 | 194 |
true)); |
182 | 195 |
CHECK_EQ(42, FLAG_testing_int_flag); |
183 | 196 |
CHECK_EQ(2.5, FLAG_testing_float_flag); |
184 |
CHECK_EQ(2, FLAG_js_arguments.argc());
|
|
197 |
CHECK_EQ(2, FLAG_js_arguments.argc); |
|
185 | 198 |
CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); |
186 | 199 |
CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); |
187 | 200 |
CHECK_EQ(1, argc); |
... | ... | |
194 | 207 |
CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str))); |
195 | 208 |
CHECK_EQ(42, FLAG_testing_int_flag); |
196 | 209 |
CHECK_EQ(2.5, FLAG_testing_float_flag); |
197 |
CHECK_EQ(2, FLAG_js_arguments.argc());
|
|
210 |
CHECK_EQ(2, FLAG_js_arguments.argc); |
|
198 | 211 |
CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); |
199 | 212 |
CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); |
200 | 213 |
} |
... | ... | |
206 | 219 |
CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str))); |
207 | 220 |
CHECK_EQ(42, FLAG_testing_int_flag); |
208 | 221 |
CHECK_EQ(2.5, FLAG_testing_float_flag); |
209 |
CHECK_EQ(2, FLAG_js_arguments.argc());
|
|
222 |
CHECK_EQ(2, FLAG_js_arguments.argc); |
|
210 | 223 |
CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); |
211 | 224 |
CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); |
212 | 225 |
} |
... | ... | |
218 | 231 |
CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str))); |
219 | 232 |
CHECK_EQ(42, FLAG_testing_int_flag); |
220 | 233 |
CHECK_EQ(2.5, FLAG_testing_float_flag); |
221 |
CHECK_EQ(2, FLAG_js_arguments.argc());
|
|
234 |
CHECK_EQ(2, FLAG_js_arguments.argc); |
|
222 | 235 |
CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); |
223 | 236 |
CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); |
224 | 237 |
} |
... | ... | |
229 | 242 |
const char* str = "--testing-int-flag 42 --"; |
230 | 243 |
CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str))); |
231 | 244 |
CHECK_EQ(42, FLAG_testing_int_flag); |
232 |
CHECK_EQ(0, FLAG_js_arguments.argc());
|
|
245 |
CHECK_EQ(0, FLAG_js_arguments.argc); |
|
233 | 246 |
} |
234 | 247 |
|
235 | 248 |
|
Also available in: Unified diff