字节队列类
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package test;
|
||||
|
||||
import com.sunyard.sge.bytes.BytesQueue;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ByteQueueTest {
|
||||
|
||||
@Test
|
||||
public void case1() {
|
||||
BytesQueue queue = new BytesQueue();
|
||||
int max = 1000;
|
||||
|
||||
for (int i = 0; i < max; i++) {
|
||||
int r = new Random().nextInt(4096);
|
||||
queue.push(new byte[r]);
|
||||
}
|
||||
|
||||
|
||||
while (true) {
|
||||
byte[] data = queue.pop(16, 16);
|
||||
Assert.assertEquals(data.length % 16, 0);
|
||||
if (0 == data.length) {
|
||||
data = queue.pop();
|
||||
Assert.assertTrue( data.length >= 16 );
|
||||
data = queue.pop();
|
||||
Assert.assertEquals(0, data.length);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user