Flutter Engine
The Flutter Engine
Functions
TestRunner::FlagValidators Namespace Reference

Functions

void StringNonEmpty (std::string name, CommandLineFlags::StringArray flag)
 
void StringAtMostOne (std::string name, CommandLineFlags::StringArray flag)
 
void StringEven (std::string name, CommandLineFlags::StringArray flag)
 
void IntGreaterOrEqual (std::string name, int flag, int min)
 
void AllOrNone (std::map< std::string, bool > flags)
 
void ExactlyOne (std::map< std::string, bool > flags)
 

Function Documentation

◆ AllOrNone()

void TestRunner::FlagValidators::AllOrNone ( std::map< std::string, bool >  flags)

Definition at line 44 of file TestRunner.cpp.

44 {
45 std::string names;
46 unsigned int numFlagsSet = 0;
47 for (auto const& [name, isSet] : flags) {
48 if (names == "") {
49 names = name;
50 } else {
51 names += ", " + name;
52 }
53 if (isSet) {
54 numFlagsSet++;
55 }
56 }
57 if (numFlagsSet != flags.size() && numFlagsSet != 0) {
58 SK_ABORT("Either all or none of the following flags must be set: %s.\n", names.c_str());
59 }
60}
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
FlutterSemanticsFlag flags
static const char *const names[]
Definition: symbols.cc:24
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ ExactlyOne()

void TestRunner::FlagValidators::ExactlyOne ( std::map< std::string, bool >  flags)

Definition at line 62 of file TestRunner.cpp.

62 {
63 std::string names;
64 unsigned int numFlagsSet = 0;
65 for (auto const& [name, isSet] : flags) {
66 if (names == "") {
67 names = name;
68 } else {
69 names += ", " + name;
70 }
71 if (isSet) {
72 numFlagsSet++;
73 }
74 }
75 if (numFlagsSet != 1) {
76 SK_ABORT("Exactly one of the following flags must be set: %s.\n", names.c_str());
77 }
78}

◆ IntGreaterOrEqual()

void TestRunner::FlagValidators::IntGreaterOrEqual ( std::string  name,
int  flag,
int  min 
)

Definition at line 38 of file TestRunner.cpp.

38 {
39 if (flag < min) {
40 SK_ABORT("Flag %s must be greater or equal than %d, got: %d.\n", name.c_str(), min, flag);
41 }
42}
FlutterSemanticsFlag flag
static float min(float r, float g, float b)
Definition: hsl.cpp:48

◆ StringAtMostOne()

void TestRunner::FlagValidators::StringAtMostOne ( std::string  name,
CommandLineFlags::StringArray  flag 
)

Definition at line 24 of file TestRunner.cpp.

25 {
26 if (flag.size() > 1) {
27 SK_ABORT("Flag %s takes one single value, got: %d.\n", name.c_str(), flag.size());
28 }
29}

◆ StringEven()

void TestRunner::FlagValidators::StringEven ( std::string  name,
CommandLineFlags::StringArray  flag 
)

Definition at line 31 of file TestRunner.cpp.

31 {
32 if (flag.size() % 2 == 1) {
34 "Flag %s takes an even number of arguments, got: %d.\n", name.c_str(), flag.size());
35 }
36}

◆ StringNonEmpty()

void TestRunner::FlagValidators::StringNonEmpty ( std::string  name,
CommandLineFlags::StringArray  flag 
)

Definition at line 17 of file TestRunner.cpp.

18 {
19 if (flag.size() == 0) {
20 SK_ABORT("Flag %s cannot be empty.\n", name.c_str());
21 }
22}