Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: test/cctest/test-flags.cc

Issue 390004: Fix warnings on Win64. (Closed)
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no way!")); 68 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no way!"));
69 } 69 }
70 70
71 71
72 TEST(Flags2b) { 72 TEST(Flags2b) {
73 SetFlagsToDefault(); 73 SetFlagsToDefault();
74 const char* str = 74 const char* str =
75 " -notesting-bool-flag notaflag --testing_int_flag=77 " 75 " -notesting-bool-flag notaflag --testing_int_flag=77 "
76 "-testing_float_flag=.25 " 76 "-testing_float_flag=.25 "
77 "--testing_string_flag no_way! "; 77 "--testing_string_flag no_way! ";
78 CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str))); 78 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str)));
79 CHECK(!FLAG_testing_bool_flag); 79 CHECK(!FLAG_testing_bool_flag);
80 CHECK_EQ(77, FLAG_testing_int_flag); 80 CHECK_EQ(77, FLAG_testing_int_flag);
81 CHECK_EQ(.25, FLAG_testing_float_flag); 81 CHECK_EQ(.25, FLAG_testing_float_flag);
82 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no_way!")); 82 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no_way!"));
83 } 83 }
84 84
85 85
86 TEST(Flags3) { 86 TEST(Flags3) {
87 SetFlagsToDefault(); 87 SetFlagsToDefault();
88 int argc = 8; 88 int argc = 8;
(...skipping 11 matching lines...) Expand all
100 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar")); 100 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar"));
101 } 101 }
102 102
103 103
104 TEST(Flags3b) { 104 TEST(Flags3b) {
105 SetFlagsToDefault(); 105 SetFlagsToDefault();
106 const char* str = 106 const char* str =
107 "--testing_bool_flag notaflag --testing_int_flag -666 " 107 "--testing_bool_flag notaflag --testing_int_flag -666 "
108 "--testing_float_flag -12E10 " 108 "--testing_float_flag -12E10 "
109 "-testing-string-flag=foo-bar"; 109 "-testing-string-flag=foo-bar";
110 CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str))); 110 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str)));
111 CHECK(FLAG_testing_bool_flag); 111 CHECK(FLAG_testing_bool_flag);
112 CHECK_EQ(-666, FLAG_testing_int_flag); 112 CHECK_EQ(-666, FLAG_testing_int_flag);
113 CHECK_EQ(-12E10, FLAG_testing_float_flag); 113 CHECK_EQ(-12E10, FLAG_testing_float_flag);
114 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar")); 114 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar"));
115 } 115 }
116 116
117 117
118 TEST(Flags4) { 118 TEST(Flags4) {
119 SetFlagsToDefault(); 119 SetFlagsToDefault();
120 int argc = 3; 120 int argc = 3;
121 const char* argv[] = { "Test4", "--testing_bool_flag", "--foo" }; 121 const char* argv[] = { "Test4", "--testing_bool_flag", "--foo" };
122 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc, 122 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
123 const_cast<char **>(argv), 123 const_cast<char **>(argv),
124 true)); 124 true));
125 CHECK_EQ(2, argc); 125 CHECK_EQ(2, argc);
126 } 126 }
127 127
128 128
129 TEST(Flags4b) { 129 TEST(Flags4b) {
130 SetFlagsToDefault(); 130 SetFlagsToDefault();
131 const char* str = "--testing_bool_flag --foo"; 131 const char* str = "--testing_bool_flag --foo";
132 CHECK_EQ(2, FlagList::SetFlagsFromString(str, strlen(str))); 132 CHECK_EQ(2, FlagList::SetFlagsFromString(str, StrLength(str)));
133 } 133 }
134 134
135 135
136 TEST(Flags5) { 136 TEST(Flags5) {
137 SetFlagsToDefault(); 137 SetFlagsToDefault();
138 int argc = 2; 138 int argc = 2;
139 const char* argv[] = { "Test5", "--testing_int_flag=\"foobar\"" }; 139 const char* argv[] = { "Test5", "--testing_int_flag=\"foobar\"" };
140 CHECK_EQ(1, FlagList::SetFlagsFromCommandLine(&argc, 140 CHECK_EQ(1, FlagList::SetFlagsFromCommandLine(&argc,
141 const_cast<char **>(argv), 141 const_cast<char **>(argv),
142 true)); 142 true));
143 CHECK_EQ(2, argc); 143 CHECK_EQ(2, argc);
144 } 144 }
145 145
146 146
147 TEST(Flags5b) { 147 TEST(Flags5b) {
148 SetFlagsToDefault(); 148 SetFlagsToDefault();
149 const char* str = " --testing_int_flag=\"foobar\""; 149 const char* str = " --testing_int_flag=\"foobar\"";
150 CHECK_EQ(1, FlagList::SetFlagsFromString(str, strlen(str))); 150 CHECK_EQ(1, FlagList::SetFlagsFromString(str, StrLength(str)));
151 } 151 }
152 152
153 153
154 TEST(Flags6) { 154 TEST(Flags6) {
155 SetFlagsToDefault(); 155 SetFlagsToDefault();
156 int argc = 4; 156 int argc = 4;
157 const char* argv[] = { "Test5", "--testing-int-flag", "0", 157 const char* argv[] = { "Test5", "--testing-int-flag", "0",
158 "--testing_float_flag" }; 158 "--testing_float_flag" };
159 CHECK_EQ(3, FlagList::SetFlagsFromCommandLine(&argc, 159 CHECK_EQ(3, FlagList::SetFlagsFromCommandLine(&argc,
160 const_cast<char **>(argv), 160 const_cast<char **>(argv),
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, StrLength(str)));
170 } 170 }
171 171
172 172
173 TEST(FlagsJSArguments1) { 173 TEST(FlagsJSArguments1) {
174 SetFlagsToDefault(); 174 SetFlagsToDefault();
175 int argc = 6; 175 int argc = 6;
176 const char* argv[] = {"TestJSArgs1", 176 const char* argv[] = {"TestJSArgs1",
177 "--testing-int-flag", "42", 177 "--testing-int-flag", "42",
178 "--", "testing-float-flag", "7"}; 178 "--", "testing-float-flag", "7"};
179 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc, 179 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
180 const_cast<char **>(argv), 180 const_cast<char **>(argv),
181 true)); 181 true));
182 CHECK_EQ(42, FLAG_testing_int_flag); 182 CHECK_EQ(42, FLAG_testing_int_flag);
183 CHECK_EQ(2.5, FLAG_testing_float_flag); 183 CHECK_EQ(2.5, FLAG_testing_float_flag);
184 CHECK_EQ(2, FLAG_js_arguments.argc()); 184 CHECK_EQ(2, FLAG_js_arguments.argc());
185 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); 185 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag"));
186 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); 186 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7"));
187 CHECK_EQ(1, argc); 187 CHECK_EQ(1, argc);
188 } 188 }
189 189
190 190
191 TEST(FlagsJSArguments1b) { 191 TEST(FlagsJSArguments1b) {
192 SetFlagsToDefault(); 192 SetFlagsToDefault();
193 const char* str = "--testing-int-flag 42 -- testing-float-flag 7"; 193 const char* str = "--testing-int-flag 42 -- testing-float-flag 7";
194 CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str))); 194 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str)));
195 CHECK_EQ(42, FLAG_testing_int_flag); 195 CHECK_EQ(42, FLAG_testing_int_flag);
196 CHECK_EQ(2.5, FLAG_testing_float_flag); 196 CHECK_EQ(2.5, FLAG_testing_float_flag);
197 CHECK_EQ(2, FLAG_js_arguments.argc()); 197 CHECK_EQ(2, FLAG_js_arguments.argc());
198 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); 198 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag"));
199 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); 199 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7"));
200 } 200 }
201 201
202 202
203 TEST(FlagsJSArguments2) { 203 TEST(FlagsJSArguments2) {
204 SetFlagsToDefault(); 204 SetFlagsToDefault();
205 const char* str = "--testing-int-flag 42 --js-arguments testing-float-flag 7"; 205 const char* str = "--testing-int-flag 42 --js-arguments testing-float-flag 7";
206 CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str))); 206 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str)));
207 CHECK_EQ(42, FLAG_testing_int_flag); 207 CHECK_EQ(42, FLAG_testing_int_flag);
208 CHECK_EQ(2.5, FLAG_testing_float_flag); 208 CHECK_EQ(2.5, FLAG_testing_float_flag);
209 CHECK_EQ(2, FLAG_js_arguments.argc()); 209 CHECK_EQ(2, FLAG_js_arguments.argc());
210 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); 210 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag"));
211 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); 211 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7"));
212 } 212 }
213 213
214 214
215 TEST(FlagsJSArguments3) { 215 TEST(FlagsJSArguments3) {
216 SetFlagsToDefault(); 216 SetFlagsToDefault();
217 const char* str = "--testing-int-flag 42 --js-arguments=testing-float-flag 7"; 217 const char* str = "--testing-int-flag 42 --js-arguments=testing-float-flag 7";
218 CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str))); 218 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str)));
219 CHECK_EQ(42, FLAG_testing_int_flag); 219 CHECK_EQ(42, FLAG_testing_int_flag);
220 CHECK_EQ(2.5, FLAG_testing_float_flag); 220 CHECK_EQ(2.5, FLAG_testing_float_flag);
221 CHECK_EQ(2, FLAG_js_arguments.argc()); 221 CHECK_EQ(2, FLAG_js_arguments.argc());
222 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag")); 222 CHECK_EQ(0, strcmp(FLAG_js_arguments[0], "testing-float-flag"));
223 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7")); 223 CHECK_EQ(0, strcmp(FLAG_js_arguments[1], "7"));
224 } 224 }
225 225
226 226
227 TEST(FlagsJSArguments4) { 227 TEST(FlagsJSArguments4) {
228 SetFlagsToDefault(); 228 SetFlagsToDefault();
229 const char* str = "--testing-int-flag 42 --"; 229 const char* str = "--testing-int-flag 42 --";
230 CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str))); 230 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str)));
231 CHECK_EQ(42, FLAG_testing_int_flag); 231 CHECK_EQ(42, FLAG_testing_int_flag);
232 CHECK_EQ(0, FLAG_js_arguments.argc()); 232 CHECK_EQ(0, FLAG_js_arguments.argc());
233 } 233 }
234 234
OLDNEW
« src/api.cc ('K') | « test/cctest/test-debug.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698