1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sourceforge.pmd.stat;
24
25 import static org.junit.Assert.assertEquals;
26
27 import java.util.Random;
28
29 import org.junit.Test;
30
31
32
33 public class MetricTest {
34 private String testName = "";
35 private Random random = new Random();
36
37 @Test
38 public void testGetMetricName() {
39 Metric IUT = new Metric(testName, 0, 0.0, 0.0, 0.0, 0.0, 0.0);
40
41 assertEquals(testName, IUT.getMetricName());
42 }
43
44 @Test
45 public void testGetCount() {
46 int count = random.nextInt();
47 Metric IUT = new Metric(testName, count, 0.0, 0.0, 0.0, 0.0, 0.0);
48 assertEquals(count, IUT.getCount());
49 }
50
51 @Test
52 public void testGetTotal() {
53 double total = random.nextDouble();
54 Metric IUT = new Metric(testName, 0, total, 0.0, 0.0, 0.0, 0.0);
55 assertEquals(total, IUT.getTotal(), 0.05);
56 }
57
58 @Test
59 public void testGetLowValue() {
60 double low = random.nextDouble();
61 Metric IUT = new Metric(testName, 0, 0.0, low, 0.0, 0.0, 0.0);
62 assertEquals(low, IUT.getLowValue(), 0.05);
63 }
64
65 @Test
66 public void testGetHighValue() {
67 double high = random.nextDouble();
68 Metric IUT = new Metric(testName, 0, 0.0, 0.0, high, 0.0, 0.0);
69 assertEquals(high, IUT.getHighValue(), 0.05);
70 }
71
72 @Test
73 public void testGetAverage() {
74 double mean = random.nextDouble();
75 Metric IUT = new Metric(testName, 0, 0.0, 0.0, 0.0, mean, 0.0);
76 assertEquals(mean, IUT.getAverage(), 0.05);
77 }
78
79 @Test
80 public void testGetStandardDeviation() {
81 double stdev = random.nextDouble();
82 Metric IUT = new Metric(testName, 0, 0.0, 0.0, 0.0, 0.0, stdev);
83 assertEquals(stdev, IUT.getStandardDeviation(), 0.05);
84 }
85
86 public static junit.framework.Test suite() {
87 return new junit.framework.JUnit4TestAdapter(MetricTest.class);
88 }
89 }