Skip to content

Commit 20bff6e

Browse files
PropertyQueryTest: sumDouble pos/neg overflow [throws -> (-)Infinity].
1 parent f141088 commit 20bff6e

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

tests/objectbox-java-test/src/test/java/io/objectbox/query/PropertyQueryTest.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -651,24 +651,22 @@ public void sum_longOverflow_exception() {
651651

652652
@Test
653653
public void sumDouble_positiveOverflow_exception() {
654-
exceptionRule.expect(DbException.class);
655-
exceptionRule.expectMessage("Numeric overflow");
656-
657-
putTestEntityFloat(0, Double.POSITIVE_INFINITY);
658-
putTestEntityFloat(0, 1);
654+
putTestEntityFloat(Float.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
655+
putTestEntityFloat(1, 1);
659656

660-
box.query().build().property(simpleDouble).sumDouble();
657+
Query<TestEntity> baseQuery = box.query().build();
658+
assertEquals(Float.POSITIVE_INFINITY, baseQuery.property(simpleFloat).avg(), 0.001);
659+
assertEquals(Double.POSITIVE_INFINITY, baseQuery.property(simpleDouble).avg(), 0.001);
661660
}
662661

663662
@Test
664663
public void sumDouble_negativeOverflow_exception() {
665-
exceptionRule.expect(DbException.class);
666-
exceptionRule.expectMessage("Numeric overflow (negative)");
667-
668-
putTestEntityFloat(0, Double.NEGATIVE_INFINITY);
669-
putTestEntityFloat(0, -1);
664+
putTestEntityFloat(Float.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
665+
putTestEntityFloat(-1, -1);
670666

671-
box.query().build().property(simpleDouble).sumDouble();
667+
Query<TestEntity> baseQuery = box.query().build();
668+
assertEquals(Float.NEGATIVE_INFINITY, baseQuery.property(simpleFloat).avg(), 0.001);
669+
assertEquals(Double.NEGATIVE_INFINITY, baseQuery.property(simpleDouble).avg(), 0.001);
672670
}
673671

674672
@Test

0 commit comments

Comments
 (0)