1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.math.analysis;
19
20 import junit.framework.TestCase;
21
22
23
24
25 public class UnivariateRealSolverFactoryImplTest extends TestCase {
26
27
28 private UnivariateRealSolverFactory factory;
29
30
31 private DifferentiableUnivariateRealFunction function;
32
33
34
35
36 protected void setUp() throws Exception {
37 super.setUp();
38 factory = new UnivariateRealSolverFactoryImpl();
39 function = new SinFunction();
40 }
41
42
43
44
45
46 protected void tearDown() throws Exception {
47 factory = null;
48 function = null;
49 super.tearDown();
50 }
51
52 public void testNewBisectionSolverNull() {
53 try {
54 UnivariateRealSolver solver = factory.newBisectionSolver(null);
55 fail();
56 } catch(IllegalArgumentException ex) {
57
58 }
59 }
60
61 public void testNewBisectionSolverValid() {
62 UnivariateRealSolver solver = factory.newBisectionSolver(function);
63 assertNotNull(solver);
64 assertTrue(solver instanceof BisectionSolver);
65 }
66
67 public void testNewNewtonSolverNull() {
68 try {
69 UnivariateRealSolver solver = factory.newNewtonSolver(null);
70 fail();
71 } catch(IllegalArgumentException ex) {
72
73 }
74 }
75
76 public void testNewNewtonSolverValid() {
77 UnivariateRealSolver solver = factory.newNewtonSolver(function);
78 assertNotNull(solver);
79 assertTrue(solver instanceof NewtonSolver);
80 }
81
82 public void testNewBrentSolverNull() {
83 try {
84 UnivariateRealSolver solver = factory.newBrentSolver(null);
85 fail();
86 } catch(IllegalArgumentException ex) {
87
88 }
89 }
90
91 public void testNewBrentSolverValid() {
92 UnivariateRealSolver solver = factory.newBrentSolver(function);
93 assertNotNull(solver);
94 assertTrue(solver instanceof BrentSolver);
95 }
96
97 public void testNewSecantSolverNull() {
98 try {
99 UnivariateRealSolver solver = factory.newSecantSolver(null);
100 fail();
101 } catch(IllegalArgumentException ex) {
102
103 }
104 }
105
106 public void testNewSecantSolverValid() {
107 UnivariateRealSolver solver = factory.newSecantSolver(function);
108 assertNotNull(solver);
109 assertTrue(solver instanceof SecantSolver);
110 }
111 }