目录
package fib
import (
"testing"
)
// var a int
// var b int
func TestFibList(t *testing.T) {
//var a int = 1
//var b int = 1
/* var (
a int = 1
b int = 1
) */
/* a := 1
b := 1 */
a := 1
b := 1
t.Log(" ", a)
for i := 0; i < 5; i++ {
t.Log(" ", b)
tmp := a
a = b
b = tmp + a
}
t.Log()
}
func TestExchange(t *testing.T) {
a := 1
b := 2
// tmp := a
// a = b
// b = tmp
a, b = b, a
t.Log(a, b)
}
// 常量代码演示
package consttest
import "testing"
const (
Monday = iota + 1
Tuesday
Wendnesday
)
// 位运算
const (
Read = 1 << iota
Write
Excute
)
func TestConstTry(t *testing.T) {
t.Log(Tuesday, Wendnesday)
}
func TestConstTry1(t *testing.T) {
a := 7
t.Log(a&Read == Read, a&Write == Write, a&Excute == Excute)
}