test_nodelist.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* Copyright (c) 2007-2013, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file test_nodelist.c
  5. * \brief Unit tests for nodelist related functions.
  6. **/
  7. #include "or.h"
  8. #include "nodelist.h"
  9. #include "test.h"
  10. /** Tese the case when node_get_by_id() returns NULL,
  11. * node_get_verbose_nickname_by_id should return the base 16 encoding
  12. * of the id.
  13. */
  14. static void
  15. test_nodelist_node_get_verbose_nickname_by_id_null_node(void *arg)
  16. {
  17. char vname[MAX_VERBOSE_NICKNAME_LEN+1];
  18. const char ID[] = "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
  19. "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA";
  20. (void) arg;
  21. /* make sure node_get_by_id returns NULL */
  22. test_assert(!node_get_by_id(ID));
  23. node_get_verbose_nickname_by_id(ID, vname);
  24. test_streq(vname, "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
  25. done:
  26. return;
  27. }
  28. #define NODE(name, flags) \
  29. { #name, test_nodelist_##name, (flags), NULL, NULL }
  30. struct testcase_t nodelist_tests[] = {
  31. NODE(node_get_verbose_nickname_by_id_null_node, TT_FORK),
  32. END_OF_TESTCASES
  33. };