添加 structures

This commit is contained in:
YDZ
2020-08-06 23:19:28 +08:00
parent ef3da5d363
commit 1934e384d2
18 changed files with 1079 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
package structures
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_NestedInteger(t *testing.T) {
ast := assert.New(t)
n := NestedInteger{}
ast.True(n.IsInteger())
n.SetInteger(1)
ast.Equal(1, n.GetInteger())
elem := NestedInteger{Num: 1}
expected := NestedInteger{
Num: 1,
Ns: []*NestedInteger{&elem},
}
n.Add(elem)
ast.Equal(expected, n)
ast.Equal(expected.Ns, n.GetList())
}