Skip to content

Commit

Permalink
Add JsonReader.hasRemaining()
Browse files Browse the repository at this point in the history
  • Loading branch information
plokhotnyuk committed Feb 20, 2023
1 parent 82d4600 commit 6e76cc4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ final class JsonReader private[jsoniter_scala](

def isCurrentToken(t: Byte): Boolean = isCurrentToken(t, head)

def hasRemaining(): Boolean = head < tail || loadMore(head) < tail

def rollbackToken(): Unit = {
val pos = head
if (pos == 0) illegalTokenOperation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ final class JsonReader private[jsoniter_scala](

def isCurrentToken(t: Byte): Boolean = isCurrentToken(t, head)

def hasRemaining(): Boolean = head < tail || loadMore(head) < tail

def rollbackToken(): Unit = {
val pos = head
if (pos == 0) illegalTokenOperation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ final class JsonReader private[jsoniter_scala](

def isCurrentToken(t: Byte): Boolean = isCurrentToken(t, head)

def hasRemaining(): Boolean = head < tail || loadMore(head) < tail

def rollbackToken(): Unit = {
val pos = head
if (pos == 0) illegalTokenOperation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,15 @@ class JsonReaderSpec extends AnyWordSpec with Matchers with ScalaCheckPropertyCh
.getMessage.startsWith("expected preceding call of 'nextToken()' or 'isNextToken()'"))
}
}
"JsonReader.hasRemaining" should {
"return true in case of at least one byte can be read from the input" in {
val jsonReader = reader("{\n}")
jsonReader.nextToken()
jsonReader.hasRemaining() shouldBe true
jsonReader.isNextToken('}')
jsonReader.hasRemaining() shouldBe false
}
}
"JsonReader.readANullOrError" should {
"parse null value" in {
val r = reader("null")
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "2.20.8-SNAPSHOT"
ThisBuild / version := "2.21.0-SNAPSHOT"

0 comments on commit 6e76cc4

Please sign in to comment.