summaryrefslogtreecommitdiff
path: root/src/charon-tkm/tests/chunk_map_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/charon-tkm/tests/chunk_map_tests.c')
-rw-r--r--src/charon-tkm/tests/chunk_map_tests.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/charon-tkm/tests/chunk_map_tests.c b/src/charon-tkm/tests/chunk_map_tests.c
new file mode 100644
index 000000000..6deef9a80
--- /dev/null
+++ b/src/charon-tkm/tests/chunk_map_tests.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Reto Buerki
+ * Copyright (C) 2012 Adrian-Ken Rueegsegger
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include <check.h>
+
+#include "tkm_chunk_map.h"
+
+START_TEST(test_chunk_map_creation)
+{
+ tkm_chunk_map_t *map = NULL;
+
+ map = tkm_chunk_map_create();
+ fail_if(map == NULL, "Error creating chunk map");
+
+ map->destroy(map);
+}
+END_TEST
+
+START_TEST(test_chunk_map_handling)
+{
+ tkm_chunk_map_t *map = NULL;
+ const int ref = 35;
+ chunk_t data = chunk_from_thing(ref);
+
+ map = tkm_chunk_map_create();
+ fail_if(map == NULL, "Error creating chunk map");
+
+ map->insert(map, &data, 24);
+ fail_if(map->get_id(map, &data) != 24, "Id mismatch");
+
+ fail_unless(map->remove(map, &data), "Unable to remove mapping");
+ fail_unless(!map->get_id(map, &data), "Error removing mapping");
+
+ map->destroy(map);
+}
+END_TEST
+
+TCase *make_chunk_map_tests(void)
+{
+ TCase *tc = tcase_create("Chunk map tests");
+ tcase_add_test(tc, test_chunk_map_creation);
+ tcase_add_test(tc, test_chunk_map_handling);
+
+ return tc;
+}