package acl_test import ( "testing" "github.com/stretchr/testify/assert" "gitstore.ru/tolikproh/policy/acl" ) func Test_Verify(t *testing.T) { t.Run("Verify AclBits", func(t *testing.T) { for i := 0; i < 63; i++ { a := acl.New(acl.NumBit(i)) assert.Equal(t, true, a.Verify(acl.NumBit(i))) } }) t.Run("NotValid AclBits", func(t *testing.T) { for i := -63; i == 0; i++ { a := acl.New(acl.NumBit(i)) assert.NotEqual(t, true, a.Verify(acl.NumBit(i))) } }) } func Test_VerifyOr(t *testing.T) { t.Run("VarifyOr AclBits", func(t *testing.T) { a := acl.AllBit for i := 0; i < 63; i++ { assert.Equal(t, true, a.VerifyOr(acl.NumBit(i))) } }) t.Run("NotValid AclBits", func(t *testing.T) { a := acl.AllBit for i := -63; i == 0; i++ { assert.NotEqual(t, true, a.VerifyOr(acl.NumBit(i))) } }) } func Test_VerifyAnd(t *testing.T) { t.Run("VarifyOr AclBits", func(t *testing.T) { a := acl.AllBit for i := 0; i < 63; i++ { assert.Equal(t, true, a.VerifyAnd(acl.NumBit(i))) } }) t.Run("NotValid AclBits", func(t *testing.T) { a := acl.AllBit for i := -63; i == 0; i++ { assert.NotEqual(t, true, a.VerifyAnd(acl.NumBit(i))) } }) } func Test_VerifyMask(t *testing.T) { a := acl.AllBit t.Run("VarifyMask AclBits", func(t *testing.T) { for i := 0; i < 63; i++ { assert.Equal(t, true, a.VerifyMask(acl.New(acl.NumBit(i)))) } }) a = 0 t.Run("NotValid AclBits", func(t *testing.T) { for i := 0; i < 63; i++ { assert.NotEqual(t, true, a.VerifyMask(acl.New(acl.NumBit(i)))) } }) } func Test_Unite(t *testing.T) { a := acl.New(0, 1, 6, 9, 10) b := acl.New(3, 7, 16, 26, 35) c := acl.New(42, 46, 54, 59, 61) equal := acl.New(0, 1, 6, 9, 10, 3, 7, 16, 26, 35, 42, 46, 54, 59, 61) notEqual := acl.New(2, 4, 5) t.Run("Unite AclBits", func(t *testing.T) { for i := 0; i < 63; i++ { assert.Equal(t, equal, acl.Unite(a, b, c)) } }) t.Run("NotUnite AclBits", func(t *testing.T) { assert.NotEqual(t, notEqual, acl.Unite(a, b, c)) }) }