01: /**
02: * <copyright>
03: * Copyright 1997-2002 BBNT Solutions, LLC
04: * under sponsorship of the Defense Advanced Research Projects Agency (DARPA).
05: *
06: * This program is free software; you can redistribute it and/or modify
07: * it under the terms of the Cougaar Open Source License as published by
08: * DARPA on the Cougaar Open Source Website (www.cougaar.org).
09: *
10: * THE COUGAAR SOFTWARE AND ANY DERIVATIVE SUPPLIED BY LICENSOR IS
11: * PROVIDED 'AS IS' WITHOUT WARRANTIES OF ANY KIND, WHETHER EXPRESS OR
12: * IMPLIED, INCLUDING (BUT NOT LIMITED TO) ALL IMPLIED WARRANTIES OF
13: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND WITHOUT
14: * ANY WARRANTIES AS TO NON-INFRINGEMENT. IN NO EVENT SHALL COPYRIGHT
15: * HOLDER BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT OR CONSEQUENTIAL
16: * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE OF DATA OR PROFITS,
17: * TORTIOUS CONDUCT, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18: * PERFORMANCE OF THE COUGAAR SOFTWARE.
19: * </copyright>
20: *
21: * Created on Aug 26, 2002
22: */package test.net.sourceforge.pmd.stat;
23:
24: import static org.junit.Assert.assertEquals;
25:
26: import org.junit.Test;
27:
28: import net.sourceforge.pmd.stat.Metric;
29:
30: import java.util.Random;
31:
32: /**
33: * @author David Dixon-Peugh
34: */
35: public class MetricTest {
36: private String testName = "";
37: private Random random = new Random();
38:
39: @Test
40: public void testGetMetricName() {
41: Metric IUT = new Metric(testName, 0, 0.0, 0.0, 0.0, 0.0, 0.0);
42:
43: assertEquals(testName, IUT.getMetricName());
44: }
45:
46: @Test
47: public void testGetCount() {
48: int count = random.nextInt();
49: Metric IUT = new Metric(testName, count, 0.0, 0.0, 0.0, 0.0,
50: 0.0);
51: assertEquals(count, IUT.getCount());
52: }
53:
54: @Test
55: public void testGetTotal() {
56: double total = random.nextDouble();
57: Metric IUT = new Metric(testName, 0, total, 0.0, 0.0, 0.0, 0.0);
58: assertEquals(total, IUT.getTotal(), 0.05);
59: }
60:
61: @Test
62: public void testGetLowValue() {
63: double low = random.nextDouble();
64: Metric IUT = new Metric(testName, 0, 0.0, low, 0.0, 0.0, 0.0);
65: assertEquals(low, IUT.getLowValue(), 0.05);
66: }
67:
68: @Test
69: public void testGetHighValue() {
70: double high = random.nextDouble();
71: Metric IUT = new Metric(testName, 0, 0.0, 0.0, high, 0.0, 0.0);
72: assertEquals(high, IUT.getHighValue(), 0.05);
73: }
74:
75: @Test
76: public void testGetAverage() {
77: double mean = random.nextDouble();
78: Metric IUT = new Metric(testName, 0, 0.0, 0.0, 0.0, mean, 0.0);
79: assertEquals(mean, IUT.getAverage(), 0.05);
80: }
81:
82: @Test
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: public static junit.framework.Test suite() {
90: return new junit.framework.JUnit4TestAdapter(MetricTest.class);
91: }
92: }
|