1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.jstats.math;
11
12 import junit.framework.Assert;
13 import junit.framework.TestCase;
14
15 /***
16 * The test script for the ProbMath class.
17 * <p>
18 * (c) copyright 2003-2004 <a href="http://www.simulation.tudelft.nl">Delft
19 * University of Technology </a>, the Netherlands. <br>
20 * See for project information <a
21 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
22 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
23 * License (GPL) </a>, no warranty <br>
24 *
25 * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
26 * Jacobs </a>
27 * @version 1.0, 2004-03-18
28 * @since 1.2
29 */
30 public class ProbMathTest extends TestCase
31 {
32 /*** TEST_METHOD is the name of the test method */
33 public static final String TEST_METHOD = "test";
34
35 /***
36 * constructs a new EventIteratorTest.
37 */
38 public ProbMathTest()
39 {
40 this(TEST_METHOD);
41 }
42
43 /***
44 * constructs a new EventIteratorTest
45 *
46 * @param method the name of the test method
47 */
48 public ProbMathTest(final String method)
49 {
50 super(method);
51 }
52
53 /***
54 * tests the classes in the reference class.
55 */
56 public void test()
57 {
58
59 try
60 {
61 ProbMath.faculty(-1);
62 Assert.fail();
63 } catch (Exception exception)
64 {
65 Assert.assertEquals(exception.getClass(),
66 IllegalArgumentException.class);
67 }
68 Assert.assertTrue(ProbMath.faculty(0) == 1.0);
69 Assert.assertTrue(ProbMath.faculty(10) == 3628800.0);
70 try
71 {
72 ProbMath.faculty(171);
73 Assert.fail();
74 } catch (Exception exception)
75 {
76 Assert.assertEquals(exception.getClass(),
77 IllegalArgumentException.class);
78 }
79
80
81 try
82 {
83 ProbMath.permutations(2, 5);
84 } catch (Exception exception)
85 {
86 Assert.assertEquals(exception.getClass(),
87 IllegalArgumentException.class);
88 }
89 }
90 }