piffy icon

PuntoTest

piffy | PRO | 08/16/21 12:47:37 PM UTC (Edited) | 0 ⭐ | 1678 👁️ | Never ⏰ | []
Java |

570 B

|

None

|

0 👍

/

0 👎

import static org.junit.jupiter.api.Assertions.*;
 
 
class PuntoTest {
    Punto p = new Punto(1,2);
    Punto p2 = new Punto();
    
    
    
    @Test
    void testCostruttoreDefault() {
        double x=0,y=0;
        assertEquals(x,p2.x());
        assertEquals(y,p2.y());
    }
    
    @Test
    void testCostruttore() {
        assertEquals(1,p.x());
        assertEquals(2,p.y());
    }
    
    @Test
    void testDistanza() {
        assertEquals(Math.sqrt(5), p.distanzaDa(p2), 0.001);
        assertEquals(0, p.distanzaDa(p), 0.001);
    }
    
    @Test
    void testToString() {
        assertEquals("(1.0,2.0)", p.toString());
    }
 
    
 
}
 

Comments