SuperX-Kernmodul
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1.7 KiB

package de.memtext.stat;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collection;
import java.util.Vector;
import org.junit.Test;
/**
* Class to test {@link de.memtext.stat.Statistics}
* @author hiber
*/
public class StatisticsTest {
private final int DELTA = 0;
@Test
@SuppressWarnings({ "deprecation", "static-method" })
public void testGetAverageFromCollection() {
double expected = 4.0;
Collection<Integer> numbers = Arrays.asList(Integer.valueOf(0),
Integer.valueOf(2),
Integer.valueOf(4),
Integer.valueOf(6),
Integer.valueOf(8));
double actualAverage = Statistics.getAverage(numbers);
assertEquals("Average calculated as expected", expected, actualAverage, this.DELTA);
}
@Test
@SuppressWarnings({ "deprecation", "static-method" })
public void testGetAverageFromVector() {
double expected = 4.0;
Vector<Integer> numbers = new Vector<>(Arrays.asList(Integer.valueOf(0),
Integer.valueOf(2),
Integer.valueOf(4),
Integer.valueOf(6),
Integer.valueOf(8)));
double actualAverage = Statistics.getAverage(numbers);
assertEquals("Average calculated as expected", expected, actualAverage, this.DELTA);
}
}