aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_parsecommon.c
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2018-10-12 14:19:40 +0300
committerrl1987 <rl1987@sdf.lonestar.org>2018-10-16 18:04:20 +0300
commit7829e3a86875da16e3d7ac55be85145bd672fc12 (patch)
tree8323205410fda93cf13a9e85b98c04cc7661168d /src/test/test_parsecommon.c
parent55412c4f3d3486d28fe337b919e7fddc2f93e1b4 (diff)
downloadtor-7829e3a86875da16e3d7ac55be85145bd672fc12.tar.gz
tor-7829e3a86875da16e3d7ac55be85145bd672fc12.zip
First testcase for get_next_token()
Diffstat (limited to 'src/test/test_parsecommon.c')
-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 f152450f5a..ba778d9969 100644
--- a/src/test/test_parsecommon.c
+++ b/src/test/test_parsecommon.c
@@ -34,11 +34,38 @@ test_parsecommon_tokenize_string_null(void *arg)
return;
}
+static void
+test_parsecommon_get_next_token_success(void *arg)
+{
+ memarea_t *area = memarea_new();
+ const char *str = "uptime 1024";
+ 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;
+}
+
#define PARSECOMMON_TEST(name) \
{ #name, test_parsecommon_ ## name, 0, NULL, NULL }
struct testcase_t parsecommon_tests[] = {
PARSECOMMON_TEST(tokenize_string_null),
+ PARSECOMMON_TEST(get_next_token_success),
END_OF_TESTCASES
};