PageRenderTime 22ms CodeModel.GetById 11ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/testability-explorer/src/test/java/com/google/test/metric/report/chart/GradeCategoriesTest.java

http://testability-explorer.googlecode.com/
Java | 60 lines | 33 code | 12 blank | 15 comment | 0 complexity | 3f9a555fcaca33e4a3aa93e24f98ca82 MD5 | raw file
 1/*
 2 * Copyright 2007 Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 5 * use this file except in compliance with the License. You may obtain a copy of
 6 * the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16package com.google.test.metric.report.chart;
17
18import static java.util.Arrays.asList;
19import junit.framework.TestCase;
20
21import com.google.test.metric.report.GradeCategories;
22
23public class GradeCategoriesTest extends TestCase {
24
25  GradeCategories grade = new GradeCategories(1, 2);
26
27  public void testGetExcelentCount() throws Exception {
28    assertEquals(2, grade.getExcellentCount(asList(1, 1, 2, 3)));
29  }
30
31  public void testGetGoodCount() throws Exception {
32    assertEquals(2, grade.getGoodCount(asList(1, 2, 2, 3)));
33  }
34
35  public void testGetNeedsWorkCount() throws Exception {
36    assertEquals(2, grade.getNeedsWorkCount(asList(1, 2, 3, 3)));
37  }
38
39  public void testCreateOverallChart() throws Exception {
40    GoodnessChart chart = grade.createOverallChart(0);
41    assertEquals("t:0", chart.getMap().get("chd"));
42  }
43
44  public void testCreateDistributionChart() throws Exception {
45    PieChartUrl chart = grade.createDistributionChart(asList(1, 2, 2, 3, 3, 3));
46    assertEquals("t:16,33,50", chart.getMap().get("chd"));
47  }
48
49  public void testCreateHistogram() throws Exception {
50    HistogramChartUrl chart = grade.createHistogram(0, 0, asList(1, 2, 2, 3, 3, 3));
51    assertEquals("s:AVAAAAAAAAA,AApAAAAAAAA,AAA9AAAAAAA", chart.getMap().get("chd"));
52  }
53
54  public void testCreateHistogramBug() throws Exception {
55    grade = new GradeCategories(50, 100);
56    HistogramChartUrl chart = grade.createHistogram(0, 0, asList(4, 90));
57    assertEquals("s:f,f,A", chart.getMap().get("chd"));
58  }
59
60}