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