go_study/src/c4_operator_test/operator_test.go
2023-03-01 11:23:26 +08:00

31 lines
579 B
Go

package operator_test
import "testing"
// 数组比较
func TestCompareArray(t *testing.T) {
a := [...]int{1, 2, 3, 4}
b := [...]int{1, 2, 3, 5}
d := [...]int{1, 2, 3, 4}
t.Log(a == b)
//c := [...]int{1, 2, 3, 4, 5}
//t.Log(a == c) //报错 长度不同不能比较
t.Log(a == d)
}
const (
// 位运算
Readable = 1 << iota
Writeable
Executable
)
func TestBitClear(t *testing.T) {
a := 7
a = a &^ Readable
a = a &^ Executable
t.Log(a&Readable, a&Writeable, a&Executable)
t.Log(a&Readable == Readable, a&Writeable == Writeable, a&Executable == Executable)
}