1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* Copyright (C) 2012 Reto Buerki
* Copyright (C) 2012 Adrian-Ken Rueegsegger
* HSR 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 <tests/test_suite.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
Suite *make_chunk_map_tests()
{
Suite *s;
TCase *tc;
s = suite_create("chunk map");
tc = tcase_create("creating");
tcase_add_test(tc, test_chunk_map_creation);
suite_add_tcase(s, tc);
tc = tcase_create("handling");
tcase_add_test(tc, test_chunk_map_handling);
suite_add_tcase(s, tc);
return s;
}
|