From e338c4b63c6a9258d858f158049943e1e8f00e6f Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 18 Sep 2023 14:12:22 +0200 Subject: Lib: Extend MPLS label allocator bitmap Add function lmap_last_one_in_range() for finding the last active label in a label range. --- lib/bitmap_test.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/bitmap_test.c') diff --git a/lib/bitmap_test.c b/lib/bitmap_test.c index 3aeeaef5..39fbd0ed 100644 --- a/lib/bitmap_test.c +++ b/lib/bitmap_test.c @@ -216,6 +216,18 @@ t_lmap_set_clear_fill(void) lmap_clear(&b, n); expected[n] = 0; } + + { + n = lmap_last_one_in_range(&b, lo, hi); + bt_assert(n >= lo); + bt_assert(n <= hi); + + for (last = n + 1; last < hi; last++) + bt_assert(!expected[last]); + + if (n < hi) + bt_assert(expected[n]); + } } uint cnt = 0; -- cgit v1.2.3