DMatchTest.java 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package org.opencv.test.core;
  2. import org.opencv.core.DMatch;
  3. import junit.framework.TestCase;
  4. public class DMatchTest extends TestCase {
  5. public void testDMatch() {
  6. new DMatch();
  7. }
  8. public void testDMatchIntIntFloat() {
  9. DMatch dm1 = new DMatch(1, 4, 4.0f);
  10. assertEquals(1, dm1.queryIdx);
  11. assertEquals(4, dm1.trainIdx);
  12. assertEquals(4.0f, dm1.distance);
  13. }
  14. public void testDMatchIntIntIntFloat() {
  15. DMatch dm2 = new DMatch(2, 6, -1, 8.0f);
  16. assertEquals(2, dm2.queryIdx);
  17. assertEquals(6, dm2.trainIdx);
  18. assertEquals(-1, dm2.imgIdx);
  19. assertEquals(8.0f, dm2.distance);
  20. }
  21. public void testLessThan() {
  22. DMatch dm1 = new DMatch(1, 4, 4.0f);
  23. DMatch dm2 = new DMatch(2, 6, -1, 8.0f);
  24. assertTrue(dm1.lessThan(dm2));
  25. }
  26. public void testToString() {
  27. DMatch dm2 = new DMatch(2, 6, -1, 8.0f);
  28. String actual = dm2.toString();
  29. String expected = "DMatch [queryIdx=2, trainIdx=6, imgIdx=-1, distance=8.0]";
  30. assertEquals(expected, actual);
  31. }
  32. }