Skip to content

Commit

Permalink
test: unsupported-type field for pointer struct
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Nov 8, 2023
1 parent b01c393 commit 25b7d86
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
5 changes: 3 additions & 2 deletions external_jsonlib_test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/buger/jsonparser v1.1.1
github.com/bytedance/sonic v1.9.1
github.com/bytedance/sonic v1.10.0-rc
github.com/gin-gonic/gin v1.1.3
github.com/goccy/go-json v0.10.2
github.com/json-iterator/go v1.1.12
Expand All @@ -14,7 +14,8 @@ require (
)

require (
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
Expand Down
11 changes: 5 additions & 6 deletions external_jsonlib_test/go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo=
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -23,6 +21,7 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739 h1:ykXz+pRRTibcSjG1yRhpdSHInF8yZY/mfn+Rz2Nd1rE=
github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739/go.mod h1:zUx1mhth20V3VKgL5jbd1BSQcW4Fy6Qs4PZvQwRFwzM=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
42 changes: 21 additions & 21 deletions external_jsonlib_test/unit_test/issue_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2023 CloudWeGo Authors
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,32 +15,32 @@
package unit_test

import (
"github.com/gin-gonic/gin"
"github.com/bytedance/sonic"
"context"
"encoding/json"
"net/http"
"testing"

"github.com/bytedance/sonic"
jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)

func TestContext(t *testing.T) {
var obj = new(Context)
obj.Context = context.Background()
obj.Context = context.WithValue(obj.Context, "a", "b")
obj.GinCtx = new(gin.Context)
obj.GinCtx.Accepted = []string{"1"}
out, err := sonic.Marshal(obj)
if err != nil {
t.Fatal(err)
}
println(string(out))
err = sonic.Unmarshal(out, obj)
if err != nil {
t.Fatal(err)
}
out1, err1 := jsoniter.Marshal(obj)
out2, err2 := json.Marshal(obj)
println(string(out2))
assert.Equal(t, err2 ==nil, err1 ==nil)
assert.Equal(t, err2 ==nil, err ==nil)
assert.Equal(t, out2, out1)
assert.Equal(t, out2, out)
// err = sonic.Unmarshal(out, obj)
// if err != nil {
// t.Fatal(err)
// }
}


type Context struct {
context.Context
GinCtx *gin.Context
*http.Request
}

1 change: 1 addition & 0 deletions internal/encoder/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ func (self *_Compiler) compileRec(p *_Program, sp int, vt reflect.Type, pv bool)
}

func (self *_Compiler) compileOps(p *_Program, sp int, vt reflect.Type) {
println("vt:", vt.String())
switch vt.Kind() {
case reflect.Bool : p.add(_OP_bool)
case reflect.Int : p.add(_OP_int())
Expand Down

0 comments on commit 25b7d86

Please sign in to comment.