unicode: use new faster htable
[platform/upstream/libtsm.git] / test / test_hashtable.c
1 /*
2  * TSM - Hashtable Tests
3  *
4  * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files
8  * (the "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25
26 /*
27  * Hashtable Tests
28  * Stress tests for the internal hashtable implementation.
29  */
30
31 #include "test_common.h"
32
33 START_TEST(test_hashtable_setup_valid)
34 {
35         struct shl_hashtable *t = NULL;
36         int r;
37
38         r = shl_hashtable_new(&t, shl_direct_hash, shl_direct_equal,
39                               NULL, NULL);
40         ck_assert(r == 0);
41         ck_assert(t != NULL);
42
43         shl_hashtable_free(t);
44 }
45 END_TEST
46
47 START_TEST(test_hashtable_setup_invalid)
48 {
49         struct shl_hashtable *t = TEST_INVALID_PTR;
50         int r;
51
52         r = shl_hashtable_new(NULL, shl_direct_hash, shl_direct_equal,
53                               NULL, NULL);
54         ck_assert(r != 0);
55         ck_assert(t == TEST_INVALID_PTR);
56
57         r = shl_hashtable_new(&t, NULL, shl_direct_equal,
58                               NULL, NULL);
59         ck_assert(r != 0);
60         ck_assert(t == TEST_INVALID_PTR);
61
62         r = shl_hashtable_new(&t, shl_direct_hash, NULL,
63                               NULL, NULL);
64         ck_assert(r != 0);
65         ck_assert(t == TEST_INVALID_PTR);
66
67         r = shl_hashtable_new(&t, NULL, NULL,
68                               NULL, NULL);
69         ck_assert(r != 0);
70         ck_assert(t == TEST_INVALID_PTR);
71
72         r = shl_hashtable_new(NULL, NULL, NULL,
73                               NULL, NULL);
74         ck_assert(r != 0);
75         ck_assert(t == TEST_INVALID_PTR);
76 }
77 END_TEST
78
79 TEST_DEFINE_CASE(setup)
80         TEST(test_hashtable_setup_valid)
81         TEST(test_hashtable_setup_invalid)
82 TEST_END_CASE
83
84 START_TEST(test_hashtable_add_1)
85 {
86 }
87 END_TEST
88
89 TEST_DEFINE_CASE(add)
90         TEST(test_hashtable_add_1)
91 TEST_END_CASE
92
93 TEST_DEFINE(
94         TEST_SUITE(hashtable,
95                 TEST_CASE(setup),
96                 TEST_CASE(add),
97                 TEST_END
98         )
99 )