| 1 23 package test.net.sourceforge.pmd.stat; 24 25 import junit.framework.TestCase; 26 import net.sourceforge.pmd.stat.Metric; 27 28 import java.util.Random ; 29 30 33 public class MetricTest extends TestCase { 34 private String testName = null; 35 private Random random = new Random (); 36 37 42 public MetricTest(String arg0) { 43 super(arg0); 44 this.testName = arg0; 45 } 46 47 public void testGetMetricName() { 48 Metric IUT = new Metric(testName, 0, 0.0, 0.0, 0.0, 0.0, 0.0); 49 50 assertEquals(testName, IUT.getMetricName()); 51 } 52 53 public void testGetCount() { 54 int count = random.nextInt(); 55 Metric IUT = new Metric(testName, count, 0.0, 0.0, 0.0, 0.0, 0.0); 56 assertEquals(count, IUT.getCount()); 57 } 58 59 public void testGetTotal() { 60 double total = random.nextDouble(); 61 Metric IUT = new Metric(testName, 0, total, 0.0, 0.0, 0.0, 0.0); 62 assertEquals(total, IUT.getTotal(), 0.05); 63 } 64 65 public void testGetLowValue() { 66 double low = random.nextDouble(); 67 Metric IUT = new Metric(testName, 0, 0.0, low, 0.0, 0.0, 0.0); 68 assertEquals(low, IUT.getLowValue(), 0.05); 69 } 70 71 public void testGetHighValue() { 72 double high = random.nextDouble(); 73 Metric IUT = new Metric(testName, 0, 0.0, 0.0, high, 0.0, 0.0); 74 assertEquals(high, IUT.getHighValue(), 0.05); 75 } 76 77 public void testGetAverage() { 78 double mean = random.nextDouble(); 79 Metric IUT = new Metric(testName, 0, 0.0, 0.0, 0.0, mean, 0.0); 80 assertEquals(mean, IUT.getAverage(), 0.05); 81 } 82 83 public void testGetStandardDeviation() { 84 double stdev = random.nextDouble(); 85 Metric IUT = new Metric(testName, 0, 0.0, 0.0, 0.0, 0.0, stdev); 86 assertEquals(stdev, IUT.getStandardDeviation(), 0.05); 87 } 88 89 } 90 | Popular Tags |