create changelog entry
[debian/openrocket] / core / test / net / sf / openrocket / util / LinearInterpolatorTest.java
1 package net.sf.openrocket.util;
2
3 import static org.junit.Assert.*;
4 import org.junit.Test;
5
6 public class LinearInterpolatorTest {
7
8         @Test
9         public void oldMainTest() {
10                 LinearInterpolator interpolator = new LinearInterpolator(
11                                 new double[] {1, 1.5, 2, 4, 5},
12                                 new double[] {0, 1,   0, 2, 2}
13                 );
14                 
15                 double[] answer = new double[] {
16                                 /* x=0 */ 0.00, 0.00, 0.00,     0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
17                                 /* x=1 */ 0.00, 0.20, 0.40, 0.60, 0.80, 1.00, 0.80, 0.60, 0.40, 0.20,
18                                 /* x=2 */ 0.00, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90,
19                                 /* x=3 */ 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90,
20                                 /* x=4 */ 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00,
21                                 /* x=5 */ 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00,
22                                 /* x=6 */ 2.00
23                 };
24                 
25                 double x = 0;
26                 for (int i=0; i < answer.length; i++) {
27                         assertEquals( "Answer wrong for x = " + x , answer[i], interpolator.getValue(x), 0.01 );
28                         x+= 0.1;
29                 }
30
31         }
32 }