diff options
-rw-r--r-- | Foundation/GTMSQLiteTest.m | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Foundation/GTMSQLiteTest.m b/Foundation/GTMSQLiteTest.m index 5d683c0..50e893e 100644 --- a/Foundation/GTMSQLiteTest.m +++ b/Foundation/GTMSQLiteTest.m @@ -1758,15 +1758,18 @@ static NSArray* LikeGlobTestHelper(GTMSQLiteDatabase *db, NSString *sql) { STAssertNotNil(db, @"Failed to create database"); + sqlite3 *sqlite3DB = [db sqlite3DB]; + NSString *selectSQL = @"select 1"; GTMSQLiteStatement *statement; statement = [GTMSQLiteStatement statementWithSQL:selectSQL inDatabase:db errorCode:&err]; - STAssertNotNil(statement, @"Failed to create select statement"); STAssertEquals(err, SQLITE_OK, @"Failed to create select statement"); + sqlite3_stmt *sqlite3Statment = [statement sqlite3Statement]; + err = [statement stepRow]; STAssertEquals(err, SQLITE_ROW, @"failed to step row for finalize test"); @@ -1778,6 +1781,13 @@ static NSArray* LikeGlobTestHelper(GTMSQLiteDatabase *db, NSString *sql) { [GTMUnitTestDevLog expectString:expectedLog]; [GTMUnitTestDevLog expectPattern:@"Unable to close .*"]; [localPool drain]; + + // Clean up leaks. Since we hadn't finalized the statement above we + // were unable to clean up the sqlite databases. Since the pool is drained + // all of our objective-c objects are gone, so we have to call the + // sqlite3 api directly. + STAssertEquals(sqlite3_finalize(sqlite3Statment), SQLITE_OK, nil); + STAssertEquals(sqlite3_close(sqlite3DB), SQLITE_OK, nil); } } |