DMatchTest.swift 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // DMatchTest.swift
  3. //
  4. // Created by Giles Payne on 2020/01/31.
  5. //
  6. import XCTest
  7. import OpenCV
  8. class DMatchTest: OpenCVTestCase {
  9. func testDMatchIntIntFloat() {
  10. let dm1 = DMatch(queryIdx: 1, trainIdx: 4, distance: 4.0)
  11. XCTAssertEqual(1, dm1.queryIdx)
  12. XCTAssertEqual(4, dm1.trainIdx)
  13. XCTAssertEqual(4.0, dm1.distance)
  14. }
  15. func testDMatchIntIntIntFloat() {
  16. let dm2 = DMatch(queryIdx: 2, trainIdx: 6, imgIdx: -1, distance: 8.0)
  17. XCTAssertEqual(2, dm2.queryIdx)
  18. XCTAssertEqual(6, dm2.trainIdx)
  19. XCTAssertEqual(-1, dm2.imgIdx)
  20. XCTAssertEqual(8.0, dm2.distance)
  21. }
  22. func testLessThan() {
  23. let dm1 = DMatch(queryIdx: 1, trainIdx: 4, distance: 4.0)
  24. let dm2 = DMatch(queryIdx: 2, trainIdx: 6, imgIdx: -1, distance: 8.0)
  25. XCTAssert(dm1.lessThan(dm2))
  26. }
  27. func testToString() {
  28. let dm2 = DMatch(queryIdx: 2, trainIdx: 6, imgIdx: -1, distance: 8.0)
  29. let actual = "\(dm2)"
  30. let expected = "DMatch { queryIdx: 2, trainIdx: 6, imgIdx: -1, distance: 8.000000}"
  31. XCTAssertEqual(expected, actual)
  32. }
  33. }