aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorSaksham Mittal <gotlouemail@gmail.com>2023-03-19 08:27:42 +0530
committerSaksham Mittal <gotlouemail@gmail.com>2023-03-19 08:28:29 +0530
commitbbb3396d7925e5d08617f31340514f4d7f2684b8 (patch)
tree0f15eb7f063cc76ddf0215dcbfcd1d14fc7d2d0b /src/test
parent447775a5e0b2178b44826cf6802a9c5e779a45d1 (diff)
downloadtor-bbb3396d7925e5d08617f31340514f4d7f2684b8.tar.gz
tor-bbb3396d7925e5d08617f31340514f4d7f2684b8.zip
Add test for \r in directory parsing
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_parsecommon.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/test_parsecommon.c b/src/test/test_parsecommon.c
index b32840264e..a171cfa7cf 100644
--- a/src/test/test_parsecommon.c
+++ b/src/test/test_parsecommon.c
@@ -254,6 +254,32 @@ test_parsecommon_get_next_token_success(void *arg)
}
static void
+test_parsecommon_get_next_token_carriage_return(void *arg)
+{
+ memarea_t *area = memarea_new();
+ const char *str = "uptime 1024\r";
+ const char *end = str + strlen(str);
+ const char **s = &str;
+ token_rule_t table = T01("uptime", K_UPTIME, GE(1), NO_OBJ);
+ (void)arg;
+
+ directory_token_t *token = get_next_token(area, s, end, &table);
+
+ tt_int_op(token->tp, OP_EQ, K_UPTIME);
+ tt_int_op(token->n_args, OP_EQ, 1);
+ tt_str_op(*(token->args), OP_EQ, "1024");
+ tt_assert(!token->object_type);
+ tt_int_op(token->object_size, OP_EQ, 0);
+ tt_assert(!token->object_body);
+
+ tt_ptr_op(*s, OP_EQ, end);
+
+ done:
+ memarea_drop_all(area);
+ return;
+}
+
+static void
test_parsecommon_get_next_token_concat_args(void *arg)
{
memarea_t *area = memarea_new();
@@ -571,6 +597,7 @@ test_parsecommon_get_next_token_err_bad_base64(void *arg)
struct testcase_t parsecommon_tests[] = {
PARSECOMMON_TEST(tokenize_string_null),
+ PARSECOMMON_TEST(get_next_token_carriage_return),
PARSECOMMON_TEST(tokenize_string_multiple_lines),
PARSECOMMON_TEST(tokenize_string_min_cnt),
PARSECOMMON_TEST(tokenize_string_max_cnt),