...
1
2
3
4
5
6 package main
7
8 import "testing"
9
10
11 func lenMap_ssa(v map[int]int) int {
12 return len(v)
13 }
14
15 func testLenMap(t *testing.T) {
16
17 v := make(map[int]int)
18 v[0] = 0
19 v[1] = 0
20 v[2] = 0
21
22 if want, got := 3, lenMap_ssa(v); got != want {
23 t.Errorf("expected len(map) = %d, got %d", want, got)
24 }
25 }
26
27 func testLenNilMap(t *testing.T) {
28
29 var v map[int]int
30 if want, got := 0, lenMap_ssa(v); got != want {
31 t.Errorf("expected len(nil) = %d, got %d", want, got)
32 }
33 }
34 func TestMap(t *testing.T) {
35 testLenMap(t)
36 testLenNilMap(t)
37 }
38
View as plain text