blob: 4a1f9f67a5ea1d3dea774a3829a4b93d7b360268 [file] [log] [blame]
#include "pldmd/instance_id.hpp"
#include <stdexcept>
#include <gtest/gtest.h>
using namespace pldm;
TEST(InstanceId, testNext)
{
InstanceId id;
ASSERT_EQ(id.next(), 0);
ASSERT_EQ(id.next(), 1);
}
TEST(InstanceId, testAllUsed)
{
InstanceId id;
for (size_t i = 0; i < maxInstanceIds; ++i)
{
ASSERT_EQ(id.next(), i);
}
EXPECT_THROW(id.next(), std::runtime_error);
}
TEST(InstanceId, testMarkfree)
{
InstanceId id;
for (size_t i = 0; i < maxInstanceIds; ++i)
{
ASSERT_EQ(id.next(), i);
}
id.markFree(5);
ASSERT_EQ(id.next(), 5);
id.markFree(0);
ASSERT_EQ(id.next(), 0);
EXPECT_THROW(id.next(), std::runtime_error);
EXPECT_THROW(id.markFree(32), std::out_of_range);
}