aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_parsecommon.c
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2018-10-11 15:22:12 +0300
committerrl1987 <rl1987@sdf.lonestar.org>2018-10-16 18:04:17 +0300
commit55412c4f3d3486d28fe337b919e7fddc2f93e1b4 (patch)
tree2a5b839ee25212a65e778e024b339fbc1da705a9 /src/test/test_parsecommon.c
parentb7fbd1f3297d548b16a18bbc7a5636c80fff70de (diff)
downloadtor-55412c4f3d3486d28fe337b919e7fddc2f93e1b4.tar.gz
tor-55412c4f3d3486d28fe337b919e7fddc2f93e1b4.zip
Add new source file to test target
Diffstat (limited to 'src/test/test_parsecommon.c')
-rw-r--r--src/test/test_parsecommon.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/test/test_parsecommon.c b/src/test/test_parsecommon.c
new file mode 100644
index 0000000000..f152450f5a
--- /dev/null
+++ b/src/test/test_parsecommon.c
@@ -0,0 +1,44 @@
+/* Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#include "core/or/or.h"
+#include "test/test.h"
+#include "lib/memarea/memarea.h"
+#include "lib/encoding/binascii.h"
+#include "feature/dirparse/parsecommon.h"
+#include "test/log_test_helpers.h"
+
+static void
+test_parsecommon_tokenize_string_null(void *arg)
+{
+
+ memarea_t *area = memarea_new();
+ smartlist_t *tokens = smartlist_new();
+
+ (void)arg;
+
+ const char *str_with_null = "a\0bccccccccc";
+
+ int retval =
+ tokenize_string(area, str_with_null,
+ str_with_null + 3,
+ tokens, NULL, 0);
+
+ tt_int_op(retval, OP_EQ, -1);
+
+ done:
+ memarea_drop_all(area);
+ smartlist_free(tokens);
+ return;
+}
+
+#define PARSECOMMON_TEST(name) \
+ { #name, test_parsecommon_ ## name, 0, NULL, NULL }
+
+struct testcase_t parsecommon_tests[] = {
+ PARSECOMMON_TEST(tokenize_string_null),
+ END_OF_TESTCASES
+};
+