Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv27230/src/test/net/sf/tail/indicator
Added Files:
HighestValueIndicatorTest.java LowestValueIndicatorTest.java
Log Message:
Classes de teste para o HighestValue e LowestValue.
--- NEW FILE: HighestValueIndicatorTest.java ---
package net.sf.tail.indicator;
import static org.junit.Assert.assertEquals;
import junit.framework.JUnit4TestAdapter;
import net.sf.tail.SampleTimeSeries;
import net.sf.tail.TimeSeries;
import net.sf.tail.indicator.simple.ClosePriceIndicator;
import net.sf.tail.indicator.tracker.HighestValueIndicator;
import org.junit.Before;
import org.junit.Test;
public class HighestValueIndicatorTest {
private TimeSeries data;
@Before
public void prepare() throws Exception {
data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 6, 4, 3, 3, 4, 3, 2 });
}
@Test
public void testAverageGain5() throws Exception {
HighestValueIndicator highestValue = new HighestValueIndicator(new ClosePriceIndicator(data), 5);
assertEquals(4d, highestValue.getValue(5), 0.01);
assertEquals(5d, highestValue.getValue(6), 0.01);
assertEquals(6d, highestValue.getValue(7), 0.01);
assertEquals(6d, highestValue.getValue(8), 0.01);
assertEquals(6d, highestValue.getValue(9), 0.01);
assertEquals(6d, highestValue.getValue(10), 0.01);
assertEquals(6d, highestValue.getValue(11), 0.01);
assertEquals(6d, highestValue.getValue(12), 0.01);
assertEquals(4d, highestValue.getValue(13), 0.01);
}
@Test
public void test10daysJumping() {
HighestValueIndicator highestValue = new HighestValueIndicator(new ClosePriceIndicator(data), 5);
assertEquals(6, highestValue.getValue(12), 0.01);
}
@Test(expected = IndexOutOfBoundsException.class)
public void testWrongIndex() {
HighestValueIndicator highestValue = new HighestValueIndicator(new ClosePriceIndicator(data), 5);
assertEquals(3d, highestValue.getValue(300));
}
// Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux)
//e o JUnit4
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(RSIIndicatorTest.class);
}
}
--- NEW FILE: LowestValueIndicatorTest.java ---
package net.sf.tail.indicator;
import static org.junit.Assert.assertEquals;
import junit.framework.JUnit4TestAdapter;
import net.sf.tail.SampleTimeSeries;
import net.sf.tail.TimeSeries;
import net.sf.tail.indicator.simple.ClosePriceIndicator;
import net.sf.tail.indicator.tracker.LowestValueIndicator;
import org.junit.Before;
import org.junit.Test;
public class LowestValueIndicatorTest {
private TimeSeries data;
@Before
public void prepare() throws Exception {
data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 6, 4, 3, 2, 4, 3, 1 });
}
@Test
public void testAverageGain5() throws Exception {
LowestValueIndicator lowestValue = new LowestValueIndicator(new ClosePriceIndicator(data), 5);
assertEquals(1d, lowestValue.getValue(5), 0.01);
assertEquals(2d, lowestValue.getValue(6), 0.01);
assertEquals(3d, lowestValue.getValue(7), 0.01);
assertEquals(3d, lowestValue.getValue(8), 0.01);
assertEquals(3d, lowestValue.getValue(9), 0.01);
assertEquals(2d, lowestValue.getValue(10), 0.01);
assertEquals(2d, lowestValue.getValue(11), 0.01);
assertEquals(2d, lowestValue.getValue(12), 0.01);
assertEquals(1d, lowestValue.getValue(13), 0.01);
}
@Test
public void test10daysJumping() {
LowestValueIndicator lowestValue = new LowestValueIndicator(new ClosePriceIndicator(data), 5);
assertEquals(2d, lowestValue.getValue(10), 0.01);
}
@Test(expected = IndexOutOfBoundsException.class)
public void testWrongIndex() {
LowestValueIndicator lowestValue = new LowestValueIndicator(new ClosePriceIndicator(data), 5);
assertEquals(3d, lowestValue.getValue(300));
}
// Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux)
//e o JUnit4
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(RSIIndicatorTest.class);
}
}
|