1
0
Fork 0
mirror of https://github.com/ruby-opencv/ruby-opencv synced 2023-03-27 23:22:12 -04:00
ruby-opencv/test/test_cvsize2d32f.rb
ser1zw b3016fc68c added error handling to some methods (2)
Added error handlings to the methods of following classes or modules
 -CvPoint2D32f
 -CvPoint3D32f
 -CvRect
 -CvScalar
 -CvSeq
 -CvSize
 -CvSize2D32f
 -CvSlice
 -CvSURFParams
 -CvSURFPoint
 -CvTermCriteria
 -CvTwoPoints
 -CvUtils
 -CvVideoWriter
 -GUI
 -IplConvKernel
 -IplImage
 -MouseEvent
 -OpenCV
 -Trackbar
 -Window
2011-07-23 19:51:58 +09:00

75 lines
1.9 KiB
Ruby
Executable file

#!/usr/bin/env ruby
# -*- mode: ruby; coding: utf-8-unix -*-
require 'test/unit'
require 'opencv'
require File.expand_path(File.dirname(__FILE__)) + '/helper'
include OpenCV
# Tests for OpenCV::CvSize2D32f
class TestCvSize2D32f < OpenCVTestCase
class MySize; end
def test_width
size = CvSize2D32f.new
size.width = 1.1
assert_in_delta(1.1, size.width, 0.001)
size.width = 2.2
assert_in_delta(2.2, size.width, 0.001)
end
def test_height
size = CvSize2D32f.new
size.height = 1.1
assert_in_delta(1.1, size.height, 0.001)
size.height = 2.2
assert_in_delta(2.2, size.height, 0.001)
end
def test_compatible
assert(!(CvSize2D32f.compatible? MySize.new))
MySize.class_eval { def width; end }
assert(!(CvSize2D32f.compatible? MySize.new))
MySize.class_eval { def height; end }
assert(CvSize2D32f.compatible? MySize.new)
assert(CvSize2D32f.compatible? CvSize2D32f.new)
end
def test_initialize
size = CvSize2D32f.new
assert_in_delta(0, size.width, 0.001)
assert_in_delta(0, size.height, 0.001)
size = CvSize2D32f.new(1.1, 2.2)
assert_in_delta(1.1, size.width, 0.001)
assert_in_delta(2.2, size.height, 0.001)
size = CvSize2D32f.new(CvSize2D32f.new(1.1, 2.2))
assert_in_delta(1.1, size.width, 0.001)
assert_in_delta(2.2, size.height, 0.001)
assert_raise(TypeError) {
CvSize2D32f.new(DUMMY_OBJ)
}
assert_raise(ArgumentError) {
CvSize2D32f.new(1, 2, 3)
}
end
def test_to_s
size = CvSize2D32f.new(1.1, 2.2)
assert_equal('<OpenCV::CvSize2D32f:1.1x2.2>', size.to_s)
end
def test_to_ary
a = CvSize2D32f.new(1.1, 2.2).to_ary
assert_in_delta(1.1, a[0], 0.001)
assert_in_delta(2.2, a[1], 0.001)
# Alias
a = CvSize2D32f.new(1.1, 2.2).to_a
assert_in_delta(1.1, a[0], 0.001)
assert_in_delta(2.2, a[1], 0.001)
end
end