mirror of
https://github.com/opencv/opencv.git
synced 2026-07-25 13:23:02 +04:00
02385472b6
Objc binding * Initial work on Objective-C wrapper * Objective-C generator script; update manually generated wrappers * Add Mat tests * Core Tests * Imgproc wrapper generation and tests * Fixes for Imgcodecs wrapper * Miscellaneous fixes. Swift build support * Objective-C wrapper build/install * Add Swift wrappers for videoio/objdetect/feature2d * Framework build;iOS support * Fix toArray functions;Use enum types whenever possible * Use enum types where possible;prepare test build * Update test * Add test runner scripts for iOS and macOS * Add test scripts and samples * Build fixes * Fix build (cmake 3.17.x compatibility) * Fix warnings * Fix enum name conflicting handling * Add support for document generation with Jazzy * Swift/Native fast accessor functions * Add Objective-C wrapper for calib3d, dnn, ml, photo and video modules * Remove IntOut/FloatOut/DoubleOut classes * Fix iOS default test platform value * Fix samples * Revert default framework name to opencv2 * Add converter util functions * Fix failing test * Fix whitespace * Add handling for deprecated methods;fix warnings;define __OPENCV_BUILD * Suppress cmake warnings * Reduce severity of "jazzy not found" log message * Fix incorrect #include of compatibility header in ios.h * Use explicit returns in subscript/get implementation * Reduce minimum required cmake version to 3.15 for Objective-C/Swift binding
89 lines
1.8 KiB
Swift
89 lines
1.8 KiB
Swift
//
|
|
// PointTest.swift
|
|
//
|
|
// Created by Giles Payne on 2020/01/31.
|
|
//
|
|
|
|
import XCTest
|
|
import OpenCV
|
|
|
|
class PointTest: OpenCVTestCase {
|
|
|
|
let p1 = Point2d(x: 2, y: 2)
|
|
let p2 = Point2d(x: 1, y: 1)
|
|
|
|
func testClone() {
|
|
let truth = Point2d(x: 1, y: 1)
|
|
let dstPoint = truth.clone()
|
|
XCTAssertEqual(truth, dstPoint);
|
|
}
|
|
|
|
func testDot() {
|
|
let result = p1.dot(p2);
|
|
XCTAssertEqual(4.0, result)
|
|
}
|
|
|
|
func testEqualsObject() {
|
|
var flag = p1 == p1
|
|
XCTAssert(flag)
|
|
|
|
flag = p1 == p2
|
|
XCTAssertFalse(flag)
|
|
}
|
|
|
|
func testHashCode() {
|
|
XCTAssertEqual(p1.hash(), p1.hash())
|
|
}
|
|
|
|
func testInside() {
|
|
let rect = Rect2d(x: 0, y: 0, width: 5, height: 3)
|
|
XCTAssert(p1.inside(rect))
|
|
|
|
let p2 = Point2d(x: 3, y: 3)
|
|
XCTAssertFalse(p2.inside(rect))
|
|
}
|
|
|
|
func testPoint() {
|
|
let p = Point2d()
|
|
|
|
XCTAssertNotNil(p)
|
|
XCTAssertEqual(0.0, p.x)
|
|
XCTAssertEqual(0.0, p.y)
|
|
}
|
|
|
|
func testPointDoubleArray() {
|
|
let vals:[Double] = [2, 4]
|
|
let p = Point2d(vals: vals as [NSNumber])
|
|
|
|
XCTAssertEqual(2.0, p.x);
|
|
XCTAssertEqual(4.0, p.y);
|
|
}
|
|
|
|
func testPointDoubleDouble() {
|
|
let p1 = Point2d(x: 7, y: 5)
|
|
|
|
XCTAssertNotNil(p1)
|
|
XCTAssertEqual(7.0, p1.x);
|
|
XCTAssertEqual(5.0, p1.y);
|
|
}
|
|
|
|
func testSet() {
|
|
let vals1:[Double] = []
|
|
p1.set(vals: vals1 as [NSNumber])
|
|
XCTAssertEqual(0.0, p1.x)
|
|
XCTAssertEqual(0.0, p1.y)
|
|
|
|
let vals2 = [ 6, 10 ]
|
|
p2.set(vals: vals2 as [NSNumber])
|
|
XCTAssertEqual(6.0, p2.x)
|
|
XCTAssertEqual(10.0, p2.y)
|
|
}
|
|
|
|
func testToString() {
|
|
let actual = "\(p1)"
|
|
let expected = "Point2d {2.000000,2.000000}"
|
|
XCTAssertEqual(expected, actual)
|
|
}
|
|
|
|
}
|