Fix bug in PascalFormatDisk 800K; add Pascal unit tests.

This commit is contained in:
John B. Matthews 2008-05-24 16:32:43 +00:00
parent 058608b124
commit 21abbe3433
3 changed files with 73 additions and 11 deletions

View File

@ -49,10 +49,6 @@ public class PascalFormatDisk extends FormattedDisk {
* The size of the Pascal file entry.
*/
public static final int ENTRY_SIZE = 26;
/**
* The number of Pascal blocks on a 140K disk.
*/
public static final int PASCAL_BLOCKS_ON_140K_DISK = 280;
// filetypes used elsewhere in the code:
private static final String TEXTFILE = "TEXT"; //$NON-NLS-1$
@ -66,9 +62,9 @@ public class PascalFormatDisk extends FormattedDisk {
"xdskfile", //$NON-NLS-1$
CODEFILE,
TEXTFILE,
"INFO", //$NON-NLS-1$
"INFO", //$NON-NLS-1$
DATAFILE,
"GRAF", //$NON-NLS-1$
"GRAF", //$NON-NLS-1$
"FOTO", //$NON-NLS-1$
"securedir" }; //$NON-NLS-1$
@ -563,7 +559,8 @@ public class PascalFormatDisk extends FormattedDisk {
AppleUtil.setWordValue(directory, 2, 6); // last directory block
AppleUtil.setWordValue(directory, 4, 0); // entry type (0=vol header)
// volume name should have been set in constructor!
AppleUtil.setWordValue(directory, 14, PASCAL_BLOCKS_ON_140K_DISK);
int blocks = getImageOrder().getBlocksOnDevice();
AppleUtil.setWordValue(directory, 14, blocks);
AppleUtil.setWordValue(directory, 16, 0); // no files
AppleUtil.setWordValue(directory, 18, 0); // first block
AppleUtil.setPascalDate(directory, 20, new Date()); // most recent date setting

View File

@ -40,7 +40,7 @@ import com.webcodepro.applecommander.util.TextBundle;
* @author Rob Greene
*/
public class AppleCommander {
public static final String VERSION = "1.3.4.2"; //$NON-NLS-1$
public static final String VERSION = "1.3.4.3"; //$NON-NLS-1$
private static TextBundle textBundle = UiBundle.getInstance();
/**
* Launch AppleCommander.

View File

@ -28,6 +28,7 @@ import com.webcodepro.applecommander.storage.FormattedDisk.DiskUsage;
import com.webcodepro.applecommander.storage.os.dos33.DosFormatDisk;
import com.webcodepro.applecommander.storage.os.dos33.OzDosFormatDisk;
import com.webcodepro.applecommander.storage.os.dos33.UniDosFormatDisk;
import com.webcodepro.applecommander.storage.os.pascal.PascalFormatDisk;
import com.webcodepro.applecommander.storage.os.prodos.ProdosFormatDisk;
import com.webcodepro.applecommander.storage.physical.ByteArrayImageLayout;
import com.webcodepro.applecommander.storage.physical.DosOrder;
@ -81,7 +82,30 @@ public class DiskWriterTest extends TestCase {
ImageOrder imageOrder = new NibbleOrder(imageLayout);
FormattedDisk[] disks = DosFormatDisk.create("write-test-dos33.nib", imageOrder); //$NON-NLS-1$
writeFiles(disks, "B", "T", false); //$NON-NLS-1$ //$NON-NLS-2$
saveImage = true;
saveDisks(disks);
}
/**
* Test writing and reading random files to a ProDOS 140K disk.
*/
public void testWriteToPascal140kDisk() throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = PascalFormatDisk.create(
"write-test-pascal-140k.po", "TEST", imageOrder); //$NON-NLS-1$ //$NON-NLS-2$
writeFiles(disks, "code", "text", false); //$NON-NLS-1$ //$NON-NLS-2$
saveDisks(disks);
}
/**
* Test writing and reading random files to a ProDOS 140K disk.
*/
public void testWriteToPascal800kDisk() throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = PascalFormatDisk.create(
"write-test-pascal-800k.po", "TEST", imageOrder); //$NON-NLS-1$ //$NON-NLS-2$
//writeFiles(disks, "code", "text", false); //$NON-NLS-1$ //$NON-NLS-2$
saveDisks(disks);
saveImage = false;
}
@ -158,6 +182,32 @@ public class DiskWriterTest extends TestCase {
saveDisks(disks);
}
/**
* Test creating and deleting many files on a Pascal 140K disk.
*/
public void testCreateAndDeletePascal140kDisk() throws IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = PascalFormatDisk.create(
"createanddelete-test-pascal-140k.po", "TEST", //$NON-NLS-1$ //$NON-NLS-2$
imageOrder);
createAndDeleteFiles(disks, "CODE"); //$NON-NLS-1$
saveDisks(disks);
}
/**
* Test creating and deleting many files on a Pascal 800K disk.
*/
public void testCreateAndDeletePascal800kDisk() throws IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = PascalFormatDisk.create(
"createanddelete-test-pascal-800k.po", "TEST", //$NON-NLS-1$ //$NON-NLS-2$
imageOrder);
createAndDeleteFiles(disks, "CODE"); //$NON-NLS-1$
saveDisks(disks);
}
/**
* Test creating and deleting many files on a ProDOS 140K disk.
*/
@ -176,9 +226,9 @@ public class DiskWriterTest extends TestCase {
*/
public void testCreateAndDeleteProdos800kDisk() throws IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create(
"createanddelete-test-prodos-800k.dsk", "TEST", //$NON-NLS-1$ //$NON-NLS-2$
"createanddelete-test-prodos-800k.po", "TEST", //$NON-NLS-1$ //$NON-NLS-2$
imageOrder);
createAndDeleteFiles(disks, "BIN"); //$NON-NLS-1$
saveDisks(disks);
@ -226,6 +276,21 @@ public class DiskWriterTest extends TestCase {
saveDisks(disks);
}
/**
* Test creating, deleting, and then creating another file which re-uses
* the old directory entry on a Pascal 140K disk.
*/
public void testCreateDeleteCreatePascalDisk()
throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = PascalFormatDisk.create(
"createdeletecreate-test-pascal-140k.po", "TEST", //$NON-NLS-1$ //$NON-NLS-2$
imageOrder);
createDeleteCreate(disks, "CODE"); //$NON-NLS-1$
saveDisks(disks);
}
/**
* Test creating, deleting, and then creating another file which re-uses
* the old directory entry on a ProDOS 140K disk.