mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Added unit tests for new function on statements.
This commit is contained in:
parent
98aff92081
commit
9dee407ff0
@ -918,6 +918,29 @@ TEST(Statement, getName)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Statement, getDeclaredType)
|
||||||
|
{
|
||||||
|
// Create a new database
|
||||||
|
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
|
||||||
|
EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT, value DOUBLE)"));
|
||||||
|
|
||||||
|
SQLite::Statement query(db, "SELECT * FROM test");
|
||||||
|
|
||||||
|
const std::string decltype0 = query.getDeclaredType(0);
|
||||||
|
const std::string decltype1 = query.getDeclaredType(1);
|
||||||
|
const std::string decltype2 = query.getDeclaredType(2);
|
||||||
|
EXPECT_EQ("INTEGER", decltype0);
|
||||||
|
EXPECT_EQ("TEXT", decltype1);
|
||||||
|
EXPECT_EQ("DOUBLE", decltype2);
|
||||||
|
|
||||||
|
// Index out of bounds.
|
||||||
|
EXPECT_THROW(query.getDeclaredType(3), SQLite::Exception);
|
||||||
|
|
||||||
|
// Not a SELECT statement.
|
||||||
|
SQLite::Statement insert(db, "INSERT INTO test VALUES (1, 'Hello', 3.1415)");
|
||||||
|
EXPECT_THROW(insert.getDeclaredType(0), SQLite::Exception);
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1900)
|
#if __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1900)
|
||||||
TEST(Statement, getColumns)
|
TEST(Statement, getColumns)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user