Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-36871] Add some more test cases
  • Loading branch information
stephenc committed Aug 5, 2016
1 parent 6da1cb4 commit d942165
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueTest.java
Expand Up @@ -107,6 +107,40 @@ public void putGetOneByteSequences() {
assertThat(queue.hasRemaining(), is(false));
}

@Test
public void putGetByteSequences() {
ByteBufferQueue queue = new ByteBufferQueue(100);
for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
byte b = (byte)i;
queue.put(b);
assertThat(queue.hasRemaining(), is(true));
}
for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
byte b = (byte) i;
assertThat(queue.hasRemaining(), is(true));
assertThat(queue.get(), is(b));
}
assertThat(queue.hasRemaining(), is(false));
}

@Test
public void putGetByteArraySequences() {
ByteBufferQueue queue = new ByteBufferQueue(100);
byte[] dst = new byte[1];
for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
byte b = (byte)i;
queue.put(b);
assertThat(queue.hasRemaining(), is(true));
}
for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
byte b = (byte) i;
assertThat(queue.hasRemaining(), is(true));
assertThat(queue.get(dst, 0, 1), is(1));
assertThat(dst[0], is(b));
}
assertThat(queue.hasRemaining(), is(false));
}

@Test
public void putGetDrainsQueue() {
ByteBufferQueue queue = new ByteBufferQueue(100);
Expand Down

0 comments on commit d942165

Please sign in to comment.