test_deprecated.rb 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. require 'helper'
  2. module SQLite3
  3. class TestDeprecated < SQLite3::TestCase
  4. attr_reader :db
  5. def setup
  6. super
  7. @warn_before = $-w
  8. $-w = false
  9. @db = SQLite3::Database.new(':memory:')
  10. @db.execute 'CREATE TABLE test_table (name text, age int)'
  11. end
  12. def teardown
  13. super
  14. $-w = @warn_before
  15. end
  16. def test_query_with_many_bind_params_not_nil
  17. assert_equal [[1, 2]], db.query('select ?, ?', 1, 2).to_a
  18. end
  19. def test_execute_with_many_bind_params_not_nil
  20. assert_equal [[1, 2]], @db.execute("select ?, ?", 1, 2).to_a
  21. end
  22. def test_query_with_many_bind_params
  23. assert_equal [[nil, 1]], @db.query("select ?, ?", nil, 1).to_a
  24. end
  25. def test_query_with_nil_bind_params
  26. assert_equal [['foo']], @db.query("select 'foo'", nil).to_a
  27. end
  28. def test_execute_with_many_bind_params
  29. assert_equal [[nil, 1]], @db.execute("select ?, ?", nil, 1)
  30. end
  31. def test_execute_with_nil_bind_params
  32. assert_equal [['foo']], @db.execute("select 'foo'", nil)
  33. end
  34. end
  35. end