package org.bonej.ops.thresholdFraction;

import static org.junit.Assert.*;

/**
 * @author Richard Domander 
 */
public class SurfaceFractionTest {

}
@@ -46,106 +46,2472 @@
 ort 
-static org.junit.Assert.*;%0A%0A/**%0A * @author Richard Domander %0A */%0Apublic class SurfaceFractionTest %7B%0A
+net.imagej.ImageJ;%0Aimport net.imglib2.IterableInterval;%0Aimport org.bonej.ops.thresholdFraction.SurfaceFraction.Results;%0Aimport org.bonej.ops.thresholdFraction.SurfaceFraction.Settings;%0Aimport org.bonej.testImages.Cuboid;%0Aimport org.junit.AfterClass;%0Aimport org.junit.Test;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0A/**%0A * Tests for the %7B@link SurfaceFraction SurfaceFraction%7D class%0A *%0A * @author Richard Domander %0A */%0Apublic class SurfaceFractionTest %7B%0A    private final static ImageJ IMAGE_J = new ImageJ();%0A    private static final double DELTA = 1e-12;%0A%0A    @AfterClass%0A    public static void oneTimeTearDown() %7B%0A        IMAGE_J.context().dispose();%0A    %7D%0A%0A    /**%0A     * Test the volume calculation of SurfaceFraction with a 1x1x1 cube%0A     * %3Cp%3E%0A     * The surface created by the marching cubes algorithm in SurfaceFraction is %22in between pixels%22.%0A     * In the case of a unit cube it creates an octahedron,%0A     * whose vertices are in the middle of the faces of the cube.%0A     */%0A    @Test%0A    public void regressionTestUnitCube() throws AssertionError %7B%0A%0A        final long width = 1L;%0A        final long height = 1L;%0A        final long depth = 1L;%0A        final double a = width * 0.5;%0A        final double b = depth * 0.5;%0A        final double pyramidSide = Math.sqrt(a * a + b * b);%0A        final double pyramidVolume = pyramidSide * pyramidSide * (height / 2.0) / 3.0;%0A        final double thresholdVolume = pyramidVolume * 2.0;%0A        // Unit cube with 1 padding on each side, so 3x3x3 stack%0A        final IterableInterval unitCube = (IterableInterval) IMAGE_J.op().run(Cuboid.class, null, 1, 1, 1, 1, 1, 1);%0A        final Settings settings = new Settings(1.0, 1.0);%0A        /*%0A         * Each voxel in the surface is %22full%22 except for the 8 corners of the stack.%0A         * If the corner had two neighbors (x & y), the corner would be half a voxel.%0A         * Because it has three (x, y & z), a quarter of a pyramid is also added%0A         */%0A        final double totalVolume = 27.0 - 8.0 * 0.5 + pyramidVolume * 2;%0A%0A        final Results results = (Results) IMAGE_J.op().run(SurfaceFraction.class, unitCube, settings);%0A%0A        assertEquals(%22Incorrect threshold surface volume%22, thresholdVolume, results.thresholdSurfaceVolume, DELTA);%0A        assertEquals(%22Incorrect total surface volume%22, totalVolume, results.totalSurfaceVolume, DELTA);%0A        assertEquals(%22Incorrect volume ratio%22, thresholdVolume / totalVolume, results.ratio, DELTA);%0A    %7D
 %0A%7D

Add test