46 const char*
string =
"aa \t\n {\"bbb(bbb bbb)bbb {\"{a}\n/* foooo { } \n { } */\n// fooooo\naaaa";
47 const char* cursor = string;
52 ASSERT_STREQ(token,
"aa");
56 ASSERT_STREQ(token,
"{");
60 ASSERT_STREQ(token,
"bbb(bbb bbb)bbb {");
64 ASSERT_STREQ(token,
"{");
68 ASSERT_STREQ(token,
"a");
72 ASSERT_STREQ(token,
"}");
76 ASSERT_STREQ(token,
"aaaa");
80 ASSERT_STREQ(token,
"\0");
88 const char*
string =
"\n\taaaa \" \\n \\t \\\" \"";
89 const char* cursor = string;
94 ASSERT_STREQ(token,
"aaaa");
98 ASSERT_STREQ(token,
" \n \t \" ");
106 const char*
string =
"aaaaa\n\tbbbbb \"ccccc\"";
107 const char* cursor = string;
112 ASSERT_STREQ(token,
"aaaaa");
118 ASSERT_STREQ(token,
"aaaaa");
124 ASSERT_STREQ(token,
"aaaaa");
128 ASSERT_STREQ(token,
"bbbbb");
134 ASSERT_STREQ(token,
"bbbbb");
140 ASSERT_STREQ(token,
"bbbbb");
144 ASSERT_STREQ(token,
"ccccc");
150 ASSERT_STREQ(token,
"ccccc");
156 ASSERT_STREQ(token,
"ccccc");
164 const char*
string =
"aa \t\n aa,({\"bbb(bbb bbb)bbb {\"{a}\n/* foooo { } \n { } */\n// fooooo\naaaa)";
165 const char* cursor = string;
170 ASSERT_STREQ(token,
"aa");
174 ASSERT_STREQ(token,
"aa");
178 ASSERT_STREQ(token,
",");
182 ASSERT_STREQ(token,
"(");
186 ASSERT_STREQ(token,
"{");
190 ASSERT_STREQ(token,
"bbb(bbb bbb)bbb {");
194 ASSERT_STREQ(token,
"{");
198 ASSERT_STREQ(token,
"a");
202 ASSERT_STREQ(token,
"}");
206 ASSERT_STREQ(token,
"aaaa");
210 ASSERT_STREQ(token,
")");
214 ASSERT_STREQ(token,
"\0");
237 ASSERT_EQ(bvalue, 1);
238 ASSERT_EQ(bytes,
sizeof(
bool));
243 ASSERT_EQ(bvalue, 0);
244 ASSERT_EQ(bytes,
sizeof(
bool));
256 ASSERT_EQ(ivalue, 10);
257 ASSERT_EQ(bytes,
sizeof(
int));
269 ASSERT_EQ(fvalue, 1.1f);
270 ASSERT_EQ(bytes,
sizeof(
float));
275 ASSERT_EQ(fvalue, 9.8f);
276 ASSERT_EQ(bytes,
sizeof(
float));
296 ASSERT_EQ(bytes,
sizeof(
align_t));
309 ASSERT_EQ(bytes,
sizeof(
blend_t));
322 ASSERT_EQ(bytes,
sizeof(
style_t));
335 ASSERT_EQ(bytes,
sizeof(
fade_t));
348 const char*
string =
" ( aaa \n \"bbb\" \t ccc \n \n ) ";
349 const char* cursor = string;
352 ASSERT_TRUE(
Com_ParseList(&cursor, &list)) <<
"List parsing failed";
356 ASSERT_STREQ(
static_cast<const char*
>(list->
data),
"aaa");
357 ASSERT_STREQ(
static_cast<const char*
>(list->
next->
data),
"bbb");
358 ASSERT_STREQ(
static_cast<const char*
>(list->
next->
next->
data),
"ccc");
369 const char*
string =
" ( \n ) ()";
370 const char* cursor = string;
373 ASSERT_TRUE(
Com_ParseList(&cursor, &list)) <<
"List parsing failed";
377 ASSERT_TRUE(
Com_ParseList(&cursor, &list)) <<
"List parsing failed";
387 const char*
string =
" ( aaa \n bbb \t ccc \n \n";
388 const char* cursor = string;
391 ASSERT_FALSE(
Com_ParseList(&cursor, &list)) <<
"List parsing succeed, which is wrong";
399 const char*
string =
" ( aaa \n bbb \t ccc \n \n } ";
400 const char* cursor = string;
403 ASSERT_FALSE(
Com_ParseList(&cursor, &list)) <<
"List parsing succeed, which is wrong";
411 const char*
string =
" ( aaa \n bbb \t ccc \n \n ( ";
412 const char* cursor = string;
415 ASSERT_FALSE(
Com_ParseList(&cursor, &list)) <<
"List parsing succeed, which is wrong";
static void TearDownTestCase()
static void SetUpTestCase()
void LIST_Delete(linkedList_t **list)
int LIST_Count(const linkedList_t *list)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
void Com_UnParseLastToken(void)
Put back the last token into the parser The next call of Com_Parse will return the same token again.
Com_TokenType_t Com_GetType(const char **data_p)
Get the current token type.
Shared parsing functions.
bool Com_ParseList(const char **text, linkedList_t **list)
resultStatus_t Com_ParseValue(void *base, const char *token, valueTypes_t type, int ofs, size_t size, size_t *writtenBytes)
Parse a value from a string.
align_t
We need this here for checking the boundaries from script values.
TEST_F(ParserTest, Parser)
unittest around default use of parser
Cross-platform type definitions.