package water.fvec;

import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import water.TestUtil;

import java.util.Arrays;

public class C1SChunkTest extends TestUtil {
  @Test void test_inflate_impl() {
    NewChunk nc = new NewChunk(null, 0);

    for (int l=0; l<1; ++l) {
      // 0, 0.2, 0.3, 2.54, NA for l==0
      // NA, 0, 0.2, 0.3, 2.54, NA for l==1
      int[] man = new int[]{0, 2, 3, 254};
      int[] exp = new int[]{1, -1, -1, -2};
      if (l==1) nc.addNA();
      for (int i = 0; i < man.length; ++i) nc.addNum(man[i], exp[i]);
      nc.addNA();

      Chunk cc = nc.compress();
      AssertJUnit.assertEquals(man.length + 1 + l, cc.len());
      AssertJUnit.assertTrue(cc instanceof C1SChunk);
      if (l==1) AssertJUnit.assertTrue(cc.isNA0(0));
      for (int i = 0; i < man.length; ++i)
        AssertJUnit.assertEquals((float) (man[i] * Math.pow(10, exp[i])), (float) cc.at0(l + i));
      AssertJUnit.assertTrue(cc.isNA0(man.length + l));

      Chunk cc2 = cc.inflate_impl(new NewChunk(null, 0)).compress();
      AssertJUnit.assertEquals(man.length + 1 + l, cc.len());
      AssertJUnit.assertTrue(cc2 instanceof C1SChunk);
      if (l==1) AssertJUnit.assertTrue(cc2.isNA0(0));
      for (int i = 0; i < man.length; ++i)
        AssertJUnit.assertEquals((float) (man[i] * Math.pow(10, exp[i])), (float) cc2.at0(l + i));
      AssertJUnit.assertTrue(cc2.isNA0(man.length + l));

      AssertJUnit.assertTrue(Arrays.equals(cc._mem, cc2._mem));
    }
  }
}

@@ -373,19 +373,20 @@
 1%0A      
-int
+long
 %5B%5D man =
@@ -390,19 +390,20 @@
 n = new 
-int
+long
 %5B%5D%7B0, 2,
@@ -1408,24 +1408,1385 @@
 gth + l));%0A%0A
+      AssertJUnit.assertTrue(Arrays.equals(cc._mem, cc2._mem));%0A    %7D%0A  %7D%0A  @Test void test_inflate_impl2() %7B%0A    NewChunk nc = new NewChunk(null, 0);%0A%0A    for (int l=0; l%3C1; ++l) %7B%0A      // -22.8, 2, 0.3, 2.6, NA for l==0%0A      // NA, -22.8, 2, 0.3, 2.6, NA for l==0%0A      long%5B%5D man = new long%5B%5D%7B-228, 2, 3, 26%7D; //max range: 255 numbers in steps of 0.1 + NA%0A      int%5B%5D exp = new int%5B%5D%7B-1, 0, -1, -1%7D;%0A      if (l==1) nc.addNA();%0A      for (int i = 0; i %3C man.length; ++i) nc.addNum(man%5Bi%5D, exp%5Bi%5D);%0A      nc.addNA();%0A%0A      Chunk cc = nc.compress();%0A      AssertJUnit.assertEquals(man.length + 1 + l, cc.len());%0A      AssertJUnit.assertTrue(cc instanceof C1SChunk);%0A      if (l==1) AssertJUnit.assertTrue(cc.isNA0(0));%0A      for (int i = 0; i %3C man.length; ++i)%0A        AssertJUnit.assertEquals((float) (man%5Bi%5D * Math.pow(10, exp%5Bi%5D)), (float) cc.at0(l + i));%0A      AssertJUnit.assertTrue(cc.isNA0(man.length + l));%0A%0A      Chunk cc2 = cc.inflate_impl(new NewChunk(null, 0)).compress();%0A      AssertJUnit.assertEquals(man.length + 1 + l, cc.len());%0A      AssertJUnit.assertTrue(cc2 instanceof C1SChunk);%0A      if (l==1) AssertJUnit.assertTrue(cc2.isNA0(0));%0A      for (int i = 0; i %3C man.length; ++i)%0A        AssertJUnit.assertEquals((float) (man%5Bi%5D * Math.pow(10, exp%5Bi%5D)), (float) cc2.at0(l + i));%0A      AssertJUnit.assertTrue(cc2.isNA0(man.length + l));%0A%0A
       Assert

Add more tests for C1SChunk.