Add chunk map
This data structure allows to store mappings of chunks to ids. This will be used to map nonces to their corresponding nonce context ids.
This commit is contained in:
committed by
Tobias Brunner
parent
601de9f36f
commit
3242a178b3
@@ -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;
|
||||
}
|
||||
@@ -28,6 +28,7 @@ int main(void)
|
||||
int number_failed;
|
||||
Suite *s = suite_create("TKM tests");
|
||||
suite_add_tcase(s, make_id_manager_tests());
|
||||
suite_add_tcase(s, make_chunk_map_tests());
|
||||
suite_add_tcase(s, make_nonceg_tests());
|
||||
suite_add_tcase(s, make_diffie_hellman_tests());
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <check.h>
|
||||
|
||||
TCase *make_id_manager_tests(void);
|
||||
TCase *make_chunk_map_tests(void);
|
||||
TCase *make_nonceg_tests(void);
|
||||
TCase *make_diffie_hellman_tests(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user