Skip to content

Commit 0fbf8c7

Browse files
Test that property query sum overflows (#38)
1 parent 0a53a47 commit 0fbf8c7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

objectbox/test/query_property_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,25 @@ void main() {
152152
query.close();
153153
});
154154

155+
test('.sum integers overflow', () {
156+
box.removeAll();
157+
// Max int for Dart native (64-bit signed integer).
158+
box.put(TestEntity(tLong: 0x7fffffffffffffff));
159+
box.put(TestEntity(tLong: 1));
160+
161+
expect(box.get(1)!.tLong, 0x7fffffffffffffff);
162+
expect(box.get(2)!.tLong, 1);
163+
164+
final query = box.query().build();
165+
expect(() {
166+
query.property(tLong).sum();
167+
},
168+
throwsA(predicate((e) =>
169+
e is NumericOverflowException &&
170+
e.message == "Numeric overflow: 9223372036854775808 high: 0")));
171+
query.close();
172+
});
173+
155174
test('.min integers', () {
156175
box.putMany(integerList());
157176

0 commit comments

Comments
 (0)