/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. */
  16. package com.google.test.metric.report.chart;
  17. import static java.util.Arrays.asList;
  18. import junit.framework.TestCase;
  19. import com.google.test.metric.report.GradeCategories;
  20. public class GradeCategoriesTest extends TestCase {
  21. GradeCategories grade = new GradeCategories(1, 2);
  22. public void testGetExcelentCount() throws Exception {
  23. assertEquals(2, grade.getExcellentCount(asList(1, 1, 2, 3)));
  24. }
  25. public void testGetGoodCount() throws Exception {
  26. assertEquals(2, grade.getGoodCount(asList(1, 2, 2, 3)));
  27. }
  28. public void testGetNeedsWorkCount() throws Exception {
  29. assertEquals(2, grade.getNeedsWorkCount(asList(1, 2, 3, 3)));
  30. }
  31. public void testCreateOverallChart() throws Exception {
  32. GoodnessChart chart = grade.createOverallChart(0);
  33. assertEquals("t:0", chart.getMap().get("chd"));
  34. }
  35. public void testCreateDistributionChart() throws Exception {
  36. PieChartUrl chart = grade.createDistributionChart(asList(1, 2, 2, 3, 3, 3));
  37. assertEquals("t:16,33,50", chart.getMap().get("chd"));
  38. }
  39. public void testCreateHistogram() throws Exception {
  40. HistogramChartUrl chart = grade.createHistogram(0, 0, asList(1, 2, 2, 3, 3, 3));
  41. assertEquals("s:AVAAAAAAAAA,AApAAAAAAAA,AAA9AAAAAAA", chart.getMap().get("chd"));
  42. }
  43. public void testCreateHistogramBug() throws Exception {
  44. grade = new GradeCategories(50, 100);
  45. HistogramChartUrl chart = grade.createHistogram(0, 0, asList(4, 90));
  46. assertEquals("s:f,f,A", chart.getMap().get("chd"));
  47. }
  48. }