Sqlite3-ruby 1.3.1, itextomml 1.3.26
Update vendored sqlite3-ruby and tests for latest itextmml.
This commit is contained in:
parent
29224d6bcc
commit
b3aae9b06d
16 changed files with 257 additions and 9 deletions
82
vendor/plugins/sqlite3-ruby/test/test_collation.rb
vendored
Normal file
82
vendor/plugins/sqlite3-ruby/test/test_collation.rb
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
require 'helper'
|
||||
|
||||
module SQLite3
|
||||
class TestCollation < Test::Unit::TestCase
|
||||
class Comparator
|
||||
attr_reader :calls
|
||||
def initialize
|
||||
@calls = []
|
||||
end
|
||||
|
||||
def compare left, right
|
||||
@calls << [left, right]
|
||||
left <=> right
|
||||
end
|
||||
end
|
||||
|
||||
def setup
|
||||
@db = SQLite3::Database.new(':memory:')
|
||||
@create = "create table ex(id int, data string)"
|
||||
@db.execute(@create);
|
||||
[ [1, 'hello'], [2, 'world'] ].each do |vals|
|
||||
@db.execute('insert into ex (id, data) VALUES (?, ?)', vals)
|
||||
end
|
||||
end
|
||||
|
||||
def test_custom_collation
|
||||
comparator = Comparator.new
|
||||
|
||||
@db.collation 'foo', comparator
|
||||
|
||||
assert_equal comparator, @db.collations['foo']
|
||||
@db.execute('select data from ex order by 1 collate foo')
|
||||
assert_equal 1, comparator.calls.length
|
||||
end
|
||||
|
||||
def test_remove_collation
|
||||
comparator = Comparator.new
|
||||
|
||||
@db.collation 'foo', comparator
|
||||
@db.collation 'foo', nil
|
||||
|
||||
assert_nil @db.collations['foo']
|
||||
assert_raises(SQLite3::SQLException) do
|
||||
@db.execute('select data from ex order by 1 collate foo')
|
||||
end
|
||||
end
|
||||
|
||||
if RUBY_VERSION >= '1.9.1'
|
||||
def test_encoding
|
||||
comparator = Comparator.new
|
||||
@db.collation 'foo', comparator
|
||||
@db.execute('select data from ex order by 1 collate foo')
|
||||
|
||||
a, b = *comparator.calls.first
|
||||
|
||||
assert_equal Encoding.find('UTF-8'), a.encoding
|
||||
assert_equal Encoding.find('UTF-8'), b.encoding
|
||||
end
|
||||
|
||||
def test_encoding_default_internal
|
||||
warn_before = $-w
|
||||
$-w = false
|
||||
before_enc = Encoding.default_internal
|
||||
|
||||
Encoding.default_internal = 'EUC-JP'
|
||||
comparator = Comparator.new
|
||||
@db.collation 'foo', comparator
|
||||
@db.execute('select data from ex order by 1 collate foo')
|
||||
|
||||
a, b = *comparator.calls.first
|
||||
|
||||
assert_equal Encoding.find('EUC-JP'), a.encoding
|
||||
assert_equal Encoding.find('EUC-JP'), b.encoding
|
||||
ensure
|
||||
Encoding.default_internal = before_enc
|
||||
$-w = warn_before
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,6 +7,10 @@ module SQLite3
|
|||
@db = SQLite3::Database.new(':memory:')
|
||||
end
|
||||
|
||||
def test_encoding
|
||||
assert @db.encoding, 'database has encoding'
|
||||
end
|
||||
|
||||
def test_changes
|
||||
@db.execute("CREATE TABLE items (id integer PRIMARY KEY AUTOINCREMENT, number integer)")
|
||||
assert_equal 0, @db.changes
|
||||
|
|
|
@ -3,9 +3,17 @@ require 'helper'
|
|||
module SQLite3
|
||||
class TestDeprecated < Test::Unit::TestCase
|
||||
def setup
|
||||
super
|
||||
@warn_before = $-w
|
||||
$-w = false
|
||||
@db = SQLite3::Database.new(':memory:')
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
$-w = @warn_before
|
||||
end
|
||||
|
||||
def test_query_with_many_bind_params
|
||||
assert_equal [[nil, 1]], @db.query("select ?, ?", nil, 1).to_a
|
||||
end
|
||||
|
|
|
@ -12,6 +12,9 @@ module SQLite3
|
|||
end
|
||||
|
||||
def test_default_internal_is_honored
|
||||
warn_before = $-w
|
||||
$-w = false
|
||||
|
||||
before_enc = Encoding.default_internal
|
||||
|
||||
str = "壁に耳あり、障子に目あり"
|
||||
|
@ -27,6 +30,7 @@ module SQLite3
|
|||
assert_equal str, string.encode(str.encoding)
|
||||
ensure
|
||||
Encoding.default_internal = before_enc
|
||||
$-w = warn_before
|
||||
end
|
||||
|
||||
def test_blob_is_binary
|
||||
|
@ -97,7 +101,7 @@ module SQLite3
|
|||
|
||||
def test_utf_8
|
||||
str = "猫舌"
|
||||
@db.execute(@insert, 10, str)
|
||||
@db.execute(@insert, [10, str])
|
||||
row = @db.execute("select data from ex")
|
||||
assert_equal @db.encoding, row.first.first.encoding
|
||||
assert_equal str, row.first.first
|
||||
|
@ -105,7 +109,7 @@ module SQLite3
|
|||
|
||||
def test_euc_jp
|
||||
str = "猫舌".encode('EUC-JP')
|
||||
@db.execute(@insert, 10, str)
|
||||
@db.execute(@insert, [10, str])
|
||||
row = @db.execute("select data from ex")
|
||||
assert_equal @db.encoding, row.first.first.encoding
|
||||
assert_equal str.encode('UTF-8'), row.first.first
|
||||
|
|
|
@ -261,7 +261,7 @@ class TC_Database_Integration < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_execute_batch_with_bind
|
||||
@db.execute_batch( <<-SQL, 1 )
|
||||
@db.execute_batch( <<-SQL, [1] )
|
||||
create table bar ( a, b, c );
|
||||
insert into bar values ( 'one', 2, ? );
|
||||
insert into bar values ( 'four', 5, ? );
|
||||
|
|
|
@ -20,6 +20,8 @@ class TC_Integration_Pending < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_busy_handler_outwait
|
||||
skip("not working in 1.9") if RUBY_VERSION >= '1.9'
|
||||
|
||||
busy = Mutex.new
|
||||
busy.lock
|
||||
handler_call_count = 0
|
||||
|
|
35
vendor/plugins/sqlite3-ruby/test/test_statement_execute.rb
vendored
Normal file
35
vendor/plugins/sqlite3-ruby/test/test_statement_execute.rb
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue