package cs437.som.neighborhood;

import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

public class ExponentialDecayNeighborhoodWidthTest {
    private static final double MAXIMUM_DIFFERENCE = 0.0000000000000001;
    private static final int ITERATIONS = 1000;
    private static final double WIDTH = 1.0;

    @Test
    public void testNeighborhoodWidth() throws Exception {
        ExponentialDecayNeighborhoodWidth ednwf =
                new ExponentialDecayNeighborhoodWidth(WIDTH);
        ednwf.setExpectedIterations(ITERATIONS);

        double last = ednwf.neighborhoodWidth(1);
        for (int i = 2; i < ITERATIONS; i += 10) {
            double current = ednwf.neighborhoodWidth(i);
            assertTrue(current < last, "Should consistently decay.");
            last = current;
        }

        assertEquals(ednwf.neighborhoodWidth(0), WIDTH, MAXIMUM_DIFFERENCE);
        for (int i = 1; i < ITERATIONS; i++) {
            assertTrue(ednwf.neighborhoodWidth(i) < WIDTH - (i / ITERATIONS),
                    "Exponential decay should be less than linear.");
        }

        for (int i = 0; i < ITERATIONS; i++) {
            assertEquals(ednwf.neighborhoodWidth(i), Math.exp(-(double)i / ITERATIONS),
                    MAXIMUM_DIFFERENCE, String.format("it: %d", i));
        }
    }
}

@@ -26,16 +26,58 @@
 rhood;%0A%0A
+import org.testng.annotations.BeforeTest;%0A
 import o
@@ -424,137 +424,108 @@
     
-@Test%0A    public void testNeighborhoodWidth() throws Exception %7B%0A        ExponentialDecayNeighborhoodWidth ednwf =%0A      
+private ExponentialDecayNeighborhoodWidth ednwf;%0A%0A    @BeforeTest%0A    public void setUp() %7B%0A
         
   ne
@@ -520,17 +520,23 @@
         
- 
+ednwf =
  new Exp
@@ -623,16 +623,89 @@
 TIONS);%0A
+    %7D%0A%0A    @Test%0A    public void testConsistentDecay() throws Exception %7B
 %0A       
@@ -967,85 +967,67 @@
   %7D%0A
-%0A
     
+%7D%0A%0A
     
-assertEquals(ednwf.neighborhoodWidth(0), WIDTH, MAXIMUM_DIFFERENCE);
+@Test%0A    public void testByDirectComparison() %7B
 %0A   
@@ -1044,17 +1044,17 @@
 int i = 
-1
+0
 ; i %3C IT
@@ -1088,20 +1088,22 @@
   assert
-True
+Equals
 (ednwf.n
@@ -1125,36 +1125,85 @@
 h(i)
- %3C WIDTH - (i / ITERATIONS),
+,%0A                    Math.exp(-(double)i / ITERATIONS), MAXIMUM_DIFFERENCE);
 %0A   
@@ -1211,69 +1211,65 @@
     
+%7D%0A
     
+%7D%0A%0A
     
-    %22Exponential decay should be less than l
+@Test%0A    public void testLessThanL
 inear
-.%22);
+() %7B
 %0A   
@@ -1269,26 +1269,92 @@
 ) %7B%0A        
-%7D%0A
+assertEquals(ednwf.neighborhoodWidth(0), WIDTH, MAXIMUM_DIFFERENCE);
 %0A        for
@@ -1355,33 +1355,33 @@
    for (int i = 
-0
+1
 ; i %3C ITERATIONS
@@ -1399,38 +1399,36 @@
           assert
-Equals
+True
 (ednwf.neighborh
@@ -1442,28 +1442,20 @@
 h(i)
-, Math.exp(-(double)
+ %3C WIDTH - (
 i / 
@@ -1491,54 +1491,55 @@
     
-MAXIMUM_DIFFERENCE, String.format(%22it: %25d%22, i)
+%22Exponential decay should be less than linear.%22
 );%0A 

Split tests into seperate methods in ExponentialDecayNeighborhoodWidthTest.