Class: SQLite3::TestResultSet
- Defined in:
- lib/sqlite3-1.5.3-arm64-darwin/test/test_result_set.rb,
lib/sqlite3-1.5.3-x86_64-darwin/test/test_result_set.rb
Instance Method Summary collapse
Methods inherited from TestCase
Instance Method Details
#test_each_hash ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_result_set.rb', line 5 def test_each_hash db = SQLite3::Database.new ':memory:' db.execute "create table foo ( a integer primary key, b text )" list = ('a'..'z').to_a list.each do |t| db.execute "insert into foo (b) values (\"#{t}\")" end rs = db.prepare('select * from foo').execute rs.each_hash do |hash| assert_equal list[hash['a'] - 1], hash['b'] end end |
#test_next_hash ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_result_set.rb', line 19 def test_next_hash db = SQLite3::Database.new ':memory:' db.execute "create table foo ( a integer primary key, b text )" list = ('a'..'z').to_a list.each do |t| db.execute "insert into foo (b) values (\"#{t}\")" end rs = db.prepare('select * from foo').execute rows = [] while row = rs.next_hash rows << row end rows.each do |hash| assert_equal list[hash['a'] - 1], hash['b'] end end |