#include "gtest/gtest.h"
#include "PagedBuffer.h"

struct X
{
    uint64_t a;
    uint32_t b;
    uint32_t c;
};

struct Y
{
    uint32_t a;
    uint32_t b;
};

TEST(PagedBufferTest, empty_paged_buffer_has_size_0)
{
    PagedBuffer<X> pbx;
    ASSERT_EQ(0u, pbx.size());

    PagedBuffer<Y> pby;
    ASSERT_EQ(0u, pby.size());
}

TEST(PagedBufferTest, allows_adding_elements)
{
    PagedBuffer<X> pbx;

    for (uint32_t i = 0u; i < 1000u; i++)
    {
        X x = {i, 2u * i, 4u * i};
        pbx[i] = x;
    }

    ASSERT_GE(pbx.size(), 1000u);

    for (uint32_t i = 0u; i < 1000u; i++)
    {
        const X & x = pbx[i];
        ASSERT_EQ(i, x.a);
        ASSERT_EQ(2u * i, x.b);
        ASSERT_EQ(4u * i, x.c);
    }
}
