@@ -8,18 +8,37 @@ public class LinearInterpolationTest {
88
99 @ Test
1010 public void testSimpleLinearInterpolation () {
11- LinearInterpolation lInterp = new LinearInterpolation ("src /test/resources/LinearInterpolData1.csv" );
11+ LinearInterpolation lInterp = new LinearInterpolation ("../.. /test/resources/LinearInterpolData1.csv" );
1212 assertEquals (3 , lInterp .calculate (3 ), 0.01 );
1313
14- lInterp = new LinearInterpolation ("src /test/resources/LinearInterpolData2.csv" );
14+ lInterp = new LinearInterpolation ("../.. /test/resources/LinearInterpolData2.csv" );
1515 assertEquals (3 , lInterp .calculate (3 ), 0.01 );
1616 }
1717
1818 @ Test
1919 public void testLinearInterpolation () {
20- LinearInterpolation lInterp = new LinearInterpolation ("src /test/resources/LinearInterpolData3.csv" );
20+ LinearInterpolation lInterp = new LinearInterpolation ("../.. /test/resources/LinearInterpolData3.csv" );
2121 assertEquals (2 , lInterp .calculate (2 ), 0.01 );
2222 assertEquals (3.5 , lInterp .calculate (4 ), 0.01 );
2323 }
2424
25+ @ Test
26+ public void testNegativeSlopeLinearInterpolation () {
27+ LinearInterpolation lInterp = new LinearInterpolation ("../../test/resources/LinearInterpolData4.csv" );
28+ assertEquals (0.75 , lInterp .calculate (0.25 ), 0.01 );
29+ assertEquals (0.25 , lInterp .calculate (0.75 ), 0.01 );
30+ }
31+
32+ @ Test
33+ public void testPiecewiseLinearInterpolation () {
34+ LinearInterpolation lInterp = new LinearInterpolation ("../../test/resources/LinearInterpolData5.csv" );
35+ assertEquals (1 , lInterp .calculate (0 ), 0.01 );
36+ assertEquals (0.75 , lInterp .calculate (0.25 ), 0.01 );
37+ assertEquals (0.25 , lInterp .calculate (0.75 ), 0.01 );
38+ assertEquals (0 , lInterp .calculate (1 ), 0.01 );
39+ assertEquals (0.25 , lInterp .calculate (1.25 ), 0.01 );
40+ assertEquals (0.75 , lInterp .calculate (1.75 ), 0.01 );
41+ assertEquals (1 , lInterp .calculate (2 ), 0.01 );
42+ }
43+
2544}
0 commit comments