#include "tile/base/object_pool.h"

#include "gtest/gtest.h"

#include <vector>

namespace tile {

static int alive = 0;

struct Obj {
    Obj() { ++alive; }

    ~Obj() { --alive; }
};

template<>
struct PoolTraits<Obj> {
    static constexpr auto kType = PoolType::Disabled;
};

namespace object_pool {

TEST(DisabledPool, All)
{
    std::vector<PooledPtr<Obj>> ptrs;
    for (int i = 0; i != 1000; ++i) { ptrs.push_back(Get<Obj>()); }
    ASSERT_EQ(1000, alive);
    ptrs.clear();
    ASSERT_EQ(0, alive);
    Get<Obj>();
    ASSERT_EQ(0, alive);
}

}// namespace object_pool
}// namespace tile
