Fix test's assumptions regarding contract of parser.
This commit is contained in:
parent
1128038d0f
commit
abc676ef13
@ -55,20 +55,22 @@ void test_instruction_parse() {
|
|||||||
char buffer[] = "4.test,8.testdata,5.zxcvb,13.guacamoletest;XXXXXXXXXXXXXXXXXX";
|
char buffer[] = "4.test,8.testdata,5.zxcvb,13.guacamoletest;XXXXXXXXXXXXXXXXXX";
|
||||||
char* current = buffer;
|
char* current = buffer;
|
||||||
|
|
||||||
/* First element */
|
/* While data remains */
|
||||||
CU_ASSERT_EQUAL(guac_instruction_append(instruction, current, 7), 7);
|
int remaining = sizeof(buffer)-1;
|
||||||
CU_ASSERT_EQUAL(instruction->state, GUAC_INSTRUCTION_PARSE_LENGTH);
|
while (remaining > 18) {
|
||||||
current += 7;
|
|
||||||
|
|
||||||
/* Part of second */
|
/* Parse more data */
|
||||||
CU_ASSERT_EQUAL(guac_instruction_append(instruction, current, 9), 9);
|
int parsed = guac_instruction_append(instruction, current, remaining);
|
||||||
CU_ASSERT_EQUAL(instruction->state, GUAC_INSTRUCTION_PARSE_CONTENT);
|
if (parsed == 0)
|
||||||
current += 9;
|
break;
|
||||||
|
|
||||||
/* Rest of instruction */
|
current += parsed;
|
||||||
CU_ASSERT_EQUAL(guac_instruction_append(instruction, current, 45), 27);
|
remaining -= parsed;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CU_ASSERT_EQUAL(remaining, 18);
|
||||||
CU_ASSERT_EQUAL(instruction->state, GUAC_INSTRUCTION_PARSE_COMPLETE);
|
CU_ASSERT_EQUAL(instruction->state, GUAC_INSTRUCTION_PARSE_COMPLETE);
|
||||||
current += 27;
|
|
||||||
|
|
||||||
/* Parse is complete - no more data should be read */
|
/* Parse is complete - no more data should be read */
|
||||||
CU_ASSERT_EQUAL(guac_instruction_append(instruction, current, 18), 0);
|
CU_ASSERT_EQUAL(guac_instruction_append(instruction, current, 18), 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user