Flutter Engine
The Flutter Engine
flags_test.cc
Go to the documentation of this file.
1// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include "vm/flags.h"
6#include "platform/assert.h"
7#include "vm/heap/heap.h"
8#include "vm/unit_test.h"
9
10namespace dart {
11
12DEFINE_FLAG(bool, basic_flag, true, "Testing of a basic boolean flag.");
13
14DECLARE_FLAG(bool, print_flags);
15
16VM_UNIT_TEST_CASE(BasicFlags) {
17 EXPECT_EQ(true, FLAG_basic_flag);
18 EXPECT_EQ(false, FLAG_verbose_gc);
19 EXPECT_EQ(false, FLAG_print_flags);
20}
21
22DEFINE_FLAG(bool, parse_flag_bool_test, true, "Flags::Parse (bool) testing");
23DEFINE_FLAG(charp, string_opt_test, nullptr, "Testing: string option.");
24DEFINE_FLAG(charp, entrypoint_test, "main", "Testing: entrypoint");
25DEFINE_FLAG(int, counter, 100, "Testing: int flag");
26
27VM_UNIT_TEST_CASE(ParseFlags) {
28 EXPECT_EQ(true, FLAG_parse_flag_bool_test);
29 Flags::Parse("no_parse_flag_bool_test");
30 EXPECT_EQ(false, FLAG_parse_flag_bool_test);
31 Flags::Parse("parse_flag_bool_test");
32 EXPECT_EQ(true, FLAG_parse_flag_bool_test);
33 Flags::Parse("parse_flag_bool_test=false");
34 EXPECT_EQ(false, FLAG_parse_flag_bool_test);
35 Flags::Parse("parse_flag_bool_test=true");
36 EXPECT_EQ(true, FLAG_parse_flag_bool_test);
37
38 EXPECT_EQ(true, FLAG_string_opt_test == nullptr);
39 Flags::Parse("string_opt_test=doobidoo");
40 EXPECT_EQ(true, FLAG_string_opt_test != nullptr);
41 EXPECT_EQ(0, strcmp(FLAG_string_opt_test, "doobidoo"));
42 FLAG_string_opt_test = reinterpret_cast<charp>(0xDEADBEEF);
43 Flags::Parse("string_opt_test=foofoo");
44 EXPECT_EQ(true, FLAG_string_opt_test != nullptr);
45 EXPECT_EQ(0, strcmp(FLAG_string_opt_test, "foofoo"));
46
47 EXPECT_EQ(true, FLAG_entrypoint_test != nullptr);
48 EXPECT_EQ(0, strcmp(FLAG_entrypoint_test, "main"));
49
50 EXPECT_EQ(100, FLAG_counter);
51 Flags::Parse("counter=-300");
52 EXPECT_EQ(-300, FLAG_counter);
53 Flags::Parse("counter=$300");
54 EXPECT_EQ(-300, FLAG_counter);
55}
56
57} // namespace dart
const char * charp
Definition: flags.h:12
Definition: dart_vm.cc:33
DEFINE_FLAG(bool, print_cluster_information, false, "Print information about clusters written to snapshot")
DECLARE_FLAG(bool, show_invisible_frames)
VM_UNIT_TEST_CASE(DirectoryCurrentNoScope)