1 /***
2 * <copyright>
3 * Copyright 1997-2002 BBNT Solutions, LLC
4 * under sponsorship of the Defense Advanced Research Projects Agency (DARPA).
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the Cougaar Open Source License as published by
8 * DARPA on the Cougaar Open Source Website (www.cougaar.org).
9 *
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 */
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 /***
31 * @author David Dixon-Peugh
32 */
33 public class MetricTest extends TestCase {
34 private String testName = null;
35 private Random random = new Random();
36
37 /***
38 * Constructor for MetricTest.
39 * @param arg0
40 */
41 public MetricTest(String arg0) {
42 super(arg0);
43 this.testName = arg0;
44 }
45
46 public void testGetMetricName() {
47 Metric IUT = new Metric(testName, 0, 0.0, 0.0, 0.0, 0.0, 0.0);
48
49 assertEquals(testName, IUT.getMetricName());
50 }
51
52 public void testGetCount() {
53 int count = random.nextInt();
54 Metric IUT = new Metric(testName, count, 0.0, 0.0, 0.0, 0.0, 0.0);
55 assertEquals(count, IUT.getCount());
56 }
57
58 public void testGetTotal() {
59 double total = random.nextDouble();
60 Metric IUT = new Metric(testName, 0, total, 0.0, 0.0, 0.0, 0.0);
61 assertEquals(total, IUT.getTotal(), 0.05);
62 }
63
64 public void testGetLowValue() {
65 double low = random.nextDouble();
66 Metric IUT = new Metric(testName, 0, 0.0, low, 0.0, 0.0, 0.0);
67 assertEquals(low, IUT.getLowValue(), 0.05);
68 }
69
70 public void testGetHighValue() {
71 double high = random.nextDouble();
72 Metric IUT = new Metric(testName, 0, 0.0, 0.0, high, 0.0, 0.0);
73 assertEquals(high, IUT.getHighValue(), 0.05);
74 }
75
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 public void testGetStandardDeviation() {
83 double stdev = random.nextDouble();
84 Metric IUT = new Metric(testName, 0, 0.0, 0.0, 0.0, 0.0, stdev);
85 assertEquals(stdev, IUT.getStandardDeviation(), 0.05);
86 }
87
88 }
This page was automatically generated by Maven