1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * 
4    * Copyright (C) 1999-2006, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.classic.control;
11  
12  import org.junit.Test;
13  import static org.junit.Assert.assertTrue;
14  
15  public class RandomUtilTest {
16  
17    @Test
18    public void testGaussian() {
19  
20      long sum = 0;
21      int len = 100000;
22      int AVERAGE = 5;
23      for(int i = 0; i < len; i++) {
24        sum += ScenarioRandomUtil.gaussianAsPositiveInt(AVERAGE, 2);
25      }
26  
27      double resultingAverage =   sum/(1.0*len);
28      //System.out.println("Resulting average is "+resultingAverage);
29  
30      assertTrue("Expected "+AVERAGE+" but got "+resultingAverage, Math.abs(resultingAverage-AVERAGE)<0.1);
31    }
32  }