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

Unified Diff: test/cctest/test-flags.cc

Issue 1935: New static flags system (Closed)
Patch Set: Merge, again. Created 12 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-flags.cc
diff --git a/test/cctest/test-flags.cc b/test/cctest/test-flags.cc
index b4827b6676786f361a49273396a30cd3c3cd33dc..a3aa4b20e451866a0aad569444fd7da880b53c91 100644
--- a/test/cctest/test-flags.cc
+++ b/test/cctest/test-flags.cc
@@ -32,61 +32,54 @@
using namespace v8::internal;
-DEFINE_bool(bool_flag, true, "bool_flag");
-DEFINE_int(int_flag, 13, "int_flag");
-DEFINE_float(float_flag, 2.5, "float-flag");
-DEFINE_string(string_flag, "Hello, world!", "string-flag");
-
-
// This test must be executed first!
TEST(Default) {
- CHECK(FLAG_bool_flag);
- CHECK_EQ(13, FLAG_int_flag);
- CHECK_EQ(2.5, FLAG_float_flag);
- CHECK_EQ(0, strcmp(FLAG_string_flag, "Hello, world!"));
+ CHECK(FLAG_testing_bool_flag);
+ CHECK_EQ(13, FLAG_testing_int_flag);
+ CHECK_EQ(2.5, FLAG_testing_float_flag);
+ CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "Hello, world!"));
}
static void SetFlagsToDefault() {
- for (Flag* f = FlagList::list(); f != NULL; f = f->next()) {
- f->SetToDefault();
- }
+ FlagList::ResetAllFlags();
TestDefault();
}
TEST(Flags1) {
- FlagList::Print(__FILE__, false);
- FlagList::Print(NULL, true);
+ FlagList::PrintHelp();
}
TEST(Flags2) {
SetFlagsToDefault();
int argc = 7;
- const char* argv[] = { "Test2", "-nobool-flag", "notaflag", "--int_flag=77",
- "-float_flag=.25", "--string_flag", "no way!" };
+ const char* argv[] = { "Test2", "-notesting-bool-flag", "notaflag",
+ "--testing_int_flag=77", "-testing_float_flag=.25",
+ "--testing_string_flag", "no way!" };
CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
const_cast<char **>(argv),
false));
CHECK_EQ(7, argc);
- CHECK(!FLAG_bool_flag);
- CHECK_EQ(77, FLAG_int_flag);
- CHECK_EQ(.25, FLAG_float_flag);
- CHECK_EQ(0, strcmp(FLAG_string_flag, "no way!"));
+ CHECK(!FLAG_testing_bool_flag);
+ CHECK_EQ(77, FLAG_testing_int_flag);
+ CHECK_EQ(.25, FLAG_testing_float_flag);
+ CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no way!"));
}
TEST(Flags2b) {
SetFlagsToDefault();
const char* str =
- " -nobool-flag notaflag --int_flag=77 -float_flag=.25 "
- "--string_flag no_way! ";
+ " -notesting-bool-flag notaflag --testing_int_flag=77 "
+ "-testing_float_flag=.25 "
+ "--testing_string_flag no_way! ";
CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str)));
- CHECK(!FLAG_bool_flag);
- CHECK_EQ(77, FLAG_int_flag);
- CHECK_EQ(.25, FLAG_float_flag);
- CHECK_EQ(0, strcmp(FLAG_string_flag, "no_way!"));
+ CHECK(!FLAG_testing_bool_flag);
+ CHECK_EQ(77, FLAG_testing_int_flag);
+ CHECK_EQ(.25, FLAG_testing_float_flag);
+ CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no_way!"));
}
@@ -94,36 +87,38 @@ TEST(Flags3) {
SetFlagsToDefault();
int argc = 8;
const char* argv[] =
- { "Test3", "--bool_flag", "notaflag", "--int_flag", "-666",
- "--float_flag", "-12E10", "-string-flag=foo-bar" };
+ { "Test3", "--testing_bool_flag", "notaflag",
+ "--testing_int_flag", "-666",
+ "--testing_float_flag", "-12E10", "-testing-string-flag=foo-bar" };
CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
const_cast<char **>(argv),
true));
CHECK_EQ(2, argc);
- CHECK(FLAG_bool_flag);
- CHECK_EQ(-666, FLAG_int_flag);
- CHECK_EQ(-12E10, FLAG_float_flag);
- CHECK_EQ(0, strcmp(FLAG_string_flag, "foo-bar"));
+ CHECK(FLAG_testing_bool_flag);
+ CHECK_EQ(-666, FLAG_testing_int_flag);
+ CHECK_EQ(-12E10, FLAG_testing_float_flag);
+ CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar"));
}
TEST(Flags3b) {
SetFlagsToDefault();
const char* str =
- "--bool_flag notaflag --int_flag -666 --float_flag -12E10 "
- "-string-flag=foo-bar";
+ "--testing_bool_flag notaflag --testing_int_flag -666 "
+ "--testing_float_flag -12E10 "
+ "-testing-string-flag=foo-bar";
CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str)));
- CHECK(FLAG_bool_flag);
- CHECK_EQ(-666, FLAG_int_flag);
- CHECK_EQ(-12E10, FLAG_float_flag);
- CHECK_EQ(0, strcmp(FLAG_string_flag, "foo-bar"));
+ CHECK(FLAG_testing_bool_flag);
+ CHECK_EQ(-666, FLAG_testing_int_flag);
+ CHECK_EQ(-12E10, FLAG_testing_float_flag);
+ CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar"));
}
TEST(Flags4) {
SetFlagsToDefault();
int argc = 3;
- const char* argv[] = { "Test4", "--bool_flag", "--foo" };
+ const char* argv[] = { "Test4", "--testing_bool_flag", "--foo" };
CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
const_cast<char **>(argv),
true));
@@ -133,7 +128,7 @@ TEST(Flags4) {
TEST(Flags4b) {
SetFlagsToDefault();
- const char* str = "--bool_flag --foo";
+ const char* str = "--testing_bool_flag --foo";
CHECK_EQ(2, FlagList::SetFlagsFromString(str, strlen(str)));
}
@@ -141,7 +136,7 @@ TEST(Flags4b) {
TEST(Flags5) {
SetFlagsToDefault();
int argc = 2;
- const char* argv[] = { "Test5", "--int_flag=\"foobar\"" };
+ const char* argv[] = { "Test5", "--testing_int_flag=\"foobar\"" };
CHECK_EQ(1, FlagList::SetFlagsFromCommandLine(&argc,
const_cast<char **>(argv),
true));
@@ -151,7 +146,7 @@ TEST(Flags5) {
TEST(Flags5b) {
SetFlagsToDefault();
- const char* str = " --int_flag=\"foobar\"";
+ const char* str = " --testing_int_flag=\"foobar\"";
CHECK_EQ(1, FlagList::SetFlagsFromString(str, strlen(str)));
}
@@ -159,7 +154,8 @@ TEST(Flags5b) {
TEST(Flags6) {
SetFlagsToDefault();
int argc = 4;
- const char* argv[] = { "Test5", "--int-flag", "0", "--float_flag" };
+ const char* argv[] = { "Test5", "--testing-int-flag", "0",
+ "--testing_float_flag" };
CHECK_EQ(3, FlagList::SetFlagsFromCommandLine(&argc,
const_cast<char **>(argv),
true));
@@ -169,6 +165,6 @@ TEST(Flags6) {
TEST(Flags6b) {
SetFlagsToDefault();
- const char* str = " --int-flag 0 --float_flag ";
+ const char* str = " --testing-int-flag 0 --testing_float_flag ";
CHECK_EQ(3, FlagList::SetFlagsFromString(str, strlen(str)));
}
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698