gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/mount/scuzz/ata_test.go (about) 1 // Copyright 2019 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package scuzz 6 7 import ( 8 "testing" 9 ) 10 11 func TestAtaString(t *testing.T) { 12 want := "Copyright 2019 the u" 13 got := ataString([]byte{ 14 'o', 'C', 15 'y', 'p', 16 'i', 'r', 17 'h', 'g', 18 ' ', 't', 19 '0', '2', 20 '9', '1', 21 't', ' ', 22 'e', 'h', 23 'u', ' ', 24 }) 25 26 if got != want { 27 t.Fatalf("Got %v, want %v", got, want) 28 } 29 } 30 31 func TestMustLBA(t *testing.T) { 32 var data dataBlock 33 34 w, err := data.toWordBlock() 35 if err != nil { 36 t.Fatalf("toWordBlock: got %v, want nil", err) 37 } 38 39 if err := w.mustLBA(); err == nil { 40 t.Errorf("bad mustLBA: got nil, want x") 41 } 42 43 data[0], data[49*2], data[83*2], data[86*2] = 0x80, 0x2, 0x40, 0x4 44 45 w, err = data.toWordBlock() 46 if err != nil { 47 t.Fatalf("toWordBlock: got %v, want nil", err) 48 } 49 50 if err := w.mustLBA(); err != nil { 51 t.Errorf("good mustLBA: got %v, want nil", err) 52 } 53 }