mirror of
				https://github.com/ruby-opencv/ruby-opencv
				synced 2023-03-27 23:22:12 -04:00 
			
		
		
		
	implemented CvSize2D32f#to_s, CvSize2D32f#to_ary, and added some tests for CvSize and CvSize2D32f
This commit is contained in:
		
							parent
							
								
									171310a301
								
							
						
					
					
						commit
						04bb08414b
					
				
					 4 changed files with 175 additions and 0 deletions
				
			
		
							
								
								
									
										70
									
								
								test/test_cvsize2d32f.rb
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										70
									
								
								test/test_cvsize2d32f.rb
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,70 @@ | |||
| #!/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(ArgumentError) { | ||||
|       CvSize2D32f.new('string') | ||||
|     } | ||||
|     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) | ||||
|   end | ||||
| end | ||||
| 
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 ser1zw
						ser1zw