summaryrefslogtreecommitdiff
path: root/decode_scan_test.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-01-26 00:07:39 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-01-26 00:08:56 -0700
commit4148776399cb7ea5e10c74dc465e4e1e682cb399 (patch)
treedaf8a3aa6521d3d56aa986f10c3d23ea1b016f4b /decode_scan_test.go
parente483afa206686ce748ad270140f99fad9d713aad (diff)
Move the Parser to the internal package
Diffstat (limited to 'decode_scan_test.go')
-rw-r--r--decode_scan_test.go350
1 files changed, 176 insertions, 174 deletions
diff --git a/decode_scan_test.go b/decode_scan_test.go
index 70e2874..ac8c2fc 100644
--- a/decode_scan_test.go
+++ b/decode_scan_test.go
@@ -1,4 +1,4 @@
-// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com>
+// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -12,12 +12,14 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+
+ "git.lukeshu.com/go/lowmemjson/internal"
)
type ReadRuneTypeResult struct {
r rune
s int
- t RuneType
+ t internal.RuneType
e error
}
@@ -57,105 +59,105 @@ func testRuneTypeScanner(t *testing.T, testcases map[string]runeTypeScannerTestc
func TestRuneTypeScanner(t *testing.T) {
testcases := map[string]runeTypeScannerTestcase{
"basic": {`{"foo": 12.0}`, ``, []ReadRuneTypeResult{
- {'{', 1, RuneTypeObjectBeg, nil},
- {'"', 1, RuneTypeStringBeg, nil},
- {'f', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'"', 1, RuneTypeStringEnd, nil},
- {':', 1, RuneTypeObjectColon, nil},
- {' ', 1, RuneTypeSpace, nil},
- {'1', 1, RuneTypeNumberIntDig, nil},
- {'2', 1, RuneTypeNumberIntDig, nil},
- {'.', 1, RuneTypeNumberFracDot, nil},
- {'0', 1, RuneTypeNumberFracDig, nil},
- {'}', 1, RuneTypeObjectEnd, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'{', 1, internal.RuneTypeObjectBeg, nil},
+ {'"', 1, internal.RuneTypeStringBeg, nil},
+ {'f', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'"', 1, internal.RuneTypeStringEnd, nil},
+ {':', 1, internal.RuneTypeObjectColon, nil},
+ {' ', 1, internal.RuneTypeSpace, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {'2', 1, internal.RuneTypeNumberIntDig, nil},
+ {'.', 1, internal.RuneTypeNumberFracDot, nil},
+ {'0', 1, internal.RuneTypeNumberFracDig, nil},
+ {'}', 1, internal.RuneTypeObjectEnd, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}},
"unread": {`{"foo": 12.0}`, ``, []ReadRuneTypeResult{
- {'{', 1, RuneTypeObjectBeg, nil},
- {'"', 1, RuneTypeStringBeg, nil},
- {'f', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'"', 1, RuneTypeStringEnd, nil},
- {':', 1, RuneTypeObjectColon, nil},
- {' ', 1, RuneTypeSpace, nil},
- {'1', 1, RuneTypeNumberIntDig, nil},
+ {'{', 1, internal.RuneTypeObjectBeg, nil},
+ {'"', 1, internal.RuneTypeStringBeg, nil},
+ {'f', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'"', 1, internal.RuneTypeStringEnd, nil},
+ {':', 1, internal.RuneTypeObjectColon, nil},
+ {' ', 1, internal.RuneTypeSpace, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
{0, -1, 0, nil},
- {'1', 1, RuneTypeNumberIntDig, nil},
- {'2', 1, RuneTypeNumberIntDig, nil},
- {'.', 1, RuneTypeNumberFracDot, nil},
- {'0', 1, RuneTypeNumberFracDig, nil},
- {'}', 1, RuneTypeObjectEnd, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {'2', 1, internal.RuneTypeNumberIntDig, nil},
+ {'.', 1, internal.RuneTypeNumberFracDot, nil},
+ {'0', 1, internal.RuneTypeNumberFracDig, nil},
+ {'}', 1, internal.RuneTypeObjectEnd, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}},
"unread2": {`{"foo": 12.0}`, ``, []ReadRuneTypeResult{
- {'{', 1, RuneTypeObjectBeg, nil},
- {'"', 1, RuneTypeStringBeg, nil},
- {'f', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'"', 1, RuneTypeStringEnd, nil},
- {':', 1, RuneTypeObjectColon, nil},
- {' ', 1, RuneTypeSpace, nil},
- {'1', 1, RuneTypeNumberIntDig, nil},
+ {'{', 1, internal.RuneTypeObjectBeg, nil},
+ {'"', 1, internal.RuneTypeStringBeg, nil},
+ {'f', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'"', 1, internal.RuneTypeStringEnd, nil},
+ {':', 1, internal.RuneTypeObjectColon, nil},
+ {' ', 1, internal.RuneTypeSpace, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
{0, -1, 0, nil},
{0, -1, 0, ErrInvalidUnreadRune},
- {'1', 1, RuneTypeNumberIntDig, nil},
- {'2', 1, RuneTypeNumberIntDig, nil},
- {'.', 1, RuneTypeNumberFracDot, nil},
- {'0', 1, RuneTypeNumberFracDig, nil},
- {'}', 1, RuneTypeObjectEnd, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {'2', 1, internal.RuneTypeNumberIntDig, nil},
+ {'.', 1, internal.RuneTypeNumberFracDot, nil},
+ {'0', 1, internal.RuneTypeNumberFracDig, nil},
+ {'}', 1, internal.RuneTypeObjectEnd, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}},
"unread-eof": {`{"foo": 12.0}`, ``, []ReadRuneTypeResult{
- {'{', 1, RuneTypeObjectBeg, nil},
- {'"', 1, RuneTypeStringBeg, nil},
- {'f', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'"', 1, RuneTypeStringEnd, nil},
- {':', 1, RuneTypeObjectColon, nil},
- {' ', 1, RuneTypeSpace, nil},
- {'1', 1, RuneTypeNumberIntDig, nil},
- {'2', 1, RuneTypeNumberIntDig, nil},
- {'.', 1, RuneTypeNumberFracDot, nil},
- {'0', 1, RuneTypeNumberFracDig, nil},
- {'}', 1, RuneTypeObjectEnd, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'{', 1, internal.RuneTypeObjectBeg, nil},
+ {'"', 1, internal.RuneTypeStringBeg, nil},
+ {'f', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'"', 1, internal.RuneTypeStringEnd, nil},
+ {':', 1, internal.RuneTypeObjectColon, nil},
+ {' ', 1, internal.RuneTypeSpace, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {'2', 1, internal.RuneTypeNumberIntDig, nil},
+ {'.', 1, internal.RuneTypeNumberFracDot, nil},
+ {'0', 1, internal.RuneTypeNumberFracDig, nil},
+ {'}', 1, internal.RuneTypeObjectEnd, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
{0, -1, 0, ErrInvalidUnreadRune},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}},
"syntax-error": {`[[0,]`, ``, []ReadRuneTypeResult{
- {'[', 1, RuneTypeArrayBeg, nil},
- {'[', 1, RuneTypeArrayBeg, nil},
- {'0', 1, RuneTypeNumberIntZero, nil},
- {',', 1, RuneTypeArrayComma, nil},
- {']', 1, RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
- {']', 1, RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
- {']', 1, RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
+ {'[', 1, internal.RuneTypeArrayBeg, nil},
+ {'[', 1, internal.RuneTypeArrayBeg, nil},
+ {'0', 1, internal.RuneTypeNumberIntZero, nil},
+ {',', 1, internal.RuneTypeArrayComma, nil},
+ {']', 1, internal.RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
+ {']', 1, internal.RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
+ {']', 1, internal.RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
}},
"multi-value": {`1{}`, `}`, []ReadRuneTypeResult{
- {'1', 1, RuneTypeNumberIntDig, nil},
- {'{', 1, RuneTypeEOF, nil},
- {'{', 1, RuneTypeEOF, nil},
- {'{', 1, RuneTypeEOF, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {'{', 1, internal.RuneTypeEOF, nil},
+ {'{', 1, internal.RuneTypeEOF, nil},
+ {'{', 1, internal.RuneTypeEOF, nil},
}},
"early-eof": {`{`, ``, []ReadRuneTypeResult{
- {'{', 1, RuneTypeObjectBeg, nil},
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
+ {'{', 1, internal.RuneTypeObjectBeg, nil},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
}},
"empty": {``, ``, []ReadRuneTypeResult{
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 0, Err: io.EOF}},
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 0, Err: io.EOF}},
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 0, Err: io.EOF}},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 0, Err: io.EOF}},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 0, Err: io.EOF}},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 0, Err: io.EOF}},
}},
}
testRuneTypeScanner(t, testcases, func(reader io.RuneScanner) runeTypeScanner {
@@ -168,66 +170,66 @@ func TestRuneTypeScanner(t *testing.T) {
func TestNoWSRuneTypeScanner(t *testing.T) {
testcases := map[string]runeTypeScannerTestcase{
"basic": {`{"foo": 12.0}`, ``, []ReadRuneTypeResult{
- {'{', 1, RuneTypeObjectBeg, nil},
- {'"', 1, RuneTypeStringBeg, nil},
- {'f', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'"', 1, RuneTypeStringEnd, nil},
- {':', 1, RuneTypeObjectColon, nil},
- {'1', 1, RuneTypeNumberIntDig, nil},
- {'2', 1, RuneTypeNumberIntDig, nil},
- {'.', 1, RuneTypeNumberFracDot, nil},
- {'0', 1, RuneTypeNumberFracDig, nil},
- {'}', 1, RuneTypeObjectEnd, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'{', 1, internal.RuneTypeObjectBeg, nil},
+ {'"', 1, internal.RuneTypeStringBeg, nil},
+ {'f', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'"', 1, internal.RuneTypeStringEnd, nil},
+ {':', 1, internal.RuneTypeObjectColon, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {'2', 1, internal.RuneTypeNumberIntDig, nil},
+ {'.', 1, internal.RuneTypeNumberFracDot, nil},
+ {'0', 1, internal.RuneTypeNumberFracDig, nil},
+ {'}', 1, internal.RuneTypeObjectEnd, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}},
"unread": {`{"foo": 12.0}`, ``, []ReadRuneTypeResult{
- {'{', 1, RuneTypeObjectBeg, nil},
- {'"', 1, RuneTypeStringBeg, nil},
- {'f', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'"', 1, RuneTypeStringEnd, nil},
- {':', 1, RuneTypeObjectColon, nil},
- {'1', 1, RuneTypeNumberIntDig, nil},
+ {'{', 1, internal.RuneTypeObjectBeg, nil},
+ {'"', 1, internal.RuneTypeStringBeg, nil},
+ {'f', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'"', 1, internal.RuneTypeStringEnd, nil},
+ {':', 1, internal.RuneTypeObjectColon, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
{0, -1, 0, nil},
- {'1', 1, RuneTypeNumberIntDig, nil},
- {'2', 1, RuneTypeNumberIntDig, nil},
- {'.', 1, RuneTypeNumberFracDot, nil},
- {'0', 1, RuneTypeNumberFracDig, nil},
- {'}', 1, RuneTypeObjectEnd, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {'2', 1, internal.RuneTypeNumberIntDig, nil},
+ {'.', 1, internal.RuneTypeNumberFracDot, nil},
+ {'0', 1, internal.RuneTypeNumberFracDig, nil},
+ {'}', 1, internal.RuneTypeObjectEnd, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}},
"tail": {`{"foo": 12.0} `, ``, []ReadRuneTypeResult{
- {'{', 1, RuneTypeObjectBeg, nil},
- {'"', 1, RuneTypeStringBeg, nil},
- {'f', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'"', 1, RuneTypeStringEnd, nil},
- {':', 1, RuneTypeObjectColon, nil},
- {'1', 1, RuneTypeNumberIntDig, nil},
- {'2', 1, RuneTypeNumberIntDig, nil},
- {'.', 1, RuneTypeNumberFracDot, nil},
- {'0', 1, RuneTypeNumberFracDig, nil},
- {'}', 1, RuneTypeObjectEnd, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'{', 1, internal.RuneTypeObjectBeg, nil},
+ {'"', 1, internal.RuneTypeStringBeg, nil},
+ {'f', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'"', 1, internal.RuneTypeStringEnd, nil},
+ {':', 1, internal.RuneTypeObjectColon, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {'2', 1, internal.RuneTypeNumberIntDig, nil},
+ {'.', 1, internal.RuneTypeNumberFracDot, nil},
+ {'0', 1, internal.RuneTypeNumberFracDig, nil},
+ {'}', 1, internal.RuneTypeObjectEnd, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}},
"multi-value": {`1{}`, `}`, []ReadRuneTypeResult{
- {'1', 1, RuneTypeNumberIntDig, nil},
- {'{', 1, RuneTypeEOF, nil},
- {'{', 1, RuneTypeEOF, nil},
- {'{', 1, RuneTypeEOF, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {'{', 1, internal.RuneTypeEOF, nil},
+ {'{', 1, internal.RuneTypeEOF, nil},
+ {'{', 1, internal.RuneTypeEOF, nil},
}},
"early-eof": {` {`, ``, []ReadRuneTypeResult{
- {'{', 1, RuneTypeObjectBeg, nil},
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 2, Err: io.ErrUnexpectedEOF}},
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 2, Err: io.ErrUnexpectedEOF}},
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 2, Err: io.ErrUnexpectedEOF}},
+ {'{', 1, internal.RuneTypeObjectBeg, nil},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 2, Err: io.ErrUnexpectedEOF}},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 2, Err: io.ErrUnexpectedEOF}},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 2, Err: io.ErrUnexpectedEOF}},
}},
}
testRuneTypeScanner(t, testcases, func(reader io.RuneScanner) runeTypeScanner {
@@ -242,37 +244,37 @@ func TestNoWSRuneTypeScanner(t *testing.T) {
func TestElemRuneTypeScanner(t *testing.T) {
testcases := map[string]runeTypeScannerTestcase{
"basic": {`1`, ``, []ReadRuneTypeResult{
- {'1', 1, RuneTypeNumberIntDig, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}},
"syntax-error": {`[[0,]`, ``, []ReadRuneTypeResult{
- {'[', 1, RuneTypeArrayBeg, nil},
- {'[', 1, RuneTypeArrayBeg, nil},
- {'0', 1, RuneTypeNumberIntZero, nil},
- {',', 1, RuneTypeArrayComma, nil},
- {']', 1, RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
- {']', 1, RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
- {']', 1, RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
+ {'[', 1, internal.RuneTypeArrayBeg, nil},
+ {'[', 1, internal.RuneTypeArrayBeg, nil},
+ {'0', 1, internal.RuneTypeNumberIntZero, nil},
+ {',', 1, internal.RuneTypeArrayComma, nil},
+ {']', 1, internal.RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
+ {']', 1, internal.RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
+ {']', 1, internal.RuneTypeError, &DecodeSyntaxError{Offset: 5, Err: fmt.Errorf("invalid character %q looking for beginning of value", ']')}},
}},
"multi-value": {`1{}`, `{}`, []ReadRuneTypeResult{
- {'1', 1, RuneTypeNumberIntDig, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}},
"fragment": {`1,`, `,`, []ReadRuneTypeResult{
- {'1', 1, RuneTypeNumberIntDig, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}},
"early-eof": {`{`, ``, []ReadRuneTypeResult{
- {'{', 1, RuneTypeObjectBeg, nil},
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
- {0, 0, RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
+ {'{', 1, internal.RuneTypeObjectBeg, nil},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
+ {0, 0, internal.RuneTypeError, &DecodeSyntaxError{Offset: 1, Err: io.ErrUnexpectedEOF}},
}},
}
t.Run("top-level", func(t *testing.T) {
@@ -306,7 +308,7 @@ func TestElemRuneTypeScanner(t *testing.T) {
var res ReadRuneTypeResult
res.r, res.s, res.t, res.e = inner.ReadRuneType()
require.Equal(t,
- ReadRuneTypeResult{'[', 1, RuneTypeArrayBeg, nil}.String(),
+ ReadRuneTypeResult{'[', 1, internal.RuneTypeArrayBeg, nil}.String(),
res.String())
return &elemRuneTypeScanner{
@@ -323,13 +325,13 @@ func TestElemRuneTypeScanner2(t *testing.T) {
},
}
exp := []ReadRuneTypeResult{
- {'{', 1, RuneTypeObjectBeg, nil},
- {'"', 1, RuneTypeStringBeg, nil},
- {'f', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'o', 1, RuneTypeStringChar, nil},
- {'"', 1, RuneTypeStringEnd, nil},
- {':', 1, RuneTypeObjectColon, nil},
+ {'{', 1, internal.RuneTypeObjectBeg, nil},
+ {'"', 1, internal.RuneTypeStringBeg, nil},
+ {'f', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'o', 1, internal.RuneTypeStringChar, nil},
+ {'"', 1, internal.RuneTypeStringEnd, nil},
+ {':', 1, internal.RuneTypeObjectColon, nil},
}
var expStr, actStr []string
for _, iExp := range exp {
@@ -344,12 +346,12 @@ func TestElemRuneTypeScanner2(t *testing.T) {
inner: parent,
}
exp = []ReadRuneTypeResult{
- {'1', 1, RuneTypeNumberIntDig, nil},
- {'2', 1, RuneTypeNumberIntDig, nil},
- {'.', 1, RuneTypeNumberFracDot, nil},
- {'0', 1, RuneTypeNumberFracDig, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'1', 1, internal.RuneTypeNumberIntDig, nil},
+ {'2', 1, internal.RuneTypeNumberIntDig, nil},
+ {'.', 1, internal.RuneTypeNumberFracDot, nil},
+ {'0', 1, internal.RuneTypeNumberFracDig, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}
expStr, actStr = nil, nil
for _, iExp := range exp {
@@ -361,9 +363,9 @@ func TestElemRuneTypeScanner2(t *testing.T) {
}
exp = []ReadRuneTypeResult{
- {'}', 1, RuneTypeObjectEnd, nil},
- {0, 0, RuneTypeEOF, nil},
- {0, 0, RuneTypeEOF, nil},
+ {'}', 1, internal.RuneTypeObjectEnd, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
+ {0, 0, internal.RuneTypeEOF, nil},
}
expStr, actStr = nil, nil
for _, iExp := range exp {