Annotation of embedaddon/strongswan/src/charon-tkm/tests/chunk_map_tests.c, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2012 Reto Buerki
! 3: * Copyright (C) 2012 Adrian-Ken Rueegsegger
! 4: * HSR Hochschule fuer Technik Rapperswil
! 5: *
! 6: * This program is free software; you can redistribute it and/or modify it
! 7: * under the terms of the GNU General Public License as published by the
! 8: * Free Software Foundation; either version 2 of the License, or (at your
! 9: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
! 10: *
! 11: * This program is distributed in the hope that it will be useful, but
! 12: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 13: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
! 14: * for more details.
! 15: */
! 16:
! 17: #include <tests/test_suite.h>
! 18:
! 19: #include "tkm_chunk_map.h"
! 20:
! 21: START_TEST(test_chunk_map_creation)
! 22: {
! 23: tkm_chunk_map_t *map = NULL;
! 24:
! 25: map = tkm_chunk_map_create();
! 26: fail_if(map == NULL, "Error creating chunk map");
! 27:
! 28: map->destroy(map);
! 29: }
! 30: END_TEST
! 31:
! 32: START_TEST(test_chunk_map_handling)
! 33: {
! 34: tkm_chunk_map_t *map = NULL;
! 35: const int ref = 35;
! 36: chunk_t data = chunk_from_thing(ref);
! 37:
! 38: map = tkm_chunk_map_create();
! 39: fail_if(map == NULL, "Error creating chunk map");
! 40:
! 41: map->insert(map, &data, 24);
! 42: fail_if(map->get_id(map, &data) != 24, "Id mismatch");
! 43:
! 44: fail_unless(map->remove(map, &data), "Unable to remove mapping");
! 45: fail_unless(!map->get_id(map, &data), "Error removing mapping");
! 46:
! 47: map->destroy(map);
! 48: }
! 49: END_TEST
! 50:
! 51: Suite *make_chunk_map_tests()
! 52: {
! 53: Suite *s;
! 54: TCase *tc;
! 55:
! 56: s = suite_create("chunk map");
! 57:
! 58: tc = tcase_create("creating");
! 59: tcase_add_test(tc, test_chunk_map_creation);
! 60: suite_add_tcase(s, tc);
! 61:
! 62: tc = tcase_create("handling");
! 63: tcase_add_test(tc, test_chunk_map_handling);
! 64: suite_add_tcase(s, tc);
! 65:
! 66: return s;
! 67: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>