package org.nd4j.linalg.api.string;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.nd4j.linalg.BaseNd4jTest;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.Nd4j;
import org.nd4j.linalg.factory.Nd4jBackend;
import org.nd4j.linalg.string.NDArrayStrings;

/**
 * @author Adam Gibson
 */
@RunWith(Parameterized.class)
public class TestFormatting extends BaseNd4jTest {

    public TestFormatting(Nd4jBackend backend) {
        super(backend);
    }

    @Test
    public void testTwoByTwo() {
        INDArray arr = Nd4j.create(2, 2,2,2);
        System.out.println(new NDArrayStrings().format(arr));

    }

    @Test
    public void testNd4jArrayString(){

        //2d array
        INDArray arr = Nd4j.create(new float[]{1f,20000000f,40.838383f,3f}, new int[]{2,2});

        //default
        String expected1 = "[[1.00,40.84],\n" +
                           " [20,000,000.00,3.00]]";
        String serializedData1 = new NDArrayStrings(",",2).format(arr);
        Assert.assertTrue(serializedData1.equals(expected1));

        //remove commas
        String expected2 = "[[1.00,40.84],\n" +
                " [20000000.00,3.00]]";
        String serializedData2 = new NDArrayStrings(",",2,"######0").format(arr);
        Assert.assertTrue(serializedData2.equals(expected2));

    }

    @Test
    public void blah() {
        INDArray arr = Nd4j.linspace(1,4,4).reshape(2,2);
        INDArray arrA = Nd4j.create(new float[] {1.0f,2.0f,3.0f,4.0f}, new int[] {2,2});
        String b = new NDArrayStrings(",",2,"######0").format(arr);
    }


    @Override
    public char ordering() {
        return 'f';
    }
}

@@ -1398,266 +1398,8 @@
  %7D%0A%0A
-    @Test%0A    public void blah() %7B%0A        INDArray arr = Nd4j.linspace(1,4,4).reshape(2,2);%0A        INDArray arrA = Nd4j.create(new float%5B%5D %7B1.0f,2.0f,3.0f,4.0f%7D, new int%5B%5D %7B2,2%7D);%0A        String b = new NDArrayStrings(%22,%22,2,%22######0%22).format(arr);%0A    %7D%0A%0A%0A
     

Fix assertion in formatting