-
Notifications
You must be signed in to change notification settings - Fork 0
/
util_test.go
executable file
·66 lines (60 loc) · 1.79 KB
/
util_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package lrucache
import (
"fmt"
"testing"
"unsafe"
)
func TestSizeof(t *testing.T) {
var a bool = true
fmt.Println("a Bool size:", Sizeof(a))
var b int = 1
fmt.Println("b int size:", Sizeof(b))
var c int8 = 2
fmt.Println("c int8 size:", Sizeof(c))
var d int16 = 3
fmt.Println("d int16 size:", Sizeof(d))
var e int32 = 4
fmt.Println("e int32 size:", Sizeof(e))
var f int64 = 5
fmt.Println("f int64 size:", Sizeof(f))
var g uint = 6
fmt.Println("g uint size:", Sizeof(g))
var h uint8 = 7
fmt.Println("h uint8 size:", Sizeof(h))
var i uint16 = 8
fmt.Println("i uint16 size:", Sizeof(i))
var j uint32 = 9
fmt.Println("j uint32 size:", Sizeof(j))
var k uint64 = 10
fmt.Println("k uint64 size:", Sizeof(k))
var l uintptr = uintptr(4)
fmt.Println("l uintptr size:", Sizeof(l))
var m float32 = 1.0
fmt.Println("m float32 size:", Sizeof(m))
var n float64 = 2.0
fmt.Println("n float64 size:", Sizeof(n))
var o complex64 = 3i + 1
fmt.Println("o complex64 size:", Sizeof(o))
var p complex128 = 4i + 2
fmt.Println("p complex128 size:", Sizeof(p))
var q func() = func() {}
fmt.Println("q func() size:", Sizeof(q))
var r unsafe.Pointer = unsafe.Pointer(&c)
fmt.Println("r unsafe.Pointer size:", Sizeof(r))
var s string = "123"
fmt.Println("s string size:", Sizeof(s))
var t1 interface{} = s
fmt.Println("t interface{} size:", Sizeof(t1))
var u *int = &b
fmt.Println("u *int size:", Sizeof(u))
var v = [5]int{1, 2, 3, 4, 5}
fmt.Println("v array size:", Sizeof(v))
var w = make([]bool, 0, 10)
fmt.Println("w slice size:", Sizeof(w))
var x = make(map[bool]bool)
fmt.Println("x map size:", Sizeof(x))
var y = make(chan bool)
fmt.Println("y chan size:", Sizeof(y))
var z = struct{}{}
fmt.Println("z struct size:", Sizeof(z))
}