1 37 38 package org.jfree.data.junit; 39 40 import junit.framework.Test; 41 import junit.framework.TestCase; 42 import junit.framework.TestSuite; 43 44 import org.jfree.data.DatasetUtilities; 45 import org.jfree.data.DefaultCategoryDataset; 46 import org.jfree.data.Range; 47 import org.jfree.util.NumberUtils; 48 49 54 public class DatasetUtilitiesTests extends TestCase { 55 56 61 public static Test suite() { 62 return new TestSuite(DatasetUtilitiesTests.class); 63 } 64 65 70 public DatasetUtilitiesTests(String name) { 71 super(name); 72 } 73 74 77 public void testMinMaxRange() { 78 DefaultCategoryDataset dataset = new DefaultCategoryDataset(); 79 dataset.addValue(100.0, "Series 1", "Type 1"); 80 dataset.addValue(101.1, "Series 1", "Type 2"); 81 Number min = DatasetUtilities.getMinimumRangeValue(dataset); 82 assertTrue(min.doubleValue() < 100.1); 83 Number max = DatasetUtilities.getMaximumRangeValue(dataset); 84 assertTrue(max.doubleValue() > 101.0); 85 } 86 87 90 public void test803660() { 91 DefaultCategoryDataset dataset = new DefaultCategoryDataset(); 92 dataset.addValue(100.0, "Series 1", "Type 1"); 93 dataset.addValue(101.1, "Series 1", "Type 2"); 94 Number n = DatasetUtilities.getMaximumRangeValue(dataset); 95 assertTrue(n.doubleValue() > 101.0); 96 97 } 98 99 103 public void testCumulativeRange1() { 104 DefaultCategoryDataset dataset = new DefaultCategoryDataset(); 105 dataset.addValue(10.0, "Series 1", "Start"); 106 dataset.addValue(15.0, "Series 1", "Delta 1"); 107 dataset.addValue(-7.0, "Series 1", "Delta 2"); 108 Range range = DatasetUtilities.getCumulativeRangeExtent(dataset); 109 assertTrue(NumberUtils.equal(range.getLowerBound(), 0.0)); 110 assertTrue(NumberUtils.equal(range.getUpperBound(), 25.0)); 111 } 112 113 116 public void testCumulativeRange2() { 117 DefaultCategoryDataset dataset = new DefaultCategoryDataset(); 118 dataset.addValue(-21.4, "Series 1", "Start Value"); 119 dataset.addValue(11.57, "Series 1", "Delta 1"); 120 dataset.addValue(3.51, "Series 1", "Delta 2"); 121 dataset.addValue(-12.36, "Series 1", "Delta 3"); 122 dataset.addValue(3.39, "Series 1", "Delta 4"); 123 dataset.addValue(38.68, "Series 1", "Delta 5"); 124 dataset.addValue(-43.31, "Series 1", "Delta 6"); 125 dataset.addValue(-29.59, "Series 1", "Delta 7"); 126 dataset.addValue(35.30, "Series 1", "Delta 8"); 127 dataset.addValue(5.0, "Series 1", "Delta 9"); 128 Range range = DatasetUtilities.getCumulativeRangeExtent(dataset); 129 assertTrue(NumberUtils.equal(range.getLowerBound(), -49.51)); 130 assertTrue(NumberUtils.equal(range.getUpperBound(), 23.39)); 131 } 132 133 } 134 | Popular Tags |