KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > tests > EngineerTest


1 package JSci.tests;
2
3 import java.util.Map JavaDoc;
4 import java.util.HashMap JavaDoc;
5 import junit.framework.*;
6 import JSci.maths.*;
7
8 /**
9 * Testcase for Engineer methods.
10 * @author Mark Hale
11 */

12 public class EngineerTest extends TestCase {
13     private static final int N=127;
14     private double[] signal = FourierTest.gaussian(N, 1.0, 8.0);
15
16     public static void main(String JavaDoc arg[]) {
17                 junit.textui.TestRunner.run(EngineerTest.class);
18         }
19         public EngineerTest(String JavaDoc name) {
20                 super(name);
21         }
22         protected void setUp() throws Exception JavaDoc {
23                 JSci.GlobalSettings.ZERO_TOL=1.0e-10;
24         }
25     public void testResample() {
26         double[] resample = EngineerMath.resample(signal, N);
27         for(int i=0; i<N; i++)
28             assertEquals(signal[i], resample[i], JSci.GlobalSettings.ZERO_TOL);
29
30         resample = EngineerMath.resample(signal, (N+1)/2);
31         for(int i=0; i<(N+1)/2; i++)
32             assertEquals(signal[2*i], resample[i], JSci.GlobalSettings.ZERO_TOL);
33
34         resample = EngineerMath.resample(signal, 2*N-1);
35         for(int i=0; i<N; i++)
36             assertEquals(signal[i], resample[2*i], JSci.GlobalSettings.ZERO_TOL);
37         }
38 }
39
Popular Tags