This is an automated email from the ASF dual-hosted git repository.

pjfanning pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 608242b08f TestCellFormat: pin Excel's results for improper fractions 
near int overflow (#1493)
608242b08f is described below

commit 608242b08f43bd7a1d069d41aa12fe5a6b1f4b84
Author: PJ Fanning <[email protected]>
AuthorDate: Mon Oct 26 19:38:27 2026 +0000

    TestCellFormat: pin Excel's results for improper fractions near int 
overflow (#1493)
    
    Checked against Excel's =TEXT(value, "?????????/?????????"). POI matches
    for 2500.123456789 and 2100000000.12345; the 300000.707106781 case, where
    POI stops at a smaller denominator than Excel, is added as a disabled test.
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../java/org/apache/poi/ss/format/TestCellFormat.java    | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java 
b/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java
index 6589de6555..06297fff84 100644
--- a/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java
+++ b/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java
@@ -50,6 +50,7 @@ import org.apache.poi.util.LocaleUtil;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.parallel.Isolated;
 
@@ -967,8 +968,19 @@ class TestCellFormat {
 
     @Test
     void testImproperFractionNumeratorOverflow() {
-        // the numerator overflows an int long before the denominator reaches 
9 digits
-        assertEquals("202510/81", 
CellFormat.getInstance("?????????/?????????").apply(2500.123456789).text.trim());
+        // the numerator overflows an int long before the denominator reaches 
9 digits;
+        // Excel's =TEXT(value, "?????????/?????????") gives these results too
+        CellFormat cf = CellFormat.getInstance("?????????/?????????");
+        assertEquals("202510/81", cf.apply(2500.123456789).text.trim());
+        assertEquals("2100000000/1", cf.apply(2100000000.12345).text.trim());
+    }
+
+    @Disabled("POI stops at 1008902378/3363 because the numerator overflows an 
int before the denominator reaches 8119")
+    @Test
+    void testImproperFractionNumeratorOverflowExcelDenominator() {
+        // Excel's =TEXT(300000.707106781, "?????????/?????????") gives 
2435705741/8119
+        CellFormat cf = CellFormat.getInstance("?????????/?????????");
+        assertEquals("2435705741/8119", 
cf.apply(300000.707106781).text.trim());
     }
 
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to