|
18 | 18 |
|
19 | 19 | package org.bson;
|
20 | 20 |
|
| 21 | +import static org.testng.Assert.assertNotEquals; |
| 22 | + |
21 | 23 | import java.io.ByteArrayInputStream;
|
22 | 24 | import java.io.IOException;
|
23 |
| -import java.util.*; |
24 |
| - |
| 25 | +import java.util.ArrayList; |
| 26 | +import java.util.Date; |
| 27 | +import java.util.List; |
| 28 | +import java.util.Vector; |
25 | 29 | import org.bson.io.BasicOutputBuffer;
|
26 | 30 | import org.bson.io.OutputBuffer;
|
27 | 31 | import org.bson.types.CodeWScope;
|
@@ -259,6 +263,27 @@ public void testCustomDecoders()
|
259 | 263 | assertFalse( BSON.getDecodingHooks( Date.class ).contains( tf ) );
|
260 | 264 |
|
261 | 265 | }
|
| 266 | + |
| 267 | + @Test |
| 268 | + public void testEquals() { |
| 269 | + assertNotEquals(new BasicBSONObject("a", 1111111111111111111L), new BasicBSONObject("a", 1111111111111111112L), |
| 270 | + "longs should not be equal"); |
| 271 | + |
| 272 | + assertNotEquals(new BasicBSONObject("a", 100.1D), new BasicBSONObject("a", 100.2D), |
| 273 | + "doubles should not be equal"); |
| 274 | + |
| 275 | + assertNotEquals(new BasicBSONObject("a", 100.1F), new BasicBSONObject("a", 100.2F), |
| 276 | + "floats should not be equal"); |
| 277 | + |
| 278 | + assertEquals(new BasicBSONObject("a", 100.1D), new BasicBSONObject("a", 100.1D), |
| 279 | + "doubles should be equal"); |
| 280 | + |
| 281 | + assertEquals(new BasicBSONObject("a", 100.1F), new BasicBSONObject("a", 100.1F), |
| 282 | + "floats should be equal"); |
| 283 | + |
| 284 | + assertEquals(new BasicBSONObject("a", 100), new BasicBSONObject("a", 100L), |
| 285 | + "int and long should be equal"); |
| 286 | + } |
262 | 287 |
|
263 | 288 | private class TestDate {
|
264 | 289 | final int year;
|
|
0 commit comments