summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-10-01 12:52:13 -0400
committerNick Mathewson <nickm@torproject.org>2019-10-01 13:01:20 -0400
commit34bbdaf5d4673491216b64f5ab983518b3f8c7d1 (patch)
tree63b6c5fc8ac421b1fb3ee52c4e76216751ec6a89
parentf17591b8e504af9e088bd9df900639c83f5300fe (diff)
downloadtor-34bbdaf5d4673491216b64f5ab983518b3f8c7d1.tar.gz
tor-34bbdaf5d4673491216b64f5ab983518b3f8c7d1.zip
Add a test for max_u16_in_sl().
This test does not currently pass, because of bug 31898.
-rw-r--r--src/test/test_dispatch.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/test_dispatch.c b/src/test/test_dispatch.c
index d6fe7e781a..a62c18e0c9 100644
--- a/src/test/test_dispatch.c
+++ b/src/test/test_dispatch.c
@@ -1,6 +1,7 @@
/* Copyright (c) 2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+#define DISPATCH_NEW_PRIVATE
#define DISPATCH_PRIVATE
#include "test/test.h"
@@ -19,6 +20,33 @@
static dispatch_t *dispatcher_in_use=NULL;
+static void
+test_dispatch_max_in_u16_sl(void *arg)
+{
+ (void)arg;
+ smartlist_t *sl = smartlist_new();
+ uint16_t nums[] = { 10, 20, 30 };
+ tt_int_op(-1, OP_EQ, max_in_u16_sl(sl, -1));
+
+ smartlist_add(sl, NULL);
+ tt_int_op(-1, OP_EQ, max_in_u16_sl(sl, -1));
+
+ smartlist_add(sl, &nums[1]);
+ tt_int_op(20, OP_EQ, max_in_u16_sl(sl, -1));
+
+ smartlist_add(sl, &nums[0]);
+ tt_int_op(20, OP_EQ, max_in_u16_sl(sl, -1));
+
+ smartlist_add(sl, NULL);
+ tt_int_op(20, OP_EQ, max_in_u16_sl(sl, -1));
+
+ smartlist_add(sl, &nums[2]);
+ tt_int_op(30, OP_EQ, max_in_u16_sl(sl, -1));
+
+ done:
+ smartlist_free(sl);
+}
+
/* Construct an empty dispatch_t. */
static void
test_dispatch_empty(void *arg)
@@ -240,6 +268,7 @@ test_dispatch_bad_type_setup(void *arg)
{ #name, test_dispatch_ ## name, TT_FORK, NULL, NULL }
struct testcase_t dispatch_tests[] = {
+ T(max_in_u16_sl),
T(empty),
T(simple),
T(no_recipient),