Skip to content

Commit

Permalink
test[scala]: scala protocol test
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Jul 16, 2024
1 parent 5458e8b commit 60ec9a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions protocol/src/main/resources/scala/ByteBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ class ByteBuffer {
def getWriteOffset: Int = writeOffset

def setWriteOffset(writeIndex: Int): Unit = {
if (writeIndex > buffer.length) throw new RuntimeException("writeIndex[" + writeIndex + "] out of bounds exception: readerIndex: " + readOffset + ", writerIndex: " + writeOffset + "(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.length)
if (writeIndex > buffer.length) throw new RuntimeException("writeIndex[" + writeIndex + "] out of bounds exception: readOffset: " + readOffset + ", writeOffset: " + writeOffset + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.length + ")")
writeOffset = writeIndex
}

def getReadOffset: Int = readOffset

def setReadOffset(readIndex: Int): Unit = {
if (readIndex > writeOffset) throw new RuntimeException("readIndex[" + readIndex + "] out of bounds exception: readerIndex: " + readOffset + ", writerIndex: " + writeOffset + "(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.length)
if (readIndex > writeOffset) throw new RuntimeException("readIndex[" + readIndex + "] out of bounds exception: readOffset: " + readOffset + ", writeOffset: " + writeOffset + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.length + ")")
readOffset = readIndex
}

Expand Down
4 changes: 2 additions & 2 deletions protocol/src/test/scala/com/zfoo/scala/ByteBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ class ByteBuffer {
def getWriteOffset: Int = writeOffset

def setWriteOffset(writeIndex: Int): Unit = {
if (writeIndex > buffer.length) throw new RuntimeException("writeIndex[" + writeIndex + "] out of bounds exception: readerIndex: " + readOffset + ", writerIndex: " + writeOffset + "(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.length)
if (writeIndex > buffer.length) throw new RuntimeException("writeIndex[" + writeIndex + "] out of bounds exception: readOffset: " + readOffset + ", writeOffset: " + writeOffset + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.length + ")")
writeOffset = writeIndex
}

def getReadOffset: Int = readOffset

def setReadOffset(readIndex: Int): Unit = {
if (readIndex > writeOffset) throw new RuntimeException("readIndex[" + readIndex + "] out of bounds exception: readerIndex: " + readOffset + ", writerIndex: " + writeOffset + "(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.length)
if (readIndex > writeOffset) throw new RuntimeException("readIndex[" + readIndex + "] out of bounds exception: readOffset: " + readOffset + ", writeOffset: " + writeOffset + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.length + ")")
readOffset = readIndex
}

Expand Down

0 comments on commit 60ec9a7

Please sign in to comment.