github.com/fafucoder/cilium@v1.6.11/common/types/ipv4_test.go (about) 1 // Copyright 2019 Authors of Cilium 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // +build !privileged_tests 16 17 package types 18 19 import ( 20 "net" 21 "testing" 22 23 "github.com/cilium/cilium/pkg/checker" 24 25 "gopkg.in/check.v1" 26 ) 27 28 var testIPv4Address IPv4 = [4]byte{10, 0, 0, 2} 29 30 // Hook up gocheck into the "go test" runner. 31 func Test(t *testing.T) { 32 check.TestingT(t) 33 } 34 35 type IPv4Suite struct{} 36 37 var _ = check.Suite(&IPv4Suite{}) 38 39 func (s *IPv4Suite) TestIP(c *check.C) { 40 var expectedAddress net.IP 41 expectedAddress = []byte{10, 0, 0, 2} 42 result := testIPv4Address.IP() 43 44 c.Assert(result, checker.DeepEquals, expectedAddress) 45 } 46 47 func (s *IPv4Suite) TestString(c *check.C) { 48 expectedStr := "10.0.0.2" 49 result := testIPv4Address.String() 50 51 c.Assert(result, check.Equals, expectedStr) 52 }