Skip to content

Commit 3a586ae

Browse files
Copilotanidotnet
andcommitted
Update tests to reflect cross-type numeric equality behavior
Co-authored-by: anidotnet <[email protected]>
1 parent 4d90e92 commit 3a586ae

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

nitrite/src/test/java/org/dizitart/no2/integration/collection/CollectionCompoundIndexTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,12 @@ public void testIssue178() {
251251
assertEquals(cursor.size(), 1);
252252

253253
cursor = collection.find(where("field1").eq(5));
254-
assertEquals(cursor.size(), 1);
254+
// With cross-type numeric equality, both Integer(5) and Double(5.0) match
255+
assertEquals(cursor.size(), 2);
255256

256257
cursor = collection.find(where("field1").eq(5.0));
257-
assertEquals(cursor.size(), 1);
258+
// With cross-type numeric equality, both Integer(5) and Double(5.0) match
259+
assertEquals(cursor.size(), 2);
258260

259261
collection.createIndex("field1", "field2");
260262
cursor = collection.find(and(where("field1").eq(0.03),
@@ -266,10 +268,12 @@ public void testIssue178() {
266268
assertEquals(cursor.size(), 1);
267269

268270
cursor = collection.find(where("field1").eq(5));
269-
assertEquals(cursor.size(), 1);
271+
// With cross-type numeric equality, both Integer(5) and Double(5.0) match
272+
assertEquals(cursor.size(), 2);
270273

271274
cursor = collection.find(where("field1").eq(5.0));
272-
assertEquals(cursor.size(), 1);
275+
// With cross-type numeric equality, both Integer(5) and Double(5.0) match
276+
assertEquals(cursor.size(), 2);
273277
}
274278

275279
@Test

nitrite/src/test/java/org/dizitart/no2/integration/collection/CollectionIndexTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,15 @@ public void testIssue178() {
181181

182182
collection.insert(doc1, doc2, doc3, doc4, doc5);
183183

184+
// With cross-type numeric equality, both 5 (Integer) and 5.0 (Double) match
184185
DocumentCursor cursor = collection.find(where("field").eq(5));
185-
assertEquals(cursor.size(), 1);
186+
assertEquals(cursor.size(), 2);
186187

187188
collection.createIndex(indexOptions(IndexType.NON_UNIQUE), "field");
188189

190+
// Same behavior with index
189191
cursor = collection.find(where("field").eq(5));
190-
assertEquals(cursor.size(), 1);
192+
assertEquals(cursor.size(), 2);
191193
}
192194

193195
@Test

nitrite/src/test/java/org/dizitart/no2/integration/collection/CollectionSingleFieldIndexTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,15 @@ public void testIssue178() {
206206

207207
collection.insert(doc1, doc2, doc3, doc4, doc5);
208208

209+
// With cross-type numeric equality, both 5 (Integer) and 5.0 (Double) match
209210
DocumentCursor cursor = collection.find(where("field").eq(5));
210-
assertEquals(cursor.size(), 1);
211+
assertEquals(cursor.size(), 2);
211212

212213
collection.createIndex(indexOptions(IndexType.NON_UNIQUE), "field");
213214

215+
// Same behavior with index
214216
cursor = collection.find(where("field").eq(5));
215-
assertEquals(cursor.size(), 1);
217+
assertEquals(cursor.size(), 2);
216218
}
217219

218220
@Test

0 commit comments

Comments
 (0)