FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
go/extra/binary_as_string_codec_test.go at master · json-iterator/go · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Dec 15, 2025. It is now read-only.
json-iterator
/
go
Public archive
Notifications
You must be signed in to change notification settings
Fork
1.1k
Star
13.9k
Code
Issues
208
Pull requests
64
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
go
/
extra
/
binary_as_string_codec_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (29 loc) · 837 Bytes
Breadcrumbs
go
/
extra
/
binary_as_string_codec_test.go
Copy path
File metadata and controls
32 lines (29 loc) · 837 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package
extra
import
(
"github.com/json-iterator/go"
"github.com/stretchr/testify/require"
"testing"
)
func
init
() {
jsoniter
.
RegisterExtension
(
&
BinaryAsStringExtension
{})
}
func
TestBinaryAsStringCodec
(
t
*
testing.
T
) {
t
.
Run
(
"safe set"
,
func
(
t
*
testing.
T
) {
should
:=
require
.
New
(
t
)
output
,
err
:=
jsoniter
.
Marshal
([]
byte
(
"hello"
))
should
.
NoError
(
err
)
should
.
Equal
(
`"hello"`
,
string
(
output
))
var
val
[]
byte
should
.
NoError
(
jsoniter
.
Unmarshal
(
output
,
&
val
))
should
.
Equal
(
`hello`
,
string
(
val
))
})
t
.
Run
(
"non safe set"
,
func
(
t
*
testing.
T
) {
should
:=
require
.
New
(
t
)
output
,
err
:=
jsoniter
.
Marshal
([]
byte
{
1
,
2
,
3
,
23
})
should
.
NoError
(
err
)
should
.
Equal
(
`"\\x01\\x02\\x03\\x17"`
,
string
(
output
))
var
val
[]
byte
should
.
NoError
(
jsoniter
.
Unmarshal
(
output
,
&
val
))
should
.
Equal
([]
byte
{
1
,
2
,
3
,
23
},
val
)
})
}
Back
|
FazBrowse Home
|
New Git URL