@@ -67,7 +67,7 @@ def test_working
67
67
68
68
#execute an sql statement
69
69
nb_row = @db . execute ( "select x, sum(y), avg(y), avg(y*y), min(y), max(y), count(y) from TestVTable group by x" ) . each . count
70
- assert ( nb_row > 0 )
70
+ assert_operator nb_row , :> , 0
71
71
end
72
72
73
73
def test_vtable
@@ -77,58 +77,58 @@ def test_vtable
77
77
[ 3 , 6 , 9 ]
78
78
] )
79
79
nb_row = @db . execute ( 'select count(*) from TestVTable2' ) . each . first [ 0 ]
80
- assert ( nb_row == 3 )
80
+ assert_equal ( 3 , nb_row )
81
81
sum_a , sum_b , sum_c = *@db . execute ( 'select sum(a), sum(b), sum(c) from TestVTable2' ) . each . first
82
- assert ( sum_a = 6 )
83
- assert ( sum_b == 12 )
84
- assert ( sum_c == 18 )
82
+ assert_equal ( 6 , sum_a )
83
+ assert_equal ( 12 , sum_b )
84
+ assert_equal ( 18 , sum_c )
85
85
end
86
86
87
87
def test_multiple_vtable
88
88
SQLite3 . vtable ( @db , 'TestVTable3' , 'col1' , [ [ 'a' ] , [ 'b' ] ] )
89
89
SQLite3 . vtable ( @db , 'TestVTable4' , 'col2' , [ [ 'c' ] , [ 'd' ] ] )
90
90
rows = @db . execute ( 'select col1, col2 from TestVTable3, TestVTable4' ) . each . to_a
91
- assert ( rows . include? ( [ 'a' , 'c' ] ) )
92
- assert ( rows . include? ( [ 'a' , 'd' ] ) )
93
- assert ( rows . include? ( [ 'b' , 'c' ] ) )
94
- assert ( rows . include? ( [ 'b' , 'd' ] ) )
91
+ assert_includes rows , [ 'a' , 'c' ]
92
+ assert_includes rows , [ 'a' , 'd' ]
93
+ assert_includes rows , [ 'b' , 'c' ]
94
+ assert_includes rows , [ 'b' , 'd' ]
95
95
end
96
96
97
97
def test_best_filter
98
98
test = self
99
99
SQLite3 . vtable ( @db , 'TestVTable5' , 'col1, col2' , [ [ 'a' , 1 ] , [ 'b' , 2 ] ] ) . tap do |vtable |
100
100
vtable . send ( :define_method , :best_index ) do |constraint , order_by |
101
101
# check constraint
102
- test . assert ( constraint . include? ( [ 0 , :<= ] ) ) # col1 <= 'c'
103
- test . assert ( constraint . include? ( [ 0 , :> ] ) ) # col1 > 'a'
104
- test . assert ( constraint . include? ( [ 1 , :< ] ) ) # col2 < 3
102
+ test . assert_includes constraint , [ 0 , :<= ] # col1 <= 'c'
103
+ test . assert_includes constraint , [ 0 , :> ] # col1 > 'a'
104
+ test . assert_includes constraint , [ 1 , :< ] # col2 < 3
105
105
@constraint = constraint
106
106
107
107
# check order by
108
- test . assert ( order_by == [
108
+ test . assert_equal ( [
109
109
[ 1 , 1 ] , # col2
110
110
[ 0 , -1 ] , # col1 desc
111
- ] )
111
+ ] , order_by )
112
112
113
113
{ idxNum : 45 }
114
114
end
115
115
vtable . send ( :alias_method , :orig_filter , :filter )
116
116
vtable . send ( :define_method , :filter ) do |idxNum , args |
117
117
# idxNum should be the one returned by best_index
118
- test . assert ( idxNum == 45 )
118
+ test . assert_equal ( 45 , idxNum )
119
119
120
120
# args should be consistent with the constraint given to best_index
121
- test . assert ( args . size == @constraint . size )
121
+ test . assert_equal ( @constraint . size , args . size )
122
122
filters = @constraint . zip ( args )
123
- test . assert ( filters . include? ( [ [ 0 , :<= ] , 'c' ] ) ) # col1 <= 'c'
124
- test . assert ( filters . include? ( [ [ 0 , :> ] , 'a' ] ) ) # col1 > 'a'
125
- test . assert ( filters . include? ( [ [ 1 , :< ] , 3 ] ) ) # col2 < 3
123
+ test . assert_includes filters , [ [ 0 , :<= ] , 'c' ] # col1 <= 'c'
124
+ test . assert_includes filters , [ [ 0 , :> ] , 'a' ] # col1 > 'a'
125
+ test . assert_includes filters , [ [ 1 , :< ] , 3 ] # col2 < 3
126
126
127
127
orig_filter ( idxNum , args )
128
128
end
129
129
end
130
130
rows = @db . execute ( 'select col1 from TestVTable5 where col1 <= \'c\' and col1 > \'a\' and col2 < 3 order by col2, col1 desc' ) . each . to_a
131
- assert ( rows == [ [ 'b' ] ] )
131
+ assert_equal ( [ [ 'b' ] ] , rows )
132
132
end
133
133
134
134
end if defined? ( SQLite3 ::Module )
0 commit comments