@@ -918,27 +918,30 @@ TEST(Statement, getName)
918918#endif
919919}
920920
921- TEST (Statement, getDeclaredType )
921+ TEST (Statement, getColumnDeclaredType )
922922{
923923 // Create a new database
924924 SQLite::Database db (" :memory:" , SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
925925 EXPECT_EQ (0 , db.exec (" CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT, value DOUBLE)" ));
926-
927- SQLite::Statement query (db, " SELECT * FROM test" );
928-
929- const std::string decltype0 = query.getDeclaredType (0 );
930- const std::string decltype1 = query.getDeclaredType (1 );
931- const std::string decltype2 = query.getDeclaredType (2 );
926+
927+ SQLite::Statement query (db, " SELECT *, 1 FROM test" );
928+
929+ const std::string decltype0 = query.getColumnDeclaredType (0 );
930+ const std::string decltype1 = query.getColumnDeclaredType (1 );
931+ const std::string decltype2 = query.getColumnDeclaredType (2 );
932932 EXPECT_EQ (" INTEGER" , decltype0);
933933 EXPECT_EQ (" TEXT" , decltype1);
934934 EXPECT_EQ (" DOUBLE" , decltype2);
935935
936+ // The column at index 3 is not a table column.
937+ EXPECT_THROW (query.getColumnDeclaredType (3 ), SQLite::Exception);
938+
936939 // Index out of bounds.
937- EXPECT_THROW (query.getDeclaredType ( 3 ), SQLite::Exception);
940+ EXPECT_THROW (query.getColumnDeclaredType ( 4 ), SQLite::Exception);
938941
939- // Not a SELECT statement.
940- SQLite::Statement insert (db, " INSERT INTO test VALUES (1, 'Hello', 3.1415) " );
941- EXPECT_THROW (insert. getDeclaredType (0 ), SQLite::Exception);
942+ // Not a select statement.
943+ SQLite::Statement pragma (db," PRAGMA compile_options " );
944+ EXPECT_THROW (pragma. getColumnDeclaredType (0 ), SQLite::Exception);
942945}
943946
944947#if __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1900)
0 commit comments