github.com/iDigitalFlame/xmt@v0.5.4/device/regedit/entry_test.go (about) 1 // Copyright (C) 2020 - 2023 iDigitalFlame 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program. If not, see <https://www.gnu.org/licenses/>. 15 // 16 17 package regedit 18 19 import ( 20 "testing" 21 22 "github.com/iDigitalFlame/xmt/device/winapi/registry" 23 ) 24 25 func TestEntry(t *testing.T) { 26 e := Entry{ 27 Data: []byte{0xFF, 0x0, 0x10, 0x20}, 28 Type: registry.TypeDword, 29 } 30 v, err := e.ToInteger() 31 if err != nil { 32 t.Fatalf("TestEntry(): ToInteger returned an error: %s", err.Error()) 33 } 34 if v != 0x201000FF { 35 t.Fatalf(`TestEntry(): ToInteger result "0x%X" does not match expected "0x201000FF"!`, v) 36 } 37 z := Entry{ 38 Data: []byte{0xFF, 0, 0x10, 0x20, 0x40, 0x40, 0x40, 0x50}, 39 Type: registry.TypeQword, 40 } 41 if v, err = z.ToInteger(); err != nil { 42 t.Fatalf("TestEntry(): ToInteger returned an error: %s", err.Error()) 43 } 44 if v != 0x50404040201000FF { 45 t.Fatalf(`TestEntry(): ToInteger result "0x%X" does not match expected "0x50404040201000FF"!"`, v) 46 } 47 }