View | Details | Raw Unified | Return to bug 53327
Collapse All | Expand All

(-)test/java/org/apache/xmlgraphics/util/DoubleFormatUtilTest.java (-5 / +35 lines)
Lines 139-144 Link Here
139
        expected = refFormat(value, 294, 294);
139
        expected = refFormat(value, 294, 294);
140
        actual = format(value, 294, 294);
140
        actual = format(value, 294, 294);
141
        assertEquals(value, 294, 294, expected, actual);
141
        assertEquals(value, 294, 294, expected, actual);
142
143
        value = 5E-304;
144
        expected = refFormat(value, 303, 303);
145
        actual = format(value, 303, 303);
146
        assertEquals(value, 303, 303, expected, actual);
147
148
        value = 9.999999999999999E-250;
149
        expected = refFormat(value, 265, 265);
150
        actual = format(value, 265, 265);
151
        assertEquals(value, 265, 265, expected, actual);
142
    }
152
    }
143
153
144
    public void testLimits() {
154
    public void testLimits() {
Lines 535-550 Link Here
535
    }
545
    }
536
546
537
    public void testAllDoubleRanges() {
547
    public void testAllDoubleRanges() {
548
        double[] values = {0, 1, 5, 4.9999, 5.0001, 9.9999, 1234567890, 0 /* The last one is random */};
538
        Random r = new Random();
549
        Random r = new Random();
539
        double value;
550
        double value;
540
        String expected, actual;
551
        String expected, actual;
552
        int minScale, maxScale;
541
        for (int i = -330; i <= 315; i++) {
553
        for (int i = -330; i <= 315; i++) {
542
            value = r.nextDouble() * Math.pow(10.0, i);
554
            values[values.length - 1] = r.nextDouble();
543
            for (int scale = 1; scale <= 350; scale++) {
555
            double pow = Math.pow(10.0, i);
544
                expected = refFormat(value, scale, scale);
556
            for (double d : values) {
545
                actual = format(value, scale, scale);
557
                value = d * pow;
546
                assertEquals(value, scale, scale, expected, actual);
558
                minScale = 1;
559
                maxScale = 350;
560
                // Reduce scales (unnecessary tests)
561
                if (i < -30) {
562
                    minScale = -i - 30;
563
                    maxScale = -i + 30;
564
                } else if (i <= 0) {
565
                    minScale = 1;
566
                    maxScale = -i + 30;
567
                } else {
568
                    minScale = 1;
569
                    maxScale = 30;
570
                }
571
                for (int scale = minScale; scale <= maxScale; scale++) {
572
                    expected = refFormat(value, scale, scale);
573
                    actual = format(value, scale, scale);
574
                    assertEquals(value, scale, scale, expected, actual);
575
                }
547
            }
576
            }
577
            
548
        }
578
        }
549
    }
579
    }
550
}
580
}

Return to bug 53327