01: /*
02: * Copyright 2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.commons.math;
18:
19: import junit.framework.TestCase;
20:
21: /**
22: * @version $Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $
23: */
24: public class FunctionEvaluationExceptionTest extends TestCase {
25:
26: public void testConstructor() {
27: FunctionEvaluationException ex = new FunctionEvaluationException(
28: 0.0);
29: assertNull(ex.getCause());
30: assertNotNull(ex.getMessage());
31: assertEquals(0.0, ex.getArgument(), 0);
32: }
33:
34: public void testConstructorMessage() {
35: String msg = "message";
36: FunctionEvaluationException ex = new FunctionEvaluationException(
37: 0.0, msg);
38: assertNull(ex.getCause());
39: assertTrue(ex.getMessage().startsWith(msg));
40: assertTrue(ex.getMessage().indexOf("0") > 0);
41: assertEquals(0.0, ex.getArgument(), 0);
42: }
43:
44: public void testConstructorMessageCause() {
45: String outMsg = "outer message";
46: String inMsg = "inner message";
47: Exception cause = new Exception(inMsg);
48: FunctionEvaluationException ex = new FunctionEvaluationException(
49: 0, outMsg, cause);
50: assertTrue(ex.getMessage().startsWith(outMsg));
51: assertTrue(ex.getMessage().indexOf("0") > 0);
52: assertEquals(cause, ex.getCause());
53: assertEquals(0.0, ex.getArgument(), 0);
54: }
55: }
|