From 8352c13af31be429bd5fd5c36d169fe0ff4c354e Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Mon, 1 Feb 2010 23:33:54 +0000 Subject: [Author: dmaclach] Fix up a sqllite test leak R=thomasvl DELTA=4 (3 added, 0 deleted, 1 changed) --- Foundation/GTMSQLiteTest.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Foundation/GTMSQLiteTest.m') 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); } } -- cgit v1.2.3