summaryrefslogtreecommitdiffhomepage
path: root/test/path-search-result.cpp
blob: 2ce61ff6e5ddda1d1b57889718ebf798c4efc629 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "app.hpp"
#include "compat/assert.hpp"
#include "src/path-search-result.hpp"
#include "src/path-search-node.hpp"

namespace floormat {

void test_app::test_path_search_node_pool()
{
    auto& pool = path_search_result::_pool;
    fm_assert(!pool);
    {
        auto a = path_search_result{};
        fm_assert(!pool);
    }
    fm_assert(pool);
    auto* pool2 = pool.get();
    {
        auto b = path_search_result{};
        fm_assert(b._node.get() == pool2);
        auto c = path_search_result{};
        fm_assert(!pool);
        fm_assert(c._node.get() != pool2);
        fm_assert(b._node.get() == pool2);
        fm_assert(!b._node->_next);
        fm_assert(!c._node->_next);
    }
    {
        auto count = 0uz;
        for (const auto* ptr = pool.get(); ptr; ptr = ptr->_next.get())
            count++;
        fm_assert(count == 2);
    }
}

} // namespace floormat