Package kompleksnaStevila

Source Code of kompleksnaStevila.ComplexToString

package kompleksnaStevila;

import kompleksnaStevila.Complex;
import org.junit.Assert;
import org.junit.Test;

public class ComplexToString {
    @Test
    public void testToString() {
        Complex org1 = new Complex(5.2, 0);
        String dej1 = "5.2";
        Complex org2 = new Complex(0, 6.7);
        String dej2 = "6.7i";

        Complex org3 = new Complex(-5.4, -8);
        String dej3 = "-5.4-8.0i";
        Complex org4 = new Complex(6.897, 6);
        String dej4 = "6.897+6.0i";

        Complex org5 = new Complex(0, 0);
        String dej5 = "";

        Complex org6 = new Complex(0, -7);
        String dej6 = "-7.0i";

        Assert.assertEquals(dej1, org1.toString());
        Assert.assertEquals(dej2, org2.toString());
        Assert.assertEquals(dej3, org3.toString());
        Assert.assertEquals(dej4, org4.toString());
        Assert.assertEquals(dej5, org5.toString());
        Assert.assertEquals(dej6, org6.toString());

    }
}
TOP

Related Classes of kompleksnaStevila.ComplexToString

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.