dte test coverage


Directory: ./
File: test/bookmark.c
Date: 2025-11-12 12:04:10
Coverage Exec Excl Total
Lines: 100.0% 17 0 17
Functions: 100.0% 1 0 1
Branches: 100.0% 2 0 2

Line Branch Exec Source
1 #include "test.h"
2 #include "bookmark.h"
3 #include "util/ptr-array.h"
4
5 1 static void test_bookmark_push(TestContext *ctx)
6 {
7 1 PointerArray bookmarks;
8 1 ptr_array_init(&bookmarks, 80);
9 1 ASSERT_NONNULL(bookmarks.ptrs);
10 1 ASSERT_TRUE(bookmarks.alloc >= 80);
11 1 ASSERT_EQ(bookmarks.count, 0);
12
13 1 size_t n = 300;
14
2/2
✓ Branch 10 → 7 taken 300 times.
✓ Branch 10 → 11 taken 1 time.
301 for (size_t i = 0; i < n; i++) {
15 300 bookmark_push(&bookmarks, new_file_location(NULL, i, 0, 0));
16 }
17
18 1 ASSERT_EQ(bookmarks.count, 256);
19 1 ASSERT_TRUE(bookmarks.alloc >= 256);
20
21 1 const FileLocation *loc = bookmarks.ptrs[0];
22 1 EXPECT_EQ(loc->buffer_id, n - 256);
23 1 loc = bookmarks.ptrs[255];
24 1 EXPECT_EQ(loc->buffer_id, n - 1);
25
26 1 ptr_array_free_cb(&bookmarks, FREE_FUNC(file_location_free));
27 1 }
28
29 static const TestEntry tests[] = {
30 TEST(test_bookmark_push),
31 };
32
33 const TestGroup bookmark_tests = TEST_GROUP(tests);
34