Skip to content

Commit 66feca2

Browse files
committed
🎨 go-06
1 parent 82f0025 commit 66feca2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

go-06/array_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package go_06
22

33
import "testing"
44

5+
//数组
56
func TestArray(t *testing.T) {
67
var arr [3]int
78
t.Log(arr[1])
@@ -18,4 +19,18 @@ func TestArrayTravel(t *testing.T) {
1819
}
1920

2021
t.Log(arr[1:len(arr)])
22+
}
23+
24+
//切片
25+
func TestSliceInit(t *testing.T) {
26+
var s[] int
27+
t.Log(len(s),cap(s))
28+
s=append(s,1)
29+
t.Log(len(s),cap(s))
30+
31+
s1:=[] int{1,2,3}
32+
t.Log(len(s1),cap(s1))
33+
34+
s2:=make ([]int,2,3)
35+
t.Log(len(s2),cap(s2))
2136
}

0 commit comments

Comments
 (0)