Skip to content

Commit 1eaffc2

Browse files
Edarkevbabanin
andauthored
Update bson/src/test/unit/org/bson/io/BasicOutputBufferSpecification.groovy
Co-authored-by: Viacheslav Babanin <frest0512@gmail.com>
1 parent de504ee commit 1eaffc2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

bson/src/test/unit/org/bson/io/BasicOutputBufferSpecification.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,20 @@ class BasicOutputBufferSpecification extends Specification {
100100
bsonOutput.size == 4
101101
}
102102

103+
def 'toByteArray creates a copy'() {
104+
given:
105+
def bsonOutput = new BasicOutputBuffer(10)
106+
bsonOutput.writeBytes([1, 2, 3, 4] as byte[])
107+
108+
when:
109+
def first = bsonOutput.toByteArray()
110+
def second = bsonOutput.toByteArray()
111+
112+
then:
113+
first !== second
114+
first == [1, 2, 3, 4] as byte[]
115+
second == [1, 2, 3, 4] as byte[]
116+
}
103117
def 'should write a little endian Int32'() {
104118
given:
105119
def bsonOutput = new BasicOutputBuffer(3)

0 commit comments

Comments
 (0)