@@ -320,6 +320,46 @@ class BasicOutputBufferSpecification extends Specification {
320
320
bsonOutput. size == 8
321
321
}
322
322
323
+ def ' absolute write should throw with invalid position' () {
324
+ given :
325
+ def bsonOutput = new BasicOutputBuffer ()
326
+ bsonOutput. writeBytes([1 , 2 , 3 , 4 ] as byte [])
327
+
328
+ when :
329
+ bsonOutput. write(-1 , 0x1020304 )
330
+
331
+ then :
332
+ thrown(IllegalArgumentException )
333
+
334
+ when :
335
+ bsonOutput. write(4 , 0x1020304 )
336
+
337
+ then :
338
+ thrown(IllegalArgumentException )
339
+ }
340
+
341
+ def ' absolute write should write Int32 at position' () {
342
+ given :
343
+ def bsonOutput = new BasicOutputBuffer ()
344
+ bsonOutput. writeBytes([0 , 0 , 0 , 0 , 1 , 2 , 3 , 4 ] as byte [])
345
+
346
+ when :
347
+ bsonOutput. write(0 , 0x1020304 )
348
+
349
+ then :
350
+ getBytes(bsonOutput) == [4 , 0 , 0 , 0 , 1 , 2 , 3 , 4 ] as byte []
351
+ bsonOutput. position == 8
352
+ bsonOutput. size == 8
353
+
354
+ when :
355
+ bsonOutput. write(7 , 0x1020304 )
356
+
357
+ then :
358
+ getBytes(bsonOutput) == [4 , 0 , 0 , 0 , 1 , 2 , 3 , 4 ] as byte []
359
+ bsonOutput. position == 8
360
+ bsonOutput. size == 8
361
+ }
362
+
323
363
def ' truncate should throw with invalid position' () {
324
364
given :
325
365
def bsonOutput = new BasicOutputBuffer ()
0 commit comments