@@ -0,0 +1,1339 @@
+package com.yahoo.sketches.quantiles;%0A%0Aimport org.testng.Assert;%0Aimport org.testng.annotations.Test;%0A%0Aimport com.yahoo.memory.NativeMemory;%0A%0Apublic class DoublesSketchTest %7B%0A%0A  @Test%0A  public void heapToDirect() %7B%0A    DoublesSketch heapSketch = DoublesSketch.builder().build();%0A    for (int i = 0; i %3C 1000; i++) %7B%0A      heapSketch.update(i);%0A    %7D%0A    DoublesSketch directSketch = DoublesSketch.wrap(new NativeMemory(heapSketch.toByteArray()));%0A    for (int i = 0; i %3C 1000; i++) %7B%0A      directSketch.update(i + 1000);%0A    %7D%0A    Assert.assertEquals(directSketch.getMinValue(), 0);%0A    Assert.assertEquals(directSketch.getMaxValue(), 1999);%0A    Assert.assertEquals(directSketch.getQuantile(0.5), 1000.0, 10.0);%0A  %7D%0A%0A  @Test%0A  public void directToHeap() %7B%0A    int sizeBytes = 10000;%0A    DoublesSketch directSketch = DoublesSketch.builder().initMemory(new NativeMemory(new byte%5BsizeBytes%5D)).build();%0A    for (int i = 0; i %3C 1000; i++) %7B%0A      directSketch.update(i);%0A    %7D%0A    DoublesSketch heapSketch = DoublesSketch.heapify(new NativeMemory(directSketch.toByteArray()));%0A    for (int i = 0; i %3C 1000; i++) %7B%0A      heapSketch.update(i + 1000);%0A    %7D%0A    Assert.assertEquals(heapSketch.getMinValue(), 0.0);%0A    Assert.assertEquals(heapSketch.getMaxValue(), 1999.0);%0A    Assert.assertEquals(heapSketch.getQuantile(0.5), 1000.0, 10.0);%0A  %7D%0A%0A%7D%0A

test heap-to-direct and direct-to-heap conversions