Skip to content
Snippets Groups Projects
Commit c4e762ae authored by Edgar Makarov's avatar Edgar Makarov
Browse files

Add more schemas to bp-4-scan-test

parent 7058db7d
Branches
No related merge requests found
......@@ -14,25 +14,30 @@
namespace
{
auto fixed_schema = std::make_shared<shdb::Schema>(shdb::Schema{
{"id", shdb::Type::uint64}, {"name", shdb::Type::varchar, 1024}, {"age", shdb::Type::uint64}, {"graduated", shdb::Type::boolean}});
std::vector<std::shared_ptr<shdb::Schema>> schemas = {
std::make_shared<shdb::Schema>(shdb::Schema{
{"id", shdb::Type::uint64}, {"name", shdb::Type::varchar, 1024}, {"age", shdb::Type::uint64}, {"graduated", shdb::Type::boolean}}),
std::make_shared<shdb::Schema>(shdb::Schema{
{"id", shdb::Type::uint64}, {"name", shdb::Type::varchar, 512}, {"age", shdb::Type::uint64}, {"graduated", shdb::Type::boolean}}),
std::make_shared<shdb::Schema>(shdb::Schema{
{"id", shdb::Type::uint64}, {"name", shdb::Type::string}, {"age", shdb::Type::uint64}, {"graduated", shdb::Type::boolean}})};
std::shared_ptr<shdb::Database> createDatabase(int frame_count)
std::shared_ptr<shdb::Database> createDatabase(int frame_count, std::shared_ptr<shdb::Schema> schema)
{
auto db = shdb::connect("./mydb", frame_count);
if (db->checkTableExists("test_table"))
db->dropTable("test_table");
db->createTable("test_table", fixed_schema);
db->createTable("test_table", schema);
return db;
}
}
void testMetadataPrepare()
void testMetadataPrepare(std::shared_ptr<shdb::Schema> schema)
{
shdb::PageIndex pool_size = 5;
auto db = createDatabase(pool_size);
auto table = db->getTable("test_table", fixed_schema);
auto db = createDatabase(pool_size, schema);
auto table = db->getTable("test_table", schema);
std::vector<std::pair<shdb::RowId, shdb::Row>> rows;
shdb::PageIndex page_count = 0;
......@@ -72,7 +77,11 @@ void testMetadataValidate()
TEST(BufferPool, Metadata)
{
testMetadataPrepare();
std::cout << "Validating metadata in the same process:" << std::endl;
testMetadataValidate();
for (size_t i = 0; i != schemas.size(); ++i)
{
std::cout << "Testing metadata with schema " << i << std::endl;
testMetadataPrepare(schemas[i]);
std::cout << "Validating metadata in the same process:" << std::endl;
testMetadataValidate();
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment