instiki/vendor/plugins/sqlite3-ruby/test/test_statement_execute.rb
Jacques Distler b3aae9b06d Sqlite3-ruby 1.3.1, itextomml 1.3.26
Update vendored sqlite3-ruby and tests
for latest itextmml.
2010-07-20 20:36:17 -05:00

36 lines
1 KiB
Ruby

require 'helper'
module SQLite3
class TestStatementExecute < Test::Unit::TestCase
def setup
@db = SQLite3::Database.new(':memory:')
@db.execute_batch(
"CREATE TABLE items (id integer PRIMARY KEY, number integer)")
end
def test_execute_insert
ps = @db.prepare("INSERT INTO items (number) VALUES (:n)")
ps.execute('n'=>10)
assert_equal 1, @db.get_first_value("SELECT count(*) FROM items")
ps.close
end
def test_execute_update
@db.execute("INSERT INTO items (number) VALUES (?)", [10])
ps = @db.prepare("UPDATE items SET number = :new WHERE number = :old")
ps.execute('old'=>10, 'new'=>20)
assert_equal 20, @db.get_first_value("SELECT number FROM items")
ps.close
end
def test_execute_delete
@db.execute("INSERT INTO items (number) VALUES (?)", [20])
ps = @db.prepare("DELETE FROM items WHERE number = :n")
ps.execute('n' => 20)
assert_equal 0, @db.get_first_value("SELECT count(*) FROM items")
ps.close
end
end
end