diff options
author | Qingping Hou <dave2008713@gmail.com> | 2014-01-26 00:18:55 -0500 |
---|---|---|
committer | Qingping Hou <dave2008713@gmail.com> | 2014-01-29 22:47:05 -0500 |
commit | ebd99314cff907433eca835926a325c019f4b6c0 (patch) | |
tree | dfeae399f862f4d8a8cc95a6df7d0b7ba17d43fc /src/test/test_router.c | |
parent | 0b0d4b4ebcfe3711a8bcd27cbbdc05cd02530f38 (diff) | |
download | tor-ebd99314cff907433eca835926a325c019f4b6c0.tar.gz tor-ebd99314cff907433eca835926a325c019f4b6c0.zip |
add test case for node_describe_by_id
Diffstat (limited to 'src/test/test_router.c')
-rw-r--r-- | src/test/test_router.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/test_router.c b/src/test/test_router.c new file mode 100644 index 0000000000..c13ccc643e --- /dev/null +++ b/src/test/test_router.c @@ -0,0 +1,38 @@ +/* Copyright (c) 2007-2013, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file test_router.c + * \brief Unit tests for router related functions. + **/ + +#include "or.h" +#include "nodelist.h" +#include "router.h" +#include "test.h" + + +/** Tese the case when node_get_by_id() returns NULL, node_describe_by_id + * should return the base 16 encoding of the id. + */ +static void +test_node_describe_by_id_null_node(void *arg) +{ + (void) arg; + + #define ID "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" + + /* make sure node_get_by_id returns NULL */ + test_assert(!node_get_by_id(ID)); + test_streq(node_describe_by_id(ID), + "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); +done: + return; +} + +struct testcase_t router_tests[] = { + { "node_get_by_id_null_node", test_node_describe_by_id_null_node, TT_FORK, + NULL, NULL }, + END_OF_TESTCASES +}; + |