Package kompleksnaStevila

Source Code of kompleksnaStevila.ComplexAddTest

package kompleksnaStevila;

import kompleksnaStevila.Complex;

import org.junit.Assert;
import org.junit.Test;

public class ComplexAddTest {

    @Test
    public void testAdd() {
        Complex first = new Complex(-4, 5);
        Complex second = new Complex(10, 6);

        Complex vsota = first.add(second);

        Assert.assertEquals(6, vsota.getRealnoStevilo(), 0.1);
        Assert.assertEquals(11, vsota.getImaginarnoStevilo(), 0.1);

        // preverimo da se vrednosti v first in second ne spremenita
        Assert.assertEquals(-4, first.getRealnoStevilo(), 0.1);
        Assert.assertEquals(5, first.getImaginarnoStevilo(), 0.1);

        Assert.assertEquals(10, second.getRealnoStevilo(), 0.1);
        Assert.assertEquals(6, second.getImaginarnoStevilo(), 0.1);

    }

}
TOP

Related Classes of kompleksnaStevila.ComplexAddTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.