Skip to content

Commit

Permalink
grammar: add tests for like operator and between
Browse files Browse the repository at this point in the history
  • Loading branch information
rp- committed Jun 25, 2014
1 parent dd85b16 commit e1ea78f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/tests/testsqlobjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,24 @@ void TestTable::createTableWithIn()

void TestTable::createTableWithNotLikeConstraint()
{
QString sSQL = "CREATE TABLE hopefully_working("
"value TEXT CONSTRAINT 'value' CHECK(value NOT LIKE 'prefix%')"
QString sSQL = "CREATE TABLE hopefully_working(\n"
"value TEXT CONSTRAINT 'value' CHECK(value NOT LIKE 'prefix%'),\n"
"value2 TEXT CONSTRAINT 'value' CHECK(value2 NOT MATCH 'prefix%'),\n"
"value3 TEXT CONSTRAINT 'value' CHECK(value3 NOT REGEXP 'prefix%'),\n"
"value4 TEXT CONSTRAINT 'value' CHECK(value4 NOT GLOB 'prefix%'),\n"
"value5 INTEGER CONSTRAINT 'value' CHECK(value5 BETWEEN 1+4 AND 100 OR 200),\n"
"value6 INTEGER CONSTRAINT 'value' CHECK(value6 NOT BETWEEN 1 AND 100)\n"
");";

Table tab = Table::parseSQL(sSQL);
QVERIFY(tab.name() == "hopefully_working");

QVERIFY(tab.fields().at(0)->check() == "value NOT LIKE 'prefix%'");
QVERIFY(tab.fields().at(1)->check() == "value2 NOT MATCH 'prefix%'");
QVERIFY(tab.fields().at(2)->check() == "value3 NOT REGEXP 'prefix%'");
QVERIFY(tab.fields().at(3)->check() == "value4 NOT GLOB 'prefix%'");
QVERIFY(tab.fields().at(4)->check() == "value5 BETWEEN 1 + 4 AND 100 OR 200");
QVERIFY(tab.fields().at(5)->check() == "value6 NOT BETWEEN 1 AND 100");
}

QTEST_MAIN(TestTable)
Expand Down

0 comments on commit e1ea78f

Please sign in to comment.