mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2026-03-13 10:02:05 +08:00
添加 structures
This commit is contained in:
30
structures/NestedInterger_test.go
Normal file
30
structures/NestedInterger_test.go
Normal 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())
|
||||
}
|
||||
Reference in New Issue
Block a user