File: test_deprecated.rb

package info (click to toggle)
ruby-sqlite3 1.7.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,772 kB
  • sloc: ruby: 3,839; ansic: 1,470; makefile: 7
file content (49 lines) | stat: -rw-r--r-- 1,156 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require 'helper'

module SQLite3
  class TestDeprecated < SQLite3::TestCase
    def setup
      super
      @warn_before = $-w
      $-w = false
      @db = SQLite3::Database.new(':memory:')
      @db.execute 'CREATE TABLE test_table (name text, age int)'
    end

    def teardown
      super
      $-w = @warn_before
      @db.close
    end

    def test_query_with_many_bind_params_not_nil
      rs = @db.query('select ?, ?', 1, 2)
      assert_equal [[1, 2]], rs.to_a
      rs.close
    end

    def test_execute_with_many_bind_params_not_nil
      assert_equal [[1, 2]], @db.execute("select ?, ?", 1, 2).to_a
    end

    def test_query_with_many_bind_params
      rs = @db.query("select ?, ?", nil, 1)
      assert_equal [[nil, 1]], rs.to_a
      rs.close
    end

    def test_query_with_nil_bind_params
      rs = @db.query("select 'foo'", nil)
      assert_equal [['foo']], rs.to_a
      rs.close
    end

    def test_execute_with_many_bind_params
      assert_equal [[nil, 1]], @db.execute("select ?, ?", nil, 1)
    end

    def test_execute_with_nil_bind_params
      assert_equal [['foo']], @db.execute("select 'foo'", nil)
    end
  end
end