mirror of https://github.com/goccy/go-json.git
Merge pull request #157 from goccy/feature/add-number-test
Add test case of encoder for json.Number type
This commit is contained in:
commit
015b9c40be
|
@ -14,7 +14,7 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
os: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
|
||||
go-version: [ "1.13", "1.14", "1.15", "1.16" ]
|
||||
go-version: [ "1.14", "1.15", "1.16" ]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: setup Go ${{ matrix.go-version }}
|
||||
|
|
|
@ -3,6 +3,8 @@ package json_test
|
|||
import (
|
||||
"bytes"
|
||||
stdjson "encoding/json"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
)
|
||||
|
||||
func intptr(v int) *int { return &v }
|
||||
|
@ -35,6 +37,8 @@ func boolptr(v bool) *bool { return &v }
|
|||
func boolptr3(v bool) ***bool { vv := &v; vvv := &vv; return &vvv }
|
||||
func bytesptr(v []byte) *[]byte { return &v }
|
||||
func bytesptr3(v []byte) ***[]byte { vv := &v; vvv := &vv; return &vvv }
|
||||
func numberptr(v json.Number) *json.Number { return &v }
|
||||
func numberptr3(v json.Number) ***json.Number { vv := &v; vvv := &vv; return &vvv }
|
||||
func sliceptr(v []int) *[]int { return &v }
|
||||
func arrayptr(v [2]int) *[2]int { return &v }
|
||||
func mapptr(v map[string]int) *map[string]int { return &v }
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -429,6 +429,8 @@ func convertPtrOp(code *Opcode) OpType {
|
|||
return OpBoolPtr
|
||||
case OpBytes:
|
||||
return OpBytesPtr
|
||||
case OpNumber:
|
||||
return OpNumberPtr
|
||||
case OpArray:
|
||||
return OpArrayPtr
|
||||
case OpSlice:
|
||||
|
|
|
@ -2420,7 +2420,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
}
|
||||
if p != 0 {
|
||||
b = appendIndent(ctx, b, code.Indent+1)
|
||||
b = append(b, code.EscapedKey...)
|
||||
b = append(b, ' ')
|
||||
bb, err := appendNumber(b, ptrToNumber(p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -2426,7 +2426,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
}
|
||||
if p != 0 {
|
||||
b = appendIndent(ctx, b, code.Indent+1)
|
||||
b = append(b, code.Key...)
|
||||
b = append(b, ' ')
|
||||
bb, err := appendNumber(b, ptrToNumber(p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue