Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ld
go-ld-prime
Commits
1c0d42f8
Unverified
Commit
1c0d42f8
authored
Apr 28, 2021
by
Will Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
secondary round-trip test
parent
1bfa8fb3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
codec/dagjson/roundtripBytes_test.go
codec/dagjson/roundtripBytes_test.go
+32
-0
No files found.
codec/dagjson/roundtripBytes_test.go
View file @
1c0d42f8
...
...
@@ -40,3 +40,35 @@ func TestRoundtripBytes(t *testing.T) {
Wish
(
t
,
nb
.
Build
(),
ShouldEqual
,
byteNode
)
})
}
var
encapsulatedNode
=
fluent
.
MustBuildMap
(
basicnode
.
Prototype__Map
{},
1
,
func
(
na
fluent
.
MapAssembler
)
{
na
.
AssembleEntry
(
"/"
)
.
CreateMap
(
1
,
func
(
sa
fluent
.
MapAssembler
)
{
sa
.
AssembleEntry
(
"bytes"
)
.
AssignBytes
([]
byte
(
"deadbeef"
))
})
})
var
encapsulatedSerial
=
`{
"/": {
"bytes": {
"/": {
"bytes": "ZGVhZGJlZWY="
}
}
}
}
`
func
TestEncapsulatedBytes
(
t
*
testing
.
T
)
{
t
.
Run
(
"encoding"
,
func
(
t
*
testing
.
T
)
{
var
buf
bytes
.
Buffer
err
:=
Encode
(
encapsulatedNode
,
&
buf
)
Require
(
t
,
err
,
ShouldEqual
,
nil
)
Wish
(
t
,
buf
.
String
(),
ShouldEqual
,
encapsulatedSerial
)
})
t
.
Run
(
"decoding"
,
func
(
t
*
testing
.
T
)
{
buf
:=
strings
.
NewReader
(
encapsulatedSerial
)
nb
:=
basicnode
.
Prototype__Map
{}
.
NewBuilder
()
err
:=
Decode
(
nb
,
buf
)
Require
(
t
,
err
,
ShouldEqual
,
nil
)
Wish
(
t
,
nb
.
Build
(),
ShouldEqual
,
encapsulatedNode
)
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment