diff options
author | Slava Monich <slava.monich@jolla.com> | 2018-01-18 20:36:52 +0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2018-01-18 14:41:47 -0600 |
commit | 007a855bab062af81da3cc5caf68734a974d1e20 (patch) | |
tree | 67f8b746376e01f86f8d3a5f99883184a45d1900 /unit | |
parent | 0797b23c5d15ed0382fa46ddc9536f8e21595884 (diff) | |
download | ofono-007a855bab062af81da3cc5caf68734a974d1e20.tar.gz |
unit: Improve idmap.c unit test coverage
This brings function, line and branch coverage for idmap.c to 100%
Diffstat (limited to 'unit')
-rw-r--r-- | unit/test-idmap.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/unit/test-idmap.c b/unit/test-idmap.c index b0729335..2d2e2266 100644 --- a/unit/test-idmap.c +++ b/unit/test-idmap.c @@ -35,9 +35,12 @@ static void test_alloc(void) idmap = idmap_new(2); g_assert(idmap); + g_assert(idmap_get_min(idmap) == 1); bit = idmap_alloc(idmap); g_assert(bit == 1); + g_assert(idmap_find(idmap, bit)); + g_assert(!idmap_find(idmap, idmap_get_max(idmap) + 1)); bit = idmap_alloc(idmap); g_assert(bit == 2); @@ -62,6 +65,12 @@ static void test_alloc(void) bit = idmap_alloc(idmap); g_assert(bit == 1); + idmap_put(idmap, 1); + idmap_take(idmap, 1); + idmap_take(idmap, 3); + bit = idmap_alloc(idmap); + g_assert(bit == 2); + idmap_free(idmap); } @@ -80,9 +89,24 @@ static void test_alloc_next(void) bit = idmap_alloc_next(idmap, 255); g_assert(bit == 1); + while (idmap_alloc(idmap) < (sizeof(unsigned long) * 8) + 1); + bit = idmap_alloc_next(idmap, 1); + g_assert(bit == (sizeof(unsigned long) * 8) + 2); + + idmap_free(idmap); + + idmap = idmap_new(2); + + g_assert(idmap); + g_assert(idmap_alloc_next(idmap, 0) == 3); + g_assert(idmap_alloc_next(idmap, 3) == 3); + bit = idmap_alloc_next(idmap, 1); g_assert(bit == 2); + bit = idmap_alloc_next(idmap, 2); + g_assert(bit == 1); + idmap_free(idmap); } |