TermCriteriaTest.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package org.opencv.test.core;
  2. import org.opencv.core.TermCriteria;
  3. import org.opencv.test.OpenCVTestCase;
  4. public class TermCriteriaTest extends OpenCVTestCase {
  5. private TermCriteria tc1;
  6. private TermCriteria tc2;
  7. @Override
  8. protected void setUp() throws Exception {
  9. super.setUp();
  10. tc1 = new TermCriteria();
  11. tc2 = new TermCriteria(2, 4, EPS);
  12. }
  13. public void testClone() {
  14. tc1 = tc2.clone();
  15. assertEquals(tc2, tc1);
  16. }
  17. public void testEqualsObject() {
  18. assertFalse(tc2.equals(tc1));
  19. tc1 = tc2.clone();
  20. assertTrue(tc2.equals(tc1));
  21. }
  22. public void testHashCode() {
  23. assertEquals(tc2.hashCode(), tc2.hashCode());
  24. }
  25. public void testSet() {
  26. double[] vals1 = {};
  27. tc1.set(vals1);
  28. assertEquals(0, tc1.type);
  29. assertEquals(0, tc1.maxCount);
  30. assertEquals(0.0, tc1.epsilon);
  31. double[] vals2 = { 9, 8, 0.002 };
  32. tc2.set(vals2);
  33. assertEquals(9, tc2.type);
  34. assertEquals(8, tc2.maxCount);
  35. assertEquals(0.002, tc2.epsilon);
  36. }
  37. public void testTermCriteria() {
  38. tc1 = new TermCriteria();
  39. assertNotNull(tc1);
  40. assertEquals(0, tc1.type);
  41. assertEquals(0, tc1.maxCount);
  42. assertEquals(0.0, tc1.epsilon);
  43. }
  44. public void testTermCriteriaDoubleArray() {
  45. double[] vals = { 3, 2, 0.007 };
  46. tc1 = new TermCriteria(vals);
  47. assertEquals(3, tc1.type);
  48. assertEquals(2, tc1.maxCount);
  49. assertEquals(0.007, tc1.epsilon);
  50. }
  51. public void testTermCriteriaIntIntDouble() {
  52. tc1 = new TermCriteria(2, 4, EPS);
  53. assertNotNull(tc2);
  54. assertEquals(2, tc2.type);
  55. assertEquals(4, tc2.maxCount);
  56. assertEquals(EPS, tc2.epsilon);
  57. }
  58. public void testToString() {
  59. String actual = tc2.toString();
  60. double eps = EPS;
  61. String expected = "{ type: 2, maxCount: 4, epsilon: " + eps + "}";
  62. assertEquals(expected, actual);
  63. }
  64. }