...

Source file src/github.com/launchdarkly/go-jsonstream/v3/jwriter/writer_array_test.go

Documentation: github.com/launchdarkly/go-jsonstream/v3/jwriter

     1  package jwriter
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func TestArrayState(t *testing.T) {
    11  	w := NewWriter()
    12  	a := w.Array()
    13  
    14  	a.Null()
    15  	a.Bool(true)
    16  	a.Int(3)
    17  	a.Float64(4.5)
    18  	a.String("five")
    19  
    20  	aa := a.Array()
    21  	aa.Int(6)
    22  	aa.End()
    23  
    24  	ao := a.Object()
    25  	ao.Name("seven").Int(7)
    26  	ao.End()
    27  
    28  	a.End()
    29  
    30  	require.NoError(t, w.Error())
    31  	expected := `[null,true,3,4.5,"five",[6],{"seven":7}]`
    32  	assert.JSONEq(t, expected, string(w.Bytes()))
    33  }
    34  

View as plain text