|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 01:07:48
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21729/src/test/net/sf/tail/indicator Modified Files: SMAIndicatorTest.java StandardDeviationIndicatorTest.java HighestValueIndicatorTest.java WilliamsRIndicatorTest.java AverageLossIndicatorTest.java LowestValueIndicatorTest.java Removed Files: CachedIndicatorTest.java Log Message: refatoração de código (control + shift + f) Index: AverageLossIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/AverageLossIndicatorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AverageLossIndicatorTest.java 17 May 2007 23:04:57 -0000 1.4 --- AverageLossIndicatorTest.java 18 May 2007 01:07:44 -0000 1.5 *************** *** 17,21 **** @Before ! public void prepare() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } --- 17,21 ---- @Before ! public void setUp() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } Index: WilliamsRIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/WilliamsRIndicatorTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WilliamsRIndicatorTest.java 17 May 2007 23:04:57 -0000 1.3 --- WilliamsRIndicatorTest.java 18 May 2007 01:07:44 -0000 1.4 *************** *** 20,24 **** @Before ! public void prepare() throws Exception { List<Tick> ticks = new ArrayList<Tick>(); --- 20,24 ---- @Before ! public void setUp() throws Exception { List<Tick> ticks = new ArrayList<Tick>(); --- CachedIndicatorTest.java DELETED --- Index: LowestValueIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/LowestValueIndicatorTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LowestValueIndicatorTest.java 17 May 2007 23:04:57 -0000 1.2 --- LowestValueIndicatorTest.java 18 May 2007 01:07:44 -0000 1.3 *************** *** 13,25 **** 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); --- 13,25 ---- public class LowestValueIndicatorTest { ! private TimeSeries data; ! @Before ! public void setUp() 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); *************** *** 34,39 **** assertEquals(2d, lowestValue.getValue(12), 0.01); ! } ! @Test public void test10daysJumping() { --- 34,39 ---- assertEquals(2d, lowestValue.getValue(12), 0.01); ! } ! @Test public void test10daysJumping() { *************** *** 48,53 **** } ! // 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); --- 48,54 ---- } ! // 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); Index: StandardDeviationIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/StandardDeviationIndicatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StandardDeviationIndicatorTest.java 17 May 2007 21:29:16 -0000 1.1 --- StandardDeviationIndicatorTest.java 18 May 2007 01:07:44 -0000 1.2 *************** *** 12,67 **** public class StandardDeviationIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 0, 9 }); ! } ! @Test ! public void testStandardDeviation4() throws Exception { ! StandardDeviationIndicator sdv = new StandardDeviationIndicator(new ClosePriceIndicator(data), 4); ! assertEquals(0d, sdv.getValue(0), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(1), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(2), 0.1); ! assertEquals(Math.sqrt(5.0), sdv.getValue(3), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(4), 0.1); ! assertEquals(1, sdv.getValue(5), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(6), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(7), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(8), 0.1); ! assertEquals(Math.sqrt(14.0), sdv.getValue(9), 0.1); ! assertEquals(Math.sqrt(42.0), sdv.getValue(10), 0.1); ! ! } ! ! @Test ! public void testStandardDeviation2() throws Exception { ! StandardDeviationIndicator sdv = new StandardDeviationIndicator(new ClosePriceIndicator(data), 2); ! assertEquals(0d, sdv.getValue(0), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(1), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(2), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(3), 0.1); ! assertEquals(Math.sqrt(4.5), sdv.getValue(9), 0.1); ! assertEquals(Math.sqrt(40.5), sdv.getValue(10), 0.1); ! ! } ! ! ! ! @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { ! StandardDeviationIndicator quoteSDV = new StandardDeviationIndicator(new ClosePriceIndicator(data), 3); ! quoteSDV.getValue(13); ! } ! ! // 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(StandardDeviationIndicatorTest.class); } } --- 12,64 ---- public class StandardDeviationIndicatorTest { ! private TimeSeries data; ! @Before ! public void setUp() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 0, 9 }); ! } ! @Test ! public void testStandardDeviation4() throws Exception { ! StandardDeviationIndicator sdv = new StandardDeviationIndicator(new ClosePriceIndicator(data), 4); ! assertEquals(0d, sdv.getValue(0), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(1), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(2), 0.1); ! assertEquals(Math.sqrt(5.0), sdv.getValue(3), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(4), 0.1); ! assertEquals(1, sdv.getValue(5), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(6), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(7), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(8), 0.1); ! assertEquals(Math.sqrt(14.0), sdv.getValue(9), 0.1); ! assertEquals(Math.sqrt(42.0), sdv.getValue(10), 0.1); ! } ! @Test ! public void testStandardDeviation2() throws Exception { ! StandardDeviationIndicator sdv = new StandardDeviationIndicator(new ClosePriceIndicator(data), 2); ! assertEquals(0d, sdv.getValue(0), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(1), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(2), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(3), 0.1); ! assertEquals(Math.sqrt(4.5), sdv.getValue(9), 0.1); ! assertEquals(Math.sqrt(40.5), sdv.getValue(10), 0.1); ! ! } ! ! @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { ! StandardDeviationIndicator quoteSDV = new StandardDeviationIndicator(new ClosePriceIndicator(data), 3); ! quoteSDV.getValue(13); ! } ! ! // 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(StandardDeviationIndicatorTest.class); } } Index: SMAIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/SMAIndicatorTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SMAIndicatorTest.java 17 May 2007 23:04:57 -0000 1.5 --- SMAIndicatorTest.java 18 May 2007 01:07:44 -0000 1.6 *************** *** 1,6 **** package net.sf.tail.indicator; ! import java.util.Arrays; ! import net.sf.tail.SampleTimeSeries; import net.sf.tail.TimeSeries; --- 1,6 ---- 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; *************** *** 8,17 **** import net.sf.tail.indicator.tracker.SMAIndicator; - import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; - import junit.framework.JUnit4TestAdapter; - public class SMAIndicatorTest { --- 8,14 ---- *************** *** 19,23 **** @Before ! public void prepare() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } --- 16,20 ---- @Before ! public void setUp() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } *************** *** 49,61 **** } - @Test - public void testIncreaseArrayMethod() { - double[] d = new double[200]; - Arrays.fill(d, 10); - TimeSeries dataMax = new SampleTimeSeries(d); - SMAIndicator quoteSMA = new SMAIndicator(new ClosePriceIndicator(dataMax), 100); - assertEquals(10d, quoteSMA.getValue(105)); - } - @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { --- 46,49 ---- Index: HighestValueIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/HighestValueIndicatorTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HighestValueIndicatorTest.java 17 May 2007 23:04:57 -0000 1.2 --- HighestValueIndicatorTest.java 18 May 2007 01:07:44 -0000 1.3 *************** *** 13,25 **** 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); --- 13,25 ---- public class HighestValueIndicatorTest { ! private TimeSeries data; ! @Before ! public void setUp() 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); *************** *** 34,39 **** assertEquals(4d, highestValue.getValue(12), 0.01); ! } ! @Test public void test10daysJumping() { --- 34,39 ---- assertEquals(4d, highestValue.getValue(12), 0.01); ! } ! @Test public void test10daysJumping() { *************** *** 48,53 **** } ! // 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); --- 48,54 ---- } ! // 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); |