Debian Codegraph @

bdoor/word_amd64_test.go

raw
1 // Copyright 2016 VMware, Inc. All Rights Reserved.
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 package bdoor
16
17 import (
18 "github.com/vmware/vmw-guestinfo/internal"
19 "testing"
20 )
21
22 func TestSetWord(t *testing.T) {
23 inLow := uint16(0xEEFF)
24 inHigh := uint16(0xBBBB)
25
26 out := &UInt32{}
27 //out.SetWord(uint32(0xBBBBEEFF))
28 out.Low = inLow
29 out.High = inHigh
30
31 internal.AssertEqual(t, inLow, out.Low)
32 internal.AssertEqual(t, inHigh, out.High)
33
34 internal.AssertEqual(t, uint32(0xBBBBEEFF), out.Word())
35 }
36
37 func TestQuadToHighLow(t *testing.T) {
38 in := uint64(0xFFFFFFFF0000000A)
39
40 var u UInt64
41 u.SetQuad(in)
42 internal.AssertEqual(t, uint32(in), u.Low.Word())
43 internal.AssertEqual(t, uint32(in>>32), u.High.Word())
44 internal.AssertEqual(t, in, u.Quad())
45 }
46
47 func TestHighLowToQuad(t *testing.T) {
48 inHigh := uint16(0xff)
49 inLow := uint16(0xaa)
50
51 u := UInt64{
52 High: UInt32{High: inHigh},
53 Low: UInt32{Low: inLow},
54 }
55
56 internal.AssertEqual(t, (uint64(inHigh)<<48)+uint64(inLow), u.Quad())
57 }