secondary round-trip test
@@ -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)
+ })
+}
