| Index: sql/connection_unittest.cc
|
| diff --git a/sql/connection_unittest.cc b/sql/connection_unittest.cc
|
| index e99bff7fb663c31b108076b6ba4acd259ceb8cc8..9718ce0042ff16c658ace47c2fd11832287ff36f 100644
|
| --- a/sql/connection_unittest.cc
|
| +++ b/sql/connection_unittest.cc
|
| @@ -35,10 +35,21 @@ TEST_F(SQLConnectionTest, Execute) {
|
| EXPECT_EQ(SQLITE_OK, db().GetErrorCode());
|
|
|
| // Invalid statement should fail.
|
| - ASSERT_FALSE(db().Execute("CREATE TAB foo (a, b"));
|
| + ASSERT_EQ(SQLITE_ERROR,
|
| + db().ExecuteAndReturnErrorCode("CREATE TAB foo (a, b"));
|
| EXPECT_EQ(SQLITE_ERROR, db().GetErrorCode());
|
| }
|
|
|
| +TEST_F(SQLConnectionTest, ExecuteWithErrorCode) {
|
| + ASSERT_EQ(SQLITE_OK,
|
| + db().ExecuteAndReturnErrorCode("CREATE TABLE foo (a, b)"));
|
| + ASSERT_EQ(SQLITE_ERROR,
|
| + db().ExecuteAndReturnErrorCode("CREATE TABLE TABLE"));
|
| + ASSERT_EQ(SQLITE_ERROR,
|
| + db().ExecuteAndReturnErrorCode(
|
| + "INSERT INTO foo(a, b) VALUES (1, 2, 3, 4)"));
|
| +}
|
| +
|
| TEST_F(SQLConnectionTest, CachedStatement) {
|
| sql::StatementID id1("foo", 12);
|
|
|
| @@ -48,7 +59,7 @@ TEST_F(SQLConnectionTest, CachedStatement) {
|
| // Create a new cached statement.
|
| {
|
| sql::Statement s(db().GetCachedStatement(id1, "SELECT a FROM foo"));
|
| - ASSERT_FALSE(!s); // Test ! operator for validity.
|
| + ASSERT_TRUE(s.is_valid());
|
|
|
| ASSERT_TRUE(s.Step());
|
| EXPECT_EQ(12, s.ColumnInt(0));
|
| @@ -61,7 +72,7 @@ TEST_F(SQLConnectionTest, CachedStatement) {
|
| // Get the same statement using different SQL. This should ignore our
|
| // SQL and use the cached one (so it will be valid).
|
| sql::Statement s(db().GetCachedStatement(id1, "something invalid("));
|
| - ASSERT_FALSE(!s); // Test ! operator for validity.
|
| + ASSERT_TRUE(s.is_valid());
|
|
|
| ASSERT_TRUE(s.Step());
|
| EXPECT_EQ(12, s.ColumnInt(0));
|
| @@ -71,6 +82,12 @@ TEST_F(SQLConnectionTest, CachedStatement) {
|
| EXPECT_FALSE(db().HasCachedStatement(SQL_FROM_HERE));
|
| }
|
|
|
| +TEST_F(SQLConnectionTest, IsSQLValidTest) {
|
| + ASSERT_TRUE(db().Execute("CREATE TABLE foo (a, b)"));
|
| + ASSERT_TRUE(db().IsSQLValid("SELECT a FROM foo"));
|
| + ASSERT_FALSE(db().IsSQLValid("SELECT no_exist FROM foo"));
|
| +}
|
| +
|
| TEST_F(SQLConnectionTest, DoesStuffExist) {
|
| // Test DoesTableExist.
|
| EXPECT_FALSE(db().DoesTableExist("foo"));
|
| @@ -103,4 +120,3 @@ TEST_F(SQLConnectionTest, GetLastInsertRowId) {
|
| ASSERT_TRUE(s.Step());
|
| EXPECT_EQ(12, s.ColumnInt(0));
|
| }
|
| -
|
|
|