aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-03-13 15:48:45 -0400
committerNick Mathewson <nickm@torproject.org>2019-03-25 16:35:34 -0400
commitf74301f8fdf168dbd9dbfe77362658656c70fe71 (patch)
tree2e68769a0e843511eabf020ebf92ed7883f58381
parent9fb511526ae37cb7c7b5ed4714550f58882ef697 (diff)
downloadtor-f74301f8fdf168dbd9dbfe77362658656c70fe71.tar.gz
tor-f74301f8fdf168dbd9dbfe77362658656c70fe71.zip
Unit test for namemap_fmt_name()
-rw-r--r--src/test/test_namemap.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/test_namemap.c b/src/test/test_namemap.c
index 5134e1451b..df77d4e2de 100644
--- a/src/test/test_namemap.c
+++ b/src/test/test_namemap.c
@@ -142,6 +142,25 @@ test_namemap_internals(void *arg)
namemap_clear(&m);
}
+static void
+test_namemap_fmt(void *arg)
+{
+ (void)arg;
+ namemap_t m = NAMEMAP_INIT();
+
+ unsigned a = namemap_get_or_create_id(&m, "greetings");
+ unsigned b = namemap_get_or_create_id(&m, "earthlings");
+
+ tt_str_op(namemap_fmt_name(&m, a), OP_EQ, "greetings");
+ tt_str_op(namemap_fmt_name(&m, b), OP_EQ, "earthlings");
+ tt_int_op(a, OP_NE, 100);
+ tt_int_op(b, OP_NE, 100);
+ tt_str_op(namemap_fmt_name(&m, 100), OP_EQ, "{100}");
+
+ done:
+ namemap_clear(&m);
+}
+
#define T(name) \
{ #name, test_namemap_ ## name , 0, NULL, NULL }
@@ -150,5 +169,6 @@ struct testcase_t namemap_tests[] = {
T(toolong),
T(blackbox),
T(internals),
+ T(fmt),
END_OF_TESTCASES
};