Created
November 20, 2009 05:22
-
-
Save hjiang/239305 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEST(DatabaseTest, BasicTest) { | |
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); | |
db.setDatabaseName(":memory:"); | |
ASSERT_TRUE(db.open()); | |
QSqlQuery query; | |
EXPECT_TRUE(query.exec("CREATE TABLE IF NOT EXISTS testtable " | |
"(title, url);")); | |
EXPECT_TRUE(query.prepare("INSERT INTO testtable (title, url) " | |
"VALUES (:title, :url);")); | |
query.bindValue(":title", "some title"); | |
query.bindValue(":url", "some url"); | |
EXPECT_TRUE(query.exec()); | |
qDebug() << query.executedQuery(); | |
// Outputs: "INSERT INTO testtable (title, url) VALUES (?, ?);" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment