@@ -26,20 +26,18 @@ describe("rect", () => {
2626 // Test that boxPoints accepts one argument and returns Point2f[]
2727 const points = cv . boxPoints ( rotatedRect ) ;
2828
29- // Verify it returns an array
30- expect ( Array . isArray ( points ) ) . toBe ( true ) ;
31-
3229 // Verify it returns 4 points
3330 expect ( points . length ) . toBe ( 4 ) ;
3431
35- // Verify each point has x and y properties
36- points . forEach ( ( point ) => {
37- expect ( typeof point . x ) . toBe ( "number" ) ;
38- expect ( typeof point . y ) . toBe ( "number" ) ;
39- } ) ;
40-
41- // Verify the points are reasonable (not all zeros)
42- const hasNonZero = points . some ( ( point ) => point . x !== 0 || point . y !== 0 ) ;
43- expect ( hasNonZero ) . toBe ( true ) ;
32+ // Check the actual values - boxPoints should return the same result as RotatedRect.points
33+ const expectedPoints = cv . RotatedRect . points ( rotatedRect ) ;
34+ expect ( points [ 0 ] . x ) . toBeCloseTo ( expectedPoints [ 0 ] . x , 5 ) ;
35+ expect ( points [ 0 ] . y ) . toBeCloseTo ( expectedPoints [ 0 ] . y , 5 ) ;
36+ expect ( points [ 1 ] . x ) . toBeCloseTo ( expectedPoints [ 1 ] . x , 5 ) ;
37+ expect ( points [ 1 ] . y ) . toBeCloseTo ( expectedPoints [ 1 ] . y , 5 ) ;
38+ expect ( points [ 2 ] . x ) . toBeCloseTo ( expectedPoints [ 2 ] . x , 5 ) ;
39+ expect ( points [ 2 ] . y ) . toBeCloseTo ( expectedPoints [ 2 ] . y , 5 ) ;
40+ expect ( points [ 3 ] . x ) . toBeCloseTo ( expectedPoints [ 3 ] . x , 5 ) ;
41+ expect ( points [ 3 ] . y ) . toBeCloseTo ( expectedPoints [ 3 ] . y , 5 ) ;
4442 } ) ;
4543} ) ;
0 commit comments