package bootsect import ( "encoding/binary" "testing" ) func TestParseBootSectorUsesCorrectFieldWidths(t *testing.T) { data := make([]byte, 512) copy(data[0x03:], []byte("NTFS ")) binary.LittleEndian.PutUint16(data[0x0B:], 512) data[0x0D] = 8 data[0x15] = 0xF8 binary.LittleEndian.PutUint16(data[0x18:], 63) binary.LittleEndian.PutUint16(data[0x1A:], 255) binary.LittleEndian.PutUint32(data[0x1C:], 0x11223344) binary.LittleEndian.PutUint64(data[0x28:], 0x0102030405060708) binary.LittleEndian.PutUint64(data[0x30:], 0x1112131415161718) binary.LittleEndian.PutUint64(data[0x38:], 0x2122232425262728) data[0x40] = 0xF6 data[0x44] = 1 copy(data[0x48:], []byte{1, 2, 3, 4, 5, 6, 7, 8}) boot, err := Parse(data) if err != nil { t.Fatalf("Parse failed: %v", err) } if boot.SectorsPerCluster != 8 { t.Fatalf("SectorsPerCluster = %d, want 8", boot.SectorsPerCluster) } if boot.HiddenSectors != 0x11223344 { t.Fatalf("HiddenSectors = %#x, want %#x", boot.HiddenSectors, 0x11223344) } if boot.FileRecordSegmentSizeInBytes != 1024 { t.Fatalf("FileRecordSegmentSizeInBytes = %d, want 1024", boot.FileRecordSegmentSizeInBytes) } if boot.IndexBufferSizeInBytes != 4096 { t.Fatalf("IndexBufferSizeInBytes = %d, want 4096", boot.IndexBufferSizeInBytes) } }