aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_parsecommon.c
diff options
context:
space:
mode:
authorSaksham Mittal <gotlouemail@gmail.com>2023-03-31 11:04:18 +0530
committerSaksham Mittal <gotlouemail@gmail.com>2023-03-31 11:04:18 +0530
commit738785ead8fae752d40a3afa8b861d52519eabe0 (patch)
tree4755c7ce68b98839ad8b353f0b60cc1745e08981 /src/test/test_parsecommon.c
parentc5889d3f1584e60633f4dfec6e63f6dc471915e2 (diff)
downloadtor-738785ead8fae752d40a3afa8b861d52519eabe0.tar.gz
tor-738785ead8fae752d40a3afa8b861d52519eabe0.zip
Test both \r and \r\n with the expected failure conditions added
Diffstat (limited to 'src/test/test_parsecommon.c')
-rw-r--r--src/test/test_parsecommon.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/test/test_parsecommon.c b/src/test/test_parsecommon.c
index 06dbea3a75..866f89a4e1 100644
--- a/src/test/test_parsecommon.c
+++ b/src/test/test_parsecommon.c
@@ -267,13 +267,15 @@ test_parsecommon_get_next_token_carriage_return(void *arg)
END_OF_TABLE,
};
- char *str = tor_strdup("hibernating 0\r\nuptime 1024\n");
+ char *str = tor_strdup(
+ "hibernating 0\r\nuptime 1024\n"
+ "hibernating 0\ruptime 1024\n");
int retval =
tokenize_string(area, str, NULL,
tokens, table, 0);
- tt_int_op(smartlist_len(tokens), OP_EQ, 2);
+ tt_int_op(smartlist_len(tokens), OP_EQ, 3);
directory_token_t *token = smartlist_get(tokens, 0);
tt_int_op(token->tp, OP_EQ, K_HIBERNATING);
@@ -282,7 +284,11 @@ test_parsecommon_get_next_token_carriage_return(void *arg)
tt_int_op(token->tp, OP_EQ, K_UPTIME);
- tt_int_op(retval, OP_EQ, 0);
+ token = smartlist_get(tokens, 2);
+
+ tt_int_op(token->tp, OP_EQ, K_HIBERNATING);
+
+ tt_int_op(retval, OP_EQ, -1);
done:
tor_free(str);
@@ -291,7 +297,6 @@ test_parsecommon_get_next_token_carriage_return(void *arg)
return;
}
-
static void
test_parsecommon_get_next_token_concat_args(void *arg)
{