Point3Test.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package org.opencv.test.core;
  2. import org.opencv.core.Point;
  3. import org.opencv.core.Point3;
  4. import org.opencv.test.OpenCVTestCase;
  5. public class Point3Test extends OpenCVTestCase {
  6. private Point3 p1;
  7. private Point3 p2;
  8. @Override
  9. protected void setUp() throws Exception {
  10. super.setUp();
  11. p1 = new Point3(2, 2, 2);
  12. p2 = new Point3(1, 1, 1);
  13. }
  14. public void testClone() {
  15. Point3 truth = new Point3(1, 1, 1);
  16. p1 = truth.clone();
  17. assertEquals(truth, p1);
  18. }
  19. public void testCross() {
  20. Point3 dstPoint = p1.cross(p2);
  21. Point3 truth = new Point3(0, 0, 0);
  22. assertEquals(truth, dstPoint);
  23. }
  24. public void testDot() {
  25. double result = p1.dot(p2);
  26. assertEquals(6.0, result);
  27. }
  28. public void testEqualsObject() {
  29. boolean flag = p1.equals(p1);
  30. assertTrue(flag);
  31. flag = p1.equals(p2);
  32. assertFalse(flag);
  33. }
  34. public void testHashCode() {
  35. assertEquals(p1.hashCode(), p1.hashCode());
  36. }
  37. public void testPoint3() {
  38. p1 = new Point3();
  39. assertNotNull(p1);
  40. assertTrue(0 == p1.x);
  41. assertTrue(0 == p1.y);
  42. assertTrue(0 == p1.z);
  43. }
  44. public void testPoint3DoubleArray() {
  45. double[] vals = { 1, 2, 3 };
  46. p1 = new Point3(vals);
  47. assertTrue(1 == p1.x);
  48. assertTrue(2 == p1.y);
  49. assertTrue(3 == p1.z);
  50. }
  51. public void testPoint3DoubleDoubleDouble() {
  52. p1 = new Point3(1, 2, 3);
  53. assertEquals(1., p1.x);
  54. assertEquals(2., p1.y);
  55. assertEquals(3., p1.z);
  56. }
  57. public void testPoint3Point() {
  58. Point p = new Point(2, 3);
  59. p1 = new Point3(p);
  60. assertEquals(2., p1.x);
  61. assertEquals(3., p1.y);
  62. assertEquals(0., p1.z);
  63. }
  64. public void testSet() {
  65. double[] vals1 = {};
  66. p1.set(vals1);
  67. assertEquals(0., p1.x);
  68. assertEquals(0., p1.y);
  69. assertEquals(0., p1.z);
  70. double[] vals2 = { 3, 6, 10 };
  71. p1.set(vals2);
  72. assertEquals(3., p1.x);
  73. assertEquals(6., p1.y);
  74. assertEquals(10., p1.z);
  75. }
  76. public void testToString() {
  77. String actual = p1.toString();
  78. String expected = "{2.0, 2.0, 2.0}";
  79. assertEquals(expected, actual);
  80. }
  81. }