ruby-opencv 0.0.8-x86-mingw32 → 0.0.9.pre2-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/DEVELOPERS_NOTE.md +29 -12
  3. data/Gemfile +1 -2
  4. data/License.txt +30 -30
  5. data/Manifest.txt +5 -4
  6. data/README.md +1 -1
  7. data/Rakefile +62 -4
  8. data/config.yml +7 -0
  9. data/examples/alpha_blend.rb +21 -21
  10. data/examples/find_obj.rb +169 -169
  11. data/examples/match_kdtree.rb +88 -88
  12. data/ext/opencv/cvcapture.cpp +19 -12
  13. data/ext/opencv/cvutils.cpp +192 -194
  14. data/ext/opencv/cvutils.h +30 -29
  15. data/{extconf.rb → ext/opencv/extconf.rb} +12 -4
  16. data/lib/opencv.rb +12 -3
  17. data/lib/opencv/psyched_yaml.rb +22 -22
  18. data/lib/opencv/version.rb +1 -1
  19. data/ruby-opencv.gemspec +17 -16
  20. data/test/helper.rb +1 -1
  21. data/test/runner.rb +30 -30
  22. data/test/test_curve.rb +1 -1
  23. data/test/test_cvavgcomp.rb +24 -24
  24. data/test/test_cvbox2d.rb +76 -76
  25. data/test/test_cvcapture.rb +183 -183
  26. data/test/test_cvchain.rb +108 -108
  27. data/test/test_cvcircle32f.rb +41 -41
  28. data/test/test_cvconnectedcomp.rb +61 -61
  29. data/test/test_cvcontour.rb +150 -150
  30. data/test/test_cvcontourtree.rb +43 -43
  31. data/test/test_cverror.rb +1 -1
  32. data/test/test_cvfeaturetree.rb +65 -65
  33. data/test/test_cvfont.rb +58 -58
  34. data/test/test_cvhaarclassifiercascade.rb +63 -63
  35. data/test/test_cvhistogram.rb +1 -1
  36. data/test/test_cvhumoments.rb +83 -83
  37. data/test/test_cvline.rb +50 -50
  38. data/test/test_cvmat.rb +1 -1
  39. data/test/test_cvmat_drawing.rb +1 -1
  40. data/test/test_cvmat_dxt.rb +1 -1
  41. data/test/test_cvmat_imageprocessing.rb +1 -1
  42. data/test/test_cvmat_matching.rb +1 -1
  43. data/test/test_cvmoments.rb +180 -180
  44. data/test/test_cvpoint.rb +75 -75
  45. data/test/test_cvpoint2d32f.rb +75 -75
  46. data/test/test_cvpoint3d32f.rb +93 -93
  47. data/test/test_cvrect.rb +144 -144
  48. data/test/test_cvscalar.rb +113 -113
  49. data/test/test_cvseq.rb +295 -295
  50. data/test/test_cvsize.rb +75 -75
  51. data/test/test_cvsize2d32f.rb +75 -75
  52. data/test/test_cvslice.rb +31 -31
  53. data/test/test_cvsurfparams.rb +57 -57
  54. data/test/test_cvsurfpoint.rb +66 -66
  55. data/test/test_cvtermcriteria.rb +56 -56
  56. data/test/test_cvtwopoints.rb +40 -40
  57. data/test/test_cvvideowriter.rb +58 -58
  58. data/test/test_iplconvkernel.rb +54 -54
  59. data/test/test_iplimage.rb +1 -1
  60. data/test/test_mouseevent.rb +17 -17
  61. data/test/test_opencv.rb +1 -1
  62. data/test/test_pointset.rb +1 -1
  63. data/test/test_preliminary.rb +130 -130
  64. data/test/test_trackbar.rb +47 -47
  65. data/test/test_window.rb +115 -115
  66. metadata +26 -54
  67. data/ext/opencv/lib/opencv.rb +0 -3
  68. data/ext/opencv/lib/opencv/psyched_yaml.rb +0 -22
  69. data/ext/opencv/lib/opencv/version.rb +0 -3
@@ -1,295 +1,295 @@
1
- #!/usr/bin/env ruby
2
- # -*- mode: ruby; coding: utf-8-unix -*-
3
- require 'test/unit'
4
- require 'opencv'
5
- require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
-
7
- include OpenCV
8
-
9
- # Tests for OpenCV::CvSeq
10
- class TestCvSeq < OpenCVTestCase
11
- def test_initialize
12
- # assert_not_nil(CvSeq.new(CvIndex))
13
- assert_not_nil(CvSeq.new(Fixnum))
14
- assert_not_nil(CvSeq.new(CvPoint))
15
- assert_not_nil(CvSeq.new(CvPoint2D32f))
16
- assert_not_nil(CvSeq.new(CvPoint3D32f))
17
-
18
- assert(CvSeq.new(CvPoint).is_a? Enumerable)
19
- end
20
-
21
- def test_total
22
- seq1 = CvSeq.new(CvPoint)
23
- assert_equal(0, seq1.total)
24
-
25
- seq1.push(CvPoint.new(1, 2))
26
- assert_equal(1, seq1.total)
27
-
28
- seq1.push(CvPoint.new(3, 4))
29
- assert_equal(2, seq1.total)
30
- # Alias
31
- assert_equal(2, seq1.length)
32
- assert_equal(2, seq1.size)
33
- end
34
-
35
- def test_empty
36
- assert(CvSeq.new(CvPoint).empty?)
37
- assert(CvSeq.new(CvPoint2D32f).empty?)
38
- assert(CvSeq.new(CvPoint3D32f).empty?)
39
- end
40
-
41
- def test_aref
42
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
43
-
44
- assert_equal(CvPoint, seq1[0].class)
45
- assert_equal(10, seq1[0].x)
46
- assert_equal(20, seq1[0].y)
47
- assert_equal(30, seq1[1].x)
48
- assert_equal(40, seq1[1].y)
49
- assert_equal(50, seq1[2].x)
50
- assert_equal(60, seq1[2].y)
51
-
52
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
53
-
54
- assert_equal(Fixnum, seq2[0].class)
55
- assert_equal(10, seq2[0])
56
- assert_equal(20, seq2[1])
57
- assert_equal(30, seq2[2])
58
- end
59
-
60
- def test_push
61
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
62
-
63
- assert_equal(2, seq1.total)
64
- assert_equal(CvPoint, seq1[0].class)
65
- assert_equal(10, seq1[0].x)
66
- assert_equal(20, seq1[0].y)
67
- assert_equal(CvPoint, seq1[1].class)
68
- assert_equal(30, seq1[1].x)
69
- assert_equal(40, seq1[1].y)
70
-
71
- seq2 = CvSeq.new(CvPoint).push(CvPoint.new(50, 60))
72
- seq2.push(seq1)
73
- assert_equal(3, seq2.total)
74
- assert_equal(CvPoint, seq2[0].class)
75
- assert_equal(50, seq2[0].x)
76
- assert_equal(60, seq2[0].y)
77
- assert_equal(CvPoint, seq2[1].class)
78
- assert_equal(10, seq2[1].x)
79
- assert_equal(20, seq2[1].y)
80
- assert_equal(CvPoint, seq2[2].class)
81
- assert_equal(30, seq2[2].x)
82
- assert_equal(40, seq2[2].y)
83
-
84
- seq3 = CvSeq.new(Fixnum).push(10)
85
- seq4 = CvSeq.new(Fixnum).push(20, 30)
86
- seq3.push(seq4)
87
- assert_equal(3, seq3.total)
88
- assert_equal(Fixnum, seq3[0].class)
89
- assert_equal(10, seq3[0])
90
- assert_equal(20, seq3[1])
91
- assert_equal(30, seq3[2])
92
-
93
- assert_raise(TypeError) {
94
- seq1.push(CvPoint2D32f.new(55.5, 66.6))
95
- }
96
-
97
- assert_raise(TypeError) {
98
- seq3 = CvSeq.new(CvPoint2D32f).push(CvPoint2D32f.new(55.5, 66.6))
99
- seq1.push(seq3)
100
- }
101
- end
102
-
103
- def test_pop
104
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
105
- point1 = seq1.pop
106
- assert_equal(CvPoint, point1.class)
107
- assert_equal(30, point1.x)
108
- assert_equal(40, point1.y)
109
-
110
- assert_equal(1, seq1.total)
111
- assert_equal(CvPoint, seq1[0].class)
112
- assert_equal(10, seq1[0].x)
113
- assert_equal(20, seq1[0].y)
114
-
115
- assert_nil(CvSeq.new(CvPoint).pop)
116
-
117
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
118
- assert_equal(30, seq2.pop)
119
- assert_equal(20, seq2.pop)
120
- assert_equal(10, seq2.pop)
121
- end
122
-
123
- def test_clear
124
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
125
- seq1.clear
126
- assert_not_nil(seq1)
127
- assert_equal(0, seq1.total)
128
- end
129
-
130
- def test_unshift
131
- seq1 = CvSeq.new(CvPoint).unshift(CvPoint.new(10, 20), CvPoint.new(30, 40))
132
-
133
- assert_equal(2, seq1.total)
134
- assert_equal(CvPoint, seq1[0].class)
135
- assert_equal(30, seq1[0].x)
136
- assert_equal(40, seq1[0].y)
137
- assert_equal(CvPoint, seq1[1].class)
138
- assert_equal(10, seq1[1].x)
139
- assert_equal(20, seq1[1].y)
140
-
141
- seq2 = CvSeq.new(CvPoint).unshift(CvPoint.new(50, 60))
142
- seq2.unshift(seq1)
143
- assert_equal(3, seq2.total)
144
- assert_equal(CvPoint, seq1[0].class)
145
- assert_equal(30, seq1[0].x)
146
- assert_equal(40, seq1[0].y)
147
- assert_equal(CvPoint, seq1[1].class)
148
- assert_equal(10, seq1[1].x)
149
- assert_equal(20, seq1[1].y)
150
- assert_equal(CvPoint, seq2[2].class)
151
- assert_equal(50, seq2[2].x)
152
- assert_equal(60, seq2[2].y)
153
-
154
- seq3 = CvSeq.new(Fixnum).unshift(10, 20, 30)
155
- assert_equal(3, seq3.total)
156
- assert_equal(30, seq3[0])
157
- assert_equal(20, seq3[1])
158
- assert_equal(10, seq3[2])
159
-
160
- assert_raise(TypeError) {
161
- seq1.unshift(CvPoint2D32f.new(55.5, 66.6))
162
- }
163
-
164
- assert_raise(TypeError) {
165
- seq3 = CvSeq.new(CvPoint2D32f).push(CvPoint2D32f.new(55.5, 66.6))
166
- seq1.unshift(seq3)
167
- }
168
- end
169
-
170
- def test_shift
171
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
172
- point1 = seq1.shift
173
- assert_equal(CvPoint, point1.class)
174
- assert_equal(10, point1.x)
175
- assert_equal(20, point1.y)
176
-
177
- assert_equal(1, seq1.total)
178
- assert_equal(CvPoint, seq1[0].class)
179
- assert_equal(30, seq1[0].x)
180
- assert_equal(40, seq1[0].y)
181
-
182
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
183
- assert_equal(10, seq2.shift)
184
- assert_equal(20, seq2.shift)
185
- assert_equal(30, seq2.shift)
186
-
187
- assert_nil(CvSeq.new(CvPoint).shift)
188
- end
189
-
190
- def test_first
191
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
192
- point1 = seq1.first
193
- assert_equal(CvPoint, point1.class)
194
- assert_equal(10, point1.x)
195
- assert_equal(20, point1.y)
196
-
197
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
198
- assert_equal(10, seq2.first)
199
- end
200
-
201
- def test_last
202
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
203
- point1 = seq1.last
204
- assert_equal(CvPoint, point1.class)
205
- assert_equal(50, point1.x)
206
- assert_equal(60, point1.y)
207
-
208
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
209
- assert_equal(30, seq2.last)
210
- end
211
-
212
- def test_each
213
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
214
- i = 0
215
- seq1.each { |s|
216
- assert_equal(CvPoint, s.class)
217
- assert_equal(seq1[i].x, s.x)
218
- assert_equal(seq1[i].y, s.y)
219
- i += 1
220
- }
221
- assert_equal(3, i)
222
-
223
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
224
- i = 0
225
- seq2.each { |s|
226
- assert_equal(seq2[i], s)
227
- i += 1
228
- }
229
- assert_equal(3, i)
230
- end
231
-
232
- def test_each_index
233
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
234
- n = 0
235
- seq1.each_index { |i|
236
- assert_equal(n, i)
237
- n += 1
238
- }
239
- assert_equal(3, n)
240
- end
241
-
242
- def test_insert
243
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
244
- seq1.insert(1, CvPoint.new(50, 60))
245
- assert_equal(3, seq1.total)
246
- assert_equal(CvPoint, seq1[0].class)
247
- assert_equal(10, seq1[0].x)
248
- assert_equal(20, seq1[0].y)
249
- assert_equal(CvPoint, seq1[1].class)
250
- assert_equal(50, seq1[1].x)
251
- assert_equal(60, seq1[1].y)
252
- assert_equal(CvPoint, seq1[2].class)
253
- assert_equal(30, seq1[2].x)
254
- assert_equal(40, seq1[2].y)
255
-
256
- seq2 = CvSeq.new(Fixnum).push(10, 20)
257
- seq2.insert(1, 15)
258
- assert_equal(3, seq2.total)
259
- assert_equal(10, seq2[0])
260
- assert_equal(15, seq2[1])
261
- assert_equal(20, seq2[2])
262
- end
263
-
264
- def test_remove
265
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
266
-
267
- seq1.remove(1)
268
- assert_equal(2, seq1.total)
269
- assert_equal(CvPoint, seq1[0].class)
270
- assert_equal(10, seq1[0].x)
271
- assert_equal(20, seq1[0].y)
272
- assert_equal(CvPoint, seq1[1].class)
273
- assert_equal(50, seq1[1].x)
274
- assert_equal(60, seq1[1].y)
275
- end
276
-
277
- # These methods are tested in TestCvMat_imageprocessing#test_find_contours
278
- # (test_cvmat_imageprocessing.rb)
279
- # def test_h_prev
280
- # flunk('FIXME: CvSeq#h_prev is not tested yet.')
281
- # end
282
-
283
- # def test_h_next
284
- # flunk('FIXME: CvSeq#h_next is not tested yet.')
285
- # end
286
-
287
- # def test_v_prev
288
- # flunk('FIXME: CvSeq#v_prev is not tested yet.')
289
- # end
290
-
291
- # def test_v_next
292
- # flunk('FIXME: CvSeq#v_next is not tested yet.')
293
- # end
294
- end
295
-
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8 -*-
3
+ require 'test/unit'
4
+ require 'opencv'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
6
+
7
+ include OpenCV
8
+
9
+ # Tests for OpenCV::CvSeq
10
+ class TestCvSeq < OpenCVTestCase
11
+ def test_initialize
12
+ # assert_not_nil(CvSeq.new(CvIndex))
13
+ assert_not_nil(CvSeq.new(Fixnum))
14
+ assert_not_nil(CvSeq.new(CvPoint))
15
+ assert_not_nil(CvSeq.new(CvPoint2D32f))
16
+ assert_not_nil(CvSeq.new(CvPoint3D32f))
17
+
18
+ assert(CvSeq.new(CvPoint).is_a? Enumerable)
19
+ end
20
+
21
+ def test_total
22
+ seq1 = CvSeq.new(CvPoint)
23
+ assert_equal(0, seq1.total)
24
+
25
+ seq1.push(CvPoint.new(1, 2))
26
+ assert_equal(1, seq1.total)
27
+
28
+ seq1.push(CvPoint.new(3, 4))
29
+ assert_equal(2, seq1.total)
30
+ # Alias
31
+ assert_equal(2, seq1.length)
32
+ assert_equal(2, seq1.size)
33
+ end
34
+
35
+ def test_empty
36
+ assert(CvSeq.new(CvPoint).empty?)
37
+ assert(CvSeq.new(CvPoint2D32f).empty?)
38
+ assert(CvSeq.new(CvPoint3D32f).empty?)
39
+ end
40
+
41
+ def test_aref
42
+ seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
43
+
44
+ assert_equal(CvPoint, seq1[0].class)
45
+ assert_equal(10, seq1[0].x)
46
+ assert_equal(20, seq1[0].y)
47
+ assert_equal(30, seq1[1].x)
48
+ assert_equal(40, seq1[1].y)
49
+ assert_equal(50, seq1[2].x)
50
+ assert_equal(60, seq1[2].y)
51
+
52
+ seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
53
+
54
+ assert_equal(Fixnum, seq2[0].class)
55
+ assert_equal(10, seq2[0])
56
+ assert_equal(20, seq2[1])
57
+ assert_equal(30, seq2[2])
58
+ end
59
+
60
+ def test_push
61
+ seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
62
+
63
+ assert_equal(2, seq1.total)
64
+ assert_equal(CvPoint, seq1[0].class)
65
+ assert_equal(10, seq1[0].x)
66
+ assert_equal(20, seq1[0].y)
67
+ assert_equal(CvPoint, seq1[1].class)
68
+ assert_equal(30, seq1[1].x)
69
+ assert_equal(40, seq1[1].y)
70
+
71
+ seq2 = CvSeq.new(CvPoint).push(CvPoint.new(50, 60))
72
+ seq2.push(seq1)
73
+ assert_equal(3, seq2.total)
74
+ assert_equal(CvPoint, seq2[0].class)
75
+ assert_equal(50, seq2[0].x)
76
+ assert_equal(60, seq2[0].y)
77
+ assert_equal(CvPoint, seq2[1].class)
78
+ assert_equal(10, seq2[1].x)
79
+ assert_equal(20, seq2[1].y)
80
+ assert_equal(CvPoint, seq2[2].class)
81
+ assert_equal(30, seq2[2].x)
82
+ assert_equal(40, seq2[2].y)
83
+
84
+ seq3 = CvSeq.new(Fixnum).push(10)
85
+ seq4 = CvSeq.new(Fixnum).push(20, 30)
86
+ seq3.push(seq4)
87
+ assert_equal(3, seq3.total)
88
+ assert_equal(Fixnum, seq3[0].class)
89
+ assert_equal(10, seq3[0])
90
+ assert_equal(20, seq3[1])
91
+ assert_equal(30, seq3[2])
92
+
93
+ assert_raise(TypeError) {
94
+ seq1.push(CvPoint2D32f.new(55.5, 66.6))
95
+ }
96
+
97
+ assert_raise(TypeError) {
98
+ seq3 = CvSeq.new(CvPoint2D32f).push(CvPoint2D32f.new(55.5, 66.6))
99
+ seq1.push(seq3)
100
+ }
101
+ end
102
+
103
+ def test_pop
104
+ seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
105
+ point1 = seq1.pop
106
+ assert_equal(CvPoint, point1.class)
107
+ assert_equal(30, point1.x)
108
+ assert_equal(40, point1.y)
109
+
110
+ assert_equal(1, seq1.total)
111
+ assert_equal(CvPoint, seq1[0].class)
112
+ assert_equal(10, seq1[0].x)
113
+ assert_equal(20, seq1[0].y)
114
+
115
+ assert_nil(CvSeq.new(CvPoint).pop)
116
+
117
+ seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
118
+ assert_equal(30, seq2.pop)
119
+ assert_equal(20, seq2.pop)
120
+ assert_equal(10, seq2.pop)
121
+ end
122
+
123
+ def test_clear
124
+ seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
125
+ seq1.clear
126
+ assert_not_nil(seq1)
127
+ assert_equal(0, seq1.total)
128
+ end
129
+
130
+ def test_unshift
131
+ seq1 = CvSeq.new(CvPoint).unshift(CvPoint.new(10, 20), CvPoint.new(30, 40))
132
+
133
+ assert_equal(2, seq1.total)
134
+ assert_equal(CvPoint, seq1[0].class)
135
+ assert_equal(30, seq1[0].x)
136
+ assert_equal(40, seq1[0].y)
137
+ assert_equal(CvPoint, seq1[1].class)
138
+ assert_equal(10, seq1[1].x)
139
+ assert_equal(20, seq1[1].y)
140
+
141
+ seq2 = CvSeq.new(CvPoint).unshift(CvPoint.new(50, 60))
142
+ seq2.unshift(seq1)
143
+ assert_equal(3, seq2.total)
144
+ assert_equal(CvPoint, seq1[0].class)
145
+ assert_equal(30, seq1[0].x)
146
+ assert_equal(40, seq1[0].y)
147
+ assert_equal(CvPoint, seq1[1].class)
148
+ assert_equal(10, seq1[1].x)
149
+ assert_equal(20, seq1[1].y)
150
+ assert_equal(CvPoint, seq2[2].class)
151
+ assert_equal(50, seq2[2].x)
152
+ assert_equal(60, seq2[2].y)
153
+
154
+ seq3 = CvSeq.new(Fixnum).unshift(10, 20, 30)
155
+ assert_equal(3, seq3.total)
156
+ assert_equal(30, seq3[0])
157
+ assert_equal(20, seq3[1])
158
+ assert_equal(10, seq3[2])
159
+
160
+ assert_raise(TypeError) {
161
+ seq1.unshift(CvPoint2D32f.new(55.5, 66.6))
162
+ }
163
+
164
+ assert_raise(TypeError) {
165
+ seq3 = CvSeq.new(CvPoint2D32f).push(CvPoint2D32f.new(55.5, 66.6))
166
+ seq1.unshift(seq3)
167
+ }
168
+ end
169
+
170
+ def test_shift
171
+ seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
172
+ point1 = seq1.shift
173
+ assert_equal(CvPoint, point1.class)
174
+ assert_equal(10, point1.x)
175
+ assert_equal(20, point1.y)
176
+
177
+ assert_equal(1, seq1.total)
178
+ assert_equal(CvPoint, seq1[0].class)
179
+ assert_equal(30, seq1[0].x)
180
+ assert_equal(40, seq1[0].y)
181
+
182
+ seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
183
+ assert_equal(10, seq2.shift)
184
+ assert_equal(20, seq2.shift)
185
+ assert_equal(30, seq2.shift)
186
+
187
+ assert_nil(CvSeq.new(CvPoint).shift)
188
+ end
189
+
190
+ def test_first
191
+ seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
192
+ point1 = seq1.first
193
+ assert_equal(CvPoint, point1.class)
194
+ assert_equal(10, point1.x)
195
+ assert_equal(20, point1.y)
196
+
197
+ seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
198
+ assert_equal(10, seq2.first)
199
+ end
200
+
201
+ def test_last
202
+ seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
203
+ point1 = seq1.last
204
+ assert_equal(CvPoint, point1.class)
205
+ assert_equal(50, point1.x)
206
+ assert_equal(60, point1.y)
207
+
208
+ seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
209
+ assert_equal(30, seq2.last)
210
+ end
211
+
212
+ def test_each
213
+ seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
214
+ i = 0
215
+ seq1.each { |s|
216
+ assert_equal(CvPoint, s.class)
217
+ assert_equal(seq1[i].x, s.x)
218
+ assert_equal(seq1[i].y, s.y)
219
+ i += 1
220
+ }
221
+ assert_equal(3, i)
222
+
223
+ seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
224
+ i = 0
225
+ seq2.each { |s|
226
+ assert_equal(seq2[i], s)
227
+ i += 1
228
+ }
229
+ assert_equal(3, i)
230
+ end
231
+
232
+ def test_each_index
233
+ seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
234
+ n = 0
235
+ seq1.each_index { |i|
236
+ assert_equal(n, i)
237
+ n += 1
238
+ }
239
+ assert_equal(3, n)
240
+ end
241
+
242
+ def test_insert
243
+ seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
244
+ seq1.insert(1, CvPoint.new(50, 60))
245
+ assert_equal(3, seq1.total)
246
+ assert_equal(CvPoint, seq1[0].class)
247
+ assert_equal(10, seq1[0].x)
248
+ assert_equal(20, seq1[0].y)
249
+ assert_equal(CvPoint, seq1[1].class)
250
+ assert_equal(50, seq1[1].x)
251
+ assert_equal(60, seq1[1].y)
252
+ assert_equal(CvPoint, seq1[2].class)
253
+ assert_equal(30, seq1[2].x)
254
+ assert_equal(40, seq1[2].y)
255
+
256
+ seq2 = CvSeq.new(Fixnum).push(10, 20)
257
+ seq2.insert(1, 15)
258
+ assert_equal(3, seq2.total)
259
+ assert_equal(10, seq2[0])
260
+ assert_equal(15, seq2[1])
261
+ assert_equal(20, seq2[2])
262
+ end
263
+
264
+ def test_remove
265
+ seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
266
+
267
+ seq1.remove(1)
268
+ assert_equal(2, seq1.total)
269
+ assert_equal(CvPoint, seq1[0].class)
270
+ assert_equal(10, seq1[0].x)
271
+ assert_equal(20, seq1[0].y)
272
+ assert_equal(CvPoint, seq1[1].class)
273
+ assert_equal(50, seq1[1].x)
274
+ assert_equal(60, seq1[1].y)
275
+ end
276
+
277
+ # These methods are tested in TestCvMat_imageprocessing#test_find_contours
278
+ # (test_cvmat_imageprocessing.rb)
279
+ # def test_h_prev
280
+ # flunk('FIXME: CvSeq#h_prev is not tested yet.')
281
+ # end
282
+
283
+ # def test_h_next
284
+ # flunk('FIXME: CvSeq#h_next is not tested yet.')
285
+ # end
286
+
287
+ # def test_v_prev
288
+ # flunk('FIXME: CvSeq#v_prev is not tested yet.')
289
+ # end
290
+
291
+ # def test_v_next
292
+ # flunk('FIXME: CvSeq#v_next is not tested yet.')
293
+ # end
294
+ end
295
+