Advertisement
piffy

PuntoTest

Aug 15th, 2021 (edited)
1,365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import static org.junit.jupiter.api.Assertions.*;
  2.  
  3.  
  4. class PuntoTest {
  5.     Punto p = new Punto(1,2);
  6.     Punto p2 = new Punto();
  7.    
  8.    
  9.    
  10.     @Test
  11.     void testCostruttoreDefault() {
  12.         double x=0,y=0;
  13.         assertEquals(x,p2.x());
  14.         assertEquals(y,p2.y());
  15.     }
  16.    
  17.     @Test
  18.     void testCostruttore() {
  19.         assertEquals(1,p.x());
  20.         assertEquals(2,p.y());
  21.     }
  22.    
  23.     @Test
  24.     void testDistanza() {
  25.         assertEquals(Math.sqrt(5), p.distanzaDa(p2), 0.001);
  26.         assertEquals(0, p.distanzaDa(p), 0.001);
  27.     }
  28.    
  29.     @Test
  30.     void testToString() {
  31.         assertEquals("(1.0,2.0)", p.toString());
  32.     }
  33.  
  34.    
  35.  
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement