summaryrefslogtreecommitdiff
path: root/internal/parse_test.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-02-07 12:18:29 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-02-07 14:05:26 -0700
commit2b9473f5e8816eeea76b2fdada184532be00d3a2 (patch)
tree387757b00f02521d1b3824a0e92f7778dbd32440 /internal/parse_test.go
parenteab38672b2467810592b61fe5b0067086d3cbd2c (diff)
internal: Split in to sub-packages
Diffstat (limited to 'internal/parse_test.go')
-rw-r--r--internal/parse_test.go78
1 files changed, 0 insertions, 78 deletions
diff --git a/internal/parse_test.go b/internal/parse_test.go
deleted file mode 100644
index 34977fb..0000000
--- a/internal/parse_test.go
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (C) 2023 Luke Shumaker <lukeshu@lukeshu.com>
-//
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-package internal
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-)
-
-func TestParserHandleRune(t *testing.T) {
- t.Parallel()
- type testcase struct {
- Input string
- ExpStack []string
- }
- testcases := map[string]testcase{
- // Keep these test-cases in-sync with the examples in parse.go.
- "object": {
- Input: `{"x":"y","a":"b"}`,
- ExpStack: []string{
- // st,// processed
- `?`,
- `{`, // {
- `»"`, // {"
- `»"`, // {"x
- `»`, // {"x"
- `o?`, // {"x":
- `o"`, // {"x":"
- `o"`, // {"x":"y
- `o`, // {"x":"y"
- `{`, // {"x":"y",
- `»"`, // {"x":"y","
- `»"`, // {"x":"y","a
- `»`, // {"x":"y","a"
- `o?`, // {"x":"y","a":
- `o"`, // {"x":"y","a":"
- `o"`, // {"x":"y","a":"b
- `o`, // {"x":"y","a":"b"
- ``, // {"x":"y","a":"b"}
- },
- },
- "array": {
- Input: `["x","y"]`,
- ExpStack: []string{
- // st,// processed
- `?`,
- `[`, // [
- `a"`, // ["
- `a"`, // ["x
- `a`, // ["x"
- `a?`, // ["x",
- `a"`, // ["x","
- `a"`, // ["x","y
- `a`, // ["x","y"
- ``, // ["x","y"]
- },
- },
- }
- for tcName, tc := range testcases {
- tc := tc
- t.Run(tcName, func(t *testing.T) {
- t.Parallel()
- var par Parser
- if !assert.Equal(t, len(tc.Input)+1, len(tc.ExpStack)) {
- return
- }
- for i, r := range tc.Input {
- assert.Equal(t, tc.ExpStack[i], par.stackString())
- _, err := par.HandleRune(r)
- assert.NoError(t, err)
- assert.Equal(t, tc.ExpStack[i+1], par.stackString())
- }
- })
- }
-}