Ejemplo n.º 1
0
TEST(table, uniqueConstraints) {
    Constraint c1, c2;
    c1.name = "constraint 1";
    c2.type = ConstraintType::PRIMARY_KEY;
    c2.name = "constraint 2";
    c2.type = ConstraintType::UNIQUE;

    Table t;
    t.add_constraint(c1);
    t.add_constraint(c2);

    auto constraints = t.unique_constraints();
    EXPECT_EQ(1, constraints.size());
    EXPECT_EQ("constraint 2", constraints[0].name);
}
Ejemplo n.º 2
0
TEST(table, fkeyConstraints) {
    Constraint c1, c2;
    c1.name = "constraint 1";
    c2.type = ConstraintType::PRIMARY_KEY;
    c2.name = "constraint 2";
    c2.type = ConstraintType::FOREIGN_KEY;

    Table t;
    t.add_constraint(c1);
    t.add_constraint(c2);

    auto constraints = t.fkey_constraints();
    EXPECT_EQ(1, constraints.size());
    EXPECT_EQ("constraint 2", constraints[0].name);
}
Ejemplo n.º 3
0
TEST(table, constraints) {
    Constraint c1, c2;
    c1.name = "constraint 1";
    c2.name = "constraint 2";

    Table t;
    t.add_constraint(c1);
    t.add_constraint(c2);

    {
        auto constraints = t.get_constraints();
        EXPECT_EQ(2, constraints.size());
        EXPECT_EQ("constraint 1", constraints[0].name);
        EXPECT_EQ("constraint 2", constraints[1].name);
    }

    t.drop_constraint("constraint 2");
    {
        auto constraints = t.get_constraints();
        EXPECT_EQ(1, constraints.size());
        EXPECT_EQ("constraint 1", constraints[0].name);
    }
}