extralite 2.6 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,9 +2,9 @@
2
2
 
3
3
  require_relative 'helper'
4
4
 
5
- class ExtraliteTest < MiniTest::Test
5
+ class ExtraliteTest < Minitest::Test
6
6
  def test_sqlite3_version
7
- assert_match /^3\.\d+\.\d+$/, Extralite.sqlite3_version
7
+ assert_match(/^3\.\d+\.\d+$/, Extralite.sqlite3_version)
8
8
  end
9
9
 
10
10
  def test_status
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative 'helper'
4
4
 
5
- class IteratorTest < MiniTest::Test
5
+ class IteratorTest < Minitest::Test
6
6
  def setup
7
7
  @db = Extralite::Database.new(':memory:')
8
8
  @db.query('create table if not exists t (x,y,z)')
@@ -30,8 +30,20 @@ class IteratorTest < MiniTest::Test
30
30
  assert_equal [{x: 1, y: 2, z: 3},{ x: 4, y: 5, z: 6 }, { x: 7, y: 8, z: 9 }], buf
31
31
  end
32
32
 
33
+ def test_iterator_argv
34
+ @query.mode = :argv
35
+ iter = @query.each
36
+ assert_kind_of Extralite::Iterator, iter
37
+
38
+ buf = []
39
+ v = iter.each { |a, b, c| buf << [a, b, c] }
40
+ assert_equal iter, v
41
+ assert_equal [[1, 2, 3], [4, 5, 6], [7, 8, 9]], buf
42
+ end
43
+
33
44
  def test_iterator_ary
34
- iter = @query.each_ary
45
+ @query.mode = :ary
46
+ iter = @query.each
35
47
  assert_kind_of Extralite::Iterator, iter
36
48
 
37
49
  buf = []
@@ -41,8 +53,8 @@ class IteratorTest < MiniTest::Test
41
53
  end
42
54
 
43
55
  def test_iterator_single_column
44
- query = @db.prepare('select x from t')
45
- iter = query.each_single_column
56
+ query = @db.prepare_argv('select x from t')
57
+ iter = query.each
46
58
  assert_kind_of Extralite::Iterator, iter
47
59
 
48
60
  buf = []
@@ -59,14 +71,15 @@ class IteratorTest < MiniTest::Test
59
71
  assert_nil iter.next
60
72
  assert_nil iter.next
61
73
 
62
- iter = @query.reset.each_ary
74
+ @query.mode = :ary
75
+ @query.reset
63
76
  assert_equal([1, 2, 3], iter.next)
64
77
  assert_equal([4, 5, 6], iter.next)
65
78
  assert_equal([7, 8, 9], iter.next)
66
79
  assert_nil iter.next
67
80
  assert_nil iter.next
68
81
 
69
- iter = @db.prepare('select y from t').each_single_column
82
+ iter = @db.prepare_argv('select y from t').each
70
83
  assert_equal(2, iter.next)
71
84
  assert_equal(5, iter.next)
72
85
  assert_equal(8, iter.next)
@@ -78,10 +91,10 @@ class IteratorTest < MiniTest::Test
78
91
  iter = @query.each
79
92
  assert_equal [{x: 1, y: 2, z: 3},{ x: 4, y: 5, z: 6 }, { x: 7, y: 8, z: 9 }], iter.to_a
80
93
 
81
- iter = @query.each_ary
94
+ @query.mode = :ary
82
95
  assert_equal [[1, 2, 3], [4, 5, 6], [7, 8, 9]], iter.to_a
83
96
 
84
- iter = @db.prepare('select x from t').each_single_column
97
+ iter = @db.prepare_argv('select x from t').each
85
98
  assert_equal [1, 4, 7], iter.to_a
86
99
  end
87
100
 
@@ -89,17 +102,19 @@ class IteratorTest < MiniTest::Test
89
102
  mapped = @query.each.map { |row| row[:x] * 10 }
90
103
  assert_equal [10, 40, 70], mapped
91
104
 
92
- mapped = @query.each_ary.map { |row| row[1] * 10 }
105
+ @query.mode = :ary
106
+ mapped = @query.each.map { |row| row[1] * 10 }
93
107
  assert_equal [20, 50, 80], mapped
94
108
 
95
- query = @db.prepare('select z from t')
96
- mapped = query.each_single_column.map { |v| v * 10 }
109
+ query = @db.prepare_argv('select z from t')
110
+ mapped = query.each.map { |v| v * 10 }
97
111
  assert_equal [30, 60, 90], mapped
98
112
  end
99
113
 
100
114
  def test_iterator_inspect
101
- i = @query.each_ary
102
- assert_match /^\#\<Extralite::Iterator:0x[0-9a-f]+ ary\>$/, i.inspect
115
+ @query.mode = :ary
116
+ i = @query.each
117
+ assert_match(/^\#\<Extralite::Iterator:0x[0-9a-f]+\>$/, i.inspect)
103
118
  end
104
119
 
105
120
  def test_return_from_block_issue_26