KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > easymock > tests > UsageFloatingPointReturnValueTest


1 /*
2  * Copyright (c) 2001-2005 OFFIS. This program is made available under the terms of
3  * the MIT License.
4  */

5 package org.easymock.tests;
6
7 import junit.framework.TestCase;
8
9 import org.easymock.MockControl;
10
11 public class UsageFloatingPointReturnValueTest extends TestCase {
12     MockControl<IMethods> control;
13
14     IMethods mock;
15
16     public UsageFloatingPointReturnValueTest(String JavaDoc name) {
17         super(name);
18     }
19
20     protected void setUp() {
21         control = MockControl.createControl(IMethods.class);
22         mock = control.getMock();
23     }
24
25     public void testReturnFloat() {
26         mock.floatReturningMethod(0);
27         control.setReturnValue(25.0F);
28         control.setDefaultReturnValue(34.0F);
29
30         control.replay();
31
32         assertEquals(25.0F, mock.floatReturningMethod(0), 0.0F);
33         assertEquals(34.0F, mock.floatReturningMethod(-4), 0.0F);
34         assertEquals(34.0F, mock.floatReturningMethod(12), 0.0F);
35
36         control.verify();
37     }
38
39     public void testReturnDouble() {
40         mock.doubleReturningMethod(0);
41         control.setReturnValue(25.0);
42         control.setDefaultReturnValue(34.0);
43
44         control.replay();
45
46         assertEquals(25.0, mock.doubleReturningMethod(0), 0.0);
47         assertEquals(34.0, mock.doubleReturningMethod(-4), 0.0);
48         assertEquals(34.0, mock.doubleReturningMethod(12), 0.0);
49
50         control.verify();
51     }
52 }
53
Popular Tags