package ml.shifu.shifu.core;

import org.testng.Assert;
import org.testng.annotations.Test;

public class ConvergeJudgerTest {

    @Test
    public void testIsConverged() {
        double train_err = 1.0;
        double test_err = 3.0;
        double threshold1 = 1.0;
        double threshold2 = 2.0;
        double threshold3 = 3.0;
        
        Assert.assertFalse(ConvergeJudger.isConverged(train_err, test_err, threshold1));
        Assert.assertTrue(ConvergeJudger.isConverged(train_err, test_err, threshold2));
        Assert.assertTrue(ConvergeJudger.isConverged(train_err, test_err, threshold3));
        
    }
}

@@ -155,455 +155,1732 @@
 test
-IsConverged() %7B%0A        double train_err = 1.0;%0A        double test_err = 3.0;%0A        double threshold1 = 1.0;%0A        double threshold2 = 2.0;%0A        double threshold3 = 3.0;%0A        %0A        Assert.assertFalse(ConvergeJudger.isConverged(train_err, test_err, threshold1));%0A        Assert.assertTrue(ConvergeJudger.isConverged(train_err, test_err, threshold2));%0A        Assert.assertTrue(ConvergeJudger.isConverged(train_err, test_err, t
+Reset() %7B%0A        ConvergeJudger judger = new ConvergeJudger();%0A        judger.setTrainErr(1.0);%0A        judger.setTestErr(2.0);%0A        judger.setThreshold(3.0);%0A        %0A        judger.reset();%0A        Assert.assertTrue(judger.getTrainErr().compareTo(Double.POSITIVE_INFINITY) == 0);%0A        Assert.assertTrue(judger.getTestErr().compareTo(Double.POSITIVE_INFINITY) == 0);%0A        Assert.assertTrue(judger.getCurrentAvgErr().compareTo(Double.POSITIVE_INFINITY) == 0);%0A        Assert.assertTrue(judger.getThreshold().compareTo(Double.valueOf(0.0)) == 0);%0A    %7D%0A    %0A    @Test%0A    public void testIsConverged() %7B%0A        double train_err = 1.0;%0A        double test_err = 3.0;%0A        double threshold1 = 1.0;%0A        double threshold2 = 2.0;%0A        double threshold3 = 3.0;%0A        %0A        ConvergeJudger judger = new ConvergeJudger();%0A        judger.setTrainErr(train_err);%0A        judger.setTestErr(test_err);%0A        %0A        judger.setThreshold(threshold1);%0A        Assert.assertFalse(judger.isConverged());%0A        %0A        judger.setThreshold(threshold2);%0A        Assert.assertTrue(judger.isConverged());%0A        %0A        judger.setThreshold(threshold3);%0A        Assert.assertTrue(judger.isConverged());%0A        %0A        judger.setTrainErr(null);%0A        judger.setTestErr(0.0);%0A        Assert.assertFalse(judger.isConverged());%0A        Assert.assertTrue(judger.getCurrentAvgErr().compareTo(Double.POSITIVE_INFINITY) == 0);%0A        %0A        judger.setTrainErr(0.0);%0A        judger.setTestErr(null);%0A        Assert.assertFalse(judger.isConverged());%0A        Assert.assertTrue(judger.getCurrentAvgErr().compareTo(Double.POSITIVE_INFINITY) == 0);%0A        %0A        judger.setTestErr(0.00001);%0A        judger.setT
 hreshold
 3));
@@ -1875,18 +1875,21 @@
 hreshold
-3)
+(null
 );%0A     
@@ -1887,21 +1887,62 @@
 l);%0A        
+Assert.assertFalse(judger.isConverged());
 %0A    %7D%0A%7D%0A

add reset function test.