BitSet { public void setMemorySegment(MemorySegment memorySegment, int offset) { Preconditions.checkArgument(memorySegment != null, "MemorySegment can not be null."); Preconditions.checkArgument(offset >= 0, "Offset should be positive integer."); Preconditions.checkArgument(offset + byteLength <= memorySegment.size(), "Could not set MemorySegment, the remain buffers is not enough."); this.memorySegment = memorySegment; this.offset = offset; } BitSet(int byteSize); void setMemorySegment(MemorySegment memorySegment, int offset); void set(int index); boolean get(int index); int bitSize(); void clear(); @Override String toString();  }
@Test(expected = IllegalArgumentException.class) public void verifyBitSetSize1() { bitSet.setMemorySegment(memorySegment, 1); }
@Test(expected = IllegalArgumentException.class) public void verifyBitSetSize2() { bitSet.setMemorySegment(null, 1); }
@Test(expected = IllegalArgumentException.class) public void verifyBitSetSize3() { bitSet.setMemorySegment(memorySegment, -1); }