31 lines
579 B
Go
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)
|
|
}
|