@@ -82,6 +82,11 @@ private int insertData(String sql) throws SQLException {
8282 }
8383 }
8484
85+ private static void assertFloat32Boundary (float actual , float expectedA , float expectedB , String label ) {
86+ Assert .assertTrue (actual == expectedA || actual == expectedB ,
87+ label + " expected one of [" + expectedA + ", " + expectedB + "] but found [" + actual + "]" );
88+ }
89+
8590 @ Test (groups = { "integration" })
8691 public void testIntegerTypes () throws SQLException {
8792 runQuery ("CREATE TABLE test_integers (order Int8, "
@@ -1541,11 +1546,11 @@ public void testFloatTypes() throws SQLException {
15411546 try (Statement stmt = conn .createStatement ()) {
15421547 try (ResultSet rs = stmt .executeQuery ("SELECT * FROM test_floats ORDER BY order" )) {
15431548 assertTrue (rs .next ());
1544- assertEquals (rs .getFloat ("float32" ), -3.402823E38f );
1549+ assertFloat32Boundary (rs .getFloat ("float32" ), -3.4028233E38f , - 3. 402823E38f, "float32 min" );
15451550 assertEquals (rs .getDouble ("float64" ), Double .valueOf (-1.7976931348623157E308 ));
15461551
15471552 assertTrue (rs .next ());
1548- assertEquals (rs .getFloat ("float32" ), Float . valueOf ( 3.402823E38f ) );
1553+ assertFloat32Boundary (rs .getFloat ("float32" ), 3.4028233E38f , 3.402823E38f , "float32 max" );
15491554 assertEquals (rs .getDouble ("float64" ), Double .valueOf (1.7976931348623157E308 ));
15501555
15511556 assertTrue (rs .next ());
@@ -1562,11 +1567,13 @@ public void testFloatTypes() throws SQLException {
15621567 try (Statement stmt = conn .createStatement ()) {
15631568 try (ResultSet rs = stmt .executeQuery ("SELECT * FROM test_floats ORDER BY order" )) {
15641569 assertTrue (rs .next ());
1565- assertEquals (rs .getObject ("float32" ), -3.402823E38f );
1570+ assertFloat32Boundary (((Number ) rs .getObject ("float32" )).floatValue (), -3.4028233E38f , -3.402823E38f ,
1571+ "float32 min object" );
15661572 assertEquals (rs .getObject ("float64" ), Double .valueOf (-1.7976931348623157E308 ));
15671573
15681574 assertTrue (rs .next ());
1569- assertEquals (rs .getObject ("float32" ), 3.402823E38f );
1575+ assertFloat32Boundary (((Number ) rs .getObject ("float32" )).floatValue (), 3.4028233E38f , 3.402823E38f ,
1576+ "float32 max object" );
15701577 assertEquals (rs .getObject ("float64" ), Double .valueOf (1.7976931348623157E308 ));
15711578
15721579 assertTrue (rs .next ());
0 commit comments