1
0
Fork 0
mirror of https://github.com/ruby-opencv/ruby-opencv synced 2023-03-27 23:22:12 -04:00

modified an error message of CvMat#copy

This commit is contained in:
ser1zw 2011-05-15 02:36:48 +09:00
parent 059762efac
commit 6841c2f417
2 changed files with 7 additions and 17 deletions

View file

@ -705,7 +705,7 @@ rb_clone(VALUE self)
VALUE VALUE
rb_copy(int argc, VALUE *argv, VALUE self) rb_copy(int argc, VALUE *argv, VALUE self)
{ {
VALUE value, copied, tmp; VALUE value, copied;
CvMat *src = CVMAT(self); CvMat *src = CVMAT(self);
rb_scan_args(argc, argv, "01", &value); rb_scan_args(argc, argv, "01", &value);
if (argc == 0) { if (argc == 0) {
@ -724,7 +724,7 @@ rb_copy(int argc, VALUE *argv, VALUE self)
if (n > 0) { if (n > 0) {
copied = rb_ary_new2(n); copied = rb_ary_new2(n);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
tmp = new_object(src->rows, src->cols, cvGetElemType(src)); VALUE tmp = new_object(src->rows, src->cols, cvGetElemType(src));
cvCopy(src, CVMAT(tmp)); cvCopy(src, CVMAT(tmp));
rb_ary_store(copied, i, tmp); rb_ary_store(copied, i, tmp);
} }
@ -733,8 +733,9 @@ rb_copy(int argc, VALUE *argv, VALUE self)
else { else {
return Qnil; return Qnil;
} }
}else }
rb_raise(rb_eArgError, ""); else
rb_raise(rb_eArgError, "Argument should be CvMat or Fixnum");
} }
} }

View file

@ -199,19 +199,8 @@ class TestCvMat < OpenCVTestCase
} }
assert_nil(m1.copy(-1)) assert_nil(m1.copy(-1))
flunk('FIXME: CvUnmatchedSizes and CvUnmatchedFormats are not implemented yet') assert_raise(ArgumentError) {
m2 = CvMat.new(1, 2, CV_32F, 1) m1.copy('foobar')
assert_raise(CvUnmatchedSizes) {
m1.copy(m2)
}
m2 = CvMat.new(10, 20, CV_32F, 3)
assert_raise(CvUnmatchedFormats) {
m1.copy(m2)
}
m2 = CvMat.new(10, 20, CV_8U, 1)
assert_raise(CvUnmatchedFormats) {
m1.copy(m2)
} }
end end