MCPcopy Create free account
hub / github.com/apache/fory / TEST

Function TEST

cpp/fory/util/pool_test.cc:32–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30namespace {
31
32TEST(PoolTest, AcquireUsesFactory) {
33 size_t created = 0;
34 Pool<size_t> pool([&created] {
35 ++created;
36 return std::make_unique<size_t>(created);
37 });
38
39 size_t *first_ptr = nullptr;
40 {
41 auto first = pool.acquire();
42 ASSERT_TRUE(first);
43 first_ptr = first.get();
44 EXPECT_EQ(*first, 1U);
45 }
46
47 {
48 auto second = pool.acquire();
49 ASSERT_TRUE(second);
50 EXPECT_EQ(second.get(), first_ptr);
51 EXPECT_EQ(*second, 1U);
52 EXPECT_EQ(created, 1U);
53 }
54}
55
56TEST(PoolTest, BorrowReturnsValue) {
57 Pool<int> pool([] { return std::make_unique<int>(3); });

Callers

nothing calls this directly

Calls 4

borrowMethod · 0.80
getMethod · 0.65
acquireMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected