From 1514025e37b4383580f4baf083a06272961bb157 Mon Sep 17 00:00:00 2001 From: Almasty007 <nat2013@laposte.net> Date: Tue, 24 Jan 2023 15:20:18 +0100 Subject: [PATCH] ajout des tests --- src/test/java/fr/nancy/iut/SphereTest.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/test/java/fr/nancy/iut/SphereTest.java b/src/test/java/fr/nancy/iut/SphereTest.java index 0164c5f..648a0e7 100644 --- a/src/test/java/fr/nancy/iut/SphereTest.java +++ b/src/test/java/fr/nancy/iut/SphereTest.java @@ -12,6 +12,7 @@ public class SphereTest { public void testComputeVolume() throws Exception { Sphere mySphere = new Sphere(1.5); assertEquals(9.42477796076938, mySphere.computeVolume(), 0.0); + } @Test @@ -19,6 +20,35 @@ public class SphereTest { Sphere mySphere = new Sphere(1, new Point3d(10, 15, 5)); Sphere mySphere2 = new Sphere(1,new Point3d(10, 15, 6)); assertEquals(1, mySphere.distanceSquaredTo(mySphere2)); + assertEquals(1, mySphere.distanceTo(mySphere2)); + } + + @Test + public void testContact() throws Exception { + Sphere mySphere = new Sphere(1, new Point3d(10, 15, 5)); + Sphere mySphere2 = new Sphere(1,new Point3d(10, 15, 6)); + Sphere mySphere3 = new Sphere(1,new Point3d(100, 15, 6)); + assertEquals(true, mySphere2.inContactWith(mySphere2) ); + assertEquals(false, mySphere2.inContactWith(mySphere3) ); + Sphere mySphere4 = new Sphere(1); + Sphere mySphere5 = new Sphere(1); + assertEquals(true, mySphere4.inContactWith(mySphere5)); } + @Test + public void testGetters() throws Exception { + Sphere mySphere = new Sphere(1, new Point3d(10, 15, 5)); + assertEquals(new Point3d(10, 15, 5), mySphere.getPos()); + assertEquals(1, mySphere.getRadius()); + } + + @Test + public void testCreerCercle() throws Exception { + Sphere s1 = new Sphere(); + assertEquals(0, s1.getRadius()); + assertEquals(new Point3d(), s1.getPos()); + } + + + } \ No newline at end of file -- GitLab