dte test coverage


Directory: ./
File: test/bookmark.c
Date: 2024-12-21 16:03:22
Exec Total Coverage
Lines: 17 17 100.0%
Functions: 1 1 100.0%
Branches: 2 2 100.0%

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 0 taken 300 times.
✓ Branch 1 taken 1 times.
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