Skip to content

Commit

Permalink
test: add coverage for statement resource cleanup
Browse files Browse the repository at this point in the history
Note that the unclosed statement object test fails at the moment.
  • Loading branch information
flavorjones committed Aug 7, 2023
1 parent 281dab5 commit 9574673
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/test_resource_cleanup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "helper"

module SQLite3
# these tests will cause ruby_memcheck to report a leak if we're not cleaning up resources
class TestResourceCleanup < SQLite3::TestCase
def test_cleanup_unclosed_database_object
100.times do
SQLite3::Database.new(':memory:')
end
end

def test_cleanup_unclosed_statement_object
100.times do
db = SQLite3::Database.new(':memory:')
db.execute('create table foo(text BLOB)')
db.prepare('select * from foo')
end
end

# def test_cleanup_unclosed_resultset_object
# db = SQLite3::Database.new(':memory:')
# db.execute('create table foo(text BLOB)')
# stmt = db.prepare('select * from foo')
# stmt.execute
# end
end
end

0 comments on commit 9574673

Please sign in to comment.