All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jeometry.test.geom2D.point.Point2DTest Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package org.jeometry.test.geom2D.point;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

import org.jeometry.factory.JeometryFactory;
import org.jeometry.geom2D.point.Point2D;
import org.jeometry.test.math.VectorTest;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;


/**
 * Unitary tests dedicated to {@link Point2D} implementations.
*
* Usage: *

* Create a test class that extends this one *

* @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org * @since 1.0.2 */ public class Point2DTest extends VectorTest { /** * Initialize the tests. */ @BeforeAll public static void initClass() { fail("method public static void init() has to be set up with @BeforeClass annotation"); } /** * Testing {@link Point2D#setValues(double, double)} */ @Test public void setValuesXYZTest() { double[] values = new double[] {1.0d, 2.0d}; Point2D p = JeometryFactory.createPoint2D(); p.setValues(values[0], values[1]); assertEquals(values[0], p.getX(), Double.MIN_VALUE, "Invalid X coordinate"); assertEquals(values[1], p.getY(), Double.MIN_VALUE, "Invalid Y coordinate"); p.setValues(values[1], values[0]); assertEquals(values[1], p.getX(), Double.MIN_VALUE, "Invalid X coordinate"); assertEquals(values[2], p.getY(), Double.MIN_VALUE, "Invalid Y coordinate"); } /** * Testing {@link Point2D#setValues(Point2D)} */ @Test public void setValuesPoint2DTest() { double[] values = new double[] {1.0d, 2.0d}; Point2D p = JeometryFactory.createPoint2D(); p.setValues(JeometryFactory.createPoint2D(values[0], values[1])); assertEquals(values[0], p.getX(), Double.MIN_VALUE, "Invalid X coordinate"); assertEquals(values[1], p.getY(), Double.MIN_VALUE, "Invalid Y coordinate"); p.setValues(JeometryFactory.createPoint2D(values[1], values[0])); assertEquals(values[1], p.getX(), Double.MIN_VALUE, "Invalid X coordinate"); assertEquals(values[2], p.getY(), Double.MIN_VALUE, "Invalid Y coordinate"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy