ProDOS-Utilities/prodos/file_test.go

42 lines
838 B
Go
Raw Permalink Normal View History

2024-03-12 02:16:02 +00:00
// Copyright Terence J. Boldt (c)2021-2024
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
package prodos
import (
"fmt"
"testing"
)
2023-01-22 15:01:57 +00:00
func TestCreateBlocklist(t *testing.T) {
var tests = []struct {
2024-03-11 13:05:23 +00:00
fileSize uint32
wantBlocks uint16
}{
{1, 1},
{512, 1},
{513, 3},
{2048, 5},
{2049, 6},
{17128, 35},
}
virtualDisk := NewMemoryFile(0x2000000)
CreateVolume(virtualDisk, "VIRTUAL.DISK", 0xFFFE)
for _, tt := range tests {
testname := fmt.Sprintf("%d", tt.fileSize)
t.Run(testname, func(t *testing.T) {
blockList, err := createBlockList(virtualDisk, tt.fileSize)
if err != nil {
t.Error("got error, want nil")
}
2024-03-11 13:05:23 +00:00
if uint16(len(blockList)) != tt.wantBlocks {
t.Errorf("got %d blocks, want %d", len(blockList), tt.wantBlocks)
}
})
}
}