Skip to content

Commit

Permalink
addjust build tag
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed May 31, 2024
1 parent 9df99d8 commit d53c455
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion compat.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !amd64,!arm64 !go1.17 go1.23
// +build !amd64,!arm64 go1.23 !go1.17 arm64,!go1.20

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion decode_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.17,!go1.23 arm64,go1.17,!go1.23
// +build amd64,go1.17,!go1.23 arm64,go1.20,!go1.23

/*
* Copyright 2021 ByteDance Inc.
Expand Down
1 change: 0 additions & 1 deletion decoder/decoder_native.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//go:build (amd64 && go1.16 && !go1.23) || (arm64 && go1.20 && !go1.23)
// +build amd64,go1.16,!go1.23 arm64,go1.20,!go1.23


Expand Down
37 changes: 35 additions & 2 deletions decoder/decoder_native_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//go:build (amd64 && go1.16 && !go1.23) || (arm64 && go1.20 && !go1.23)
// +build amd64,go1.16,!go1.23 arm64,go1.20,!go1.23


Expand Down Expand Up @@ -275,4 +274,38 @@ func BenchmarkSkip_Sonic(b *testing.B) {
for i:=0; i<b.N; i++ {
_, _ = Skip(data)
}
}
}


func TestDecodeCorrupt(t *testing.T) {
var ds = []string{
`{,}`,
`{,"a"}`,
`{"a":}`,
`{"a":1,}`,
`{"a":1,"b"}`,
`{"a":1,"b":}`,
`{,"a":1 "b":2}`,
`{"a",:1 "b":2}`,
`{"a":,1 "b":2}`,
`{"a":1 "b",:2}`,
`{"a":1 "b":,2}`,
`{"a":1 "b":2,}`,
`{"a":1 "b":2}`,
`[,]`,
`[,1]`,
`[1,]`,
`[,1,2]`,
`[1,2,]`,
}
for _, d := range ds {
var o interface{}
_, err := decode(d, &o, false)
if err == nil {
t.Fatalf("%#v", d)
}
if !strings.Contains(err.Error(), "Syntax error"){

Check failure on line 307 in decoder/decoder_native_test.go

View workflow job for this annotation

GitHub Actions / build (1.20.x, arm)

undefined: strings

Check failure on line 307 in decoder/decoder_native_test.go

View workflow job for this annotation

GitHub Actions / build (1.21.x, arm)

undefined: strings

Check failure on line 307 in decoder/decoder_native_test.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

undefined: strings

Check failure on line 307 in decoder/decoder_native_test.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

undefined: strings

Check failure on line 307 in decoder/decoder_native_test.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

undefined: strings

Check failure on line 307 in decoder/decoder_native_test.go

View workflow job for this annotation

GitHub Actions / build (1.18.x)

undefined: strings

Check failure on line 307 in decoder/decoder_native_test.go

View workflow job for this annotation

GitHub Actions / build (1.17.x)

undefined: strings

Check failure on line 307 in decoder/decoder_native_test.go

View workflow job for this annotation

GitHub Actions / build (1.22.x)

undefined: strings
t.Fatal(err.Error())
}
}
}
34 changes: 0 additions & 34 deletions decoder/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
`encoding/json`
`runtime`
`runtime/debug`
`strings`
`sync`
`testing`
`time`
Expand Down Expand Up @@ -191,39 +190,6 @@ func TestSkipMismatchTypeError(t *testing.T) {
})
}

func TestDecodeCorrupt(t *testing.T) {
var ds = []string{
`{,}`,
`{,"a"}`,
`{"a":}`,
`{"a":1,}`,
`{"a":1,"b"}`,
`{"a":1,"b":}`,
`{,"a":1 "b":2}`,
`{"a",:1 "b":2}`,
`{"a":,1 "b":2}`,
`{"a":1 "b",:2}`,
`{"a":1 "b":,2}`,
`{"a":1 "b":2,}`,
`{"a":1 "b":2}`,
`[,]`,
`[,1]`,
`[1,]`,
`[,1,2]`,
`[1,2,]`,
}
for _, d := range ds {
var o interface{}
_, err := decode(d, &o, false)
if err == nil {
t.Fatalf("%#v", d)
}
if !strings.Contains(err.Error(), "Syntax error"){
t.Fatal(err.Error())
}
}
}

func TestDecodeOption(t *testing.T) {
var s string
var d *Decoder
Expand Down
2 changes: 1 addition & 1 deletion encode_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.17,!go1.23 arm64,go1.17,!go1.23
// +build amd64,go1.17,!go1.23 arm64,go1.20,!go1.23

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion encoder/encoder_compat.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !amd64,!arm64 !go1.17 go1.23
// +build !amd64,!arm64 go1.23 !go1.16 arm64,!go1.20

/*
* Copyright 2023 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion encoder/encoder_native.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.17,!go1.23 arm64,go1.17,!go1.23
// +build amd64,go1.16,!go1.23 arm64,go1.20,!go1.23

/*
* Copyright 2023 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion encoder/encoder_native_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.17,!go1.23 arm64,go1.17,!go1.23
// +build amd64,go1.16,!go1.23 arm64,go1.20,!go1.23

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion encoder/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func TestEncoder_Marshal_EscapeHTML_LargeJson(t *testing.T) {
require.NoError(t, err1)
buf2, err2 :=json.Marshal(&_BindingValue)
require.NoError(t, err2)
require.Equal(t, buf1, buf2)
require.Equal(t, string(buf1), string(buf2))
}

var _GenericValue interface{}
Expand Down
2 changes: 1 addition & 1 deletion search_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.17,!go1.23 arm64,go1.17,!go1.23
// +build amd64,go1.17,!go1.23 arm64,go1.20,!go1.23

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion sonic.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.17,!go1.23 arm64,go1.17,!go1.23
// +build amd64,go1.17,!go1.23 arm64,go1.20,!go1.23

/*
* Copyright 2021 ByteDance Inc.
Expand Down

0 comments on commit d53c455

Please sign in to comment.