require 'testhelper' class A2WriteTests < Test::Unit::TestCase def test_cpm_dsk dsk=RipXplore.create_new(:AppleCPM) test_string="Is this mike on?" test_file=dsk.add_file(:CPMFile,"TESTFILE.TXT",test_string) assert(test_file.kind_of?(NativeFileType),"add_file should return a subclass of NativeFileType (was #{test_file.class})") assert(test_file.kind_of?(CPMFile),"add_file should return a NativeFileType of appropriate subclass (was #{test_file.class})") assert_equal("TESTFILE.TXT",test_file.full_filename, "file fullname should include file extension exactly once") assert(dsk.files[test_file.full_filename]!=nil,"dsk should have a file called #{test_file.full_filename}") assert_equal(test_file.contents,dsk.files[test_file.full_filename].contents) test_file=dsk.add_file(:CPMFile,"BIGFILE.TXT","Is this mike on?"+"x"*38000) assert_equal(test_file.contents,dsk.files[test_file.full_filename].contents) test_file=dsk.add_file(:CPMFile,"NO_TYPE","this file has no extension") assert(dsk.files["NO_TYPE."]!=nil,"dsk should have a file called NO_TYPE.") test_file=dsk.add_file(:CPMFile,"NO_TYPE2.","this file has a dot but no extension") assert(dsk.files["NO_TYPE2."]!=nil,"dsk should have a file called NO_TYPE2.") #test we can add the same file multiple times without raising an exception 100.times do test_file=dsk.add_file(:CPMFile,"TESTFILE.TXT",test_string) end #save disk for later examination dsk.save_as("test_images/applecpm_write_test.dsk") end def test_dos_dsk dsk=RipXplore.create_new(:AppleDos) test_file=dsk.add_file(:AppleText,"TESTFILE","Is this mike on?") assert(test_file.kind_of?(NativeFileType),"add_file should return a subclass of NativeFileType (was #{test_file.class})") assert(test_file.kind_of?(AppleText),"add_file should return a NativeFileType of appropriate subclass (was #{test_file.class})") assert(dsk.files[test_file.filename]!=nil,"dsk should have a file called #{test_file.filename}") assert_equal(test_file.to_text,dsk.files[test_file.filename].to_text) # puts dsk.dump_sector(0x11,0x0f) dsk.add_file(:Applesoft,"HELLO","replacement HELLO") # puts dsk.dump_sector(0x11,0x0f) # puts dsk.catalog assert(dsk.files[test_file.filename]!=nil,"dsk still should have a file called #{test_file.filename} after replacing HELLO") assert_equal(test_file.to_text,dsk.files[test_file.filename].to_text) #test we can write muliple files (this also tests we are correctly tracking sectors as being used) test_files=[] for i in 0..20 t=dsk.add_file(:AppleText,"TEST#{i}","TEST #{i} "+"*"*i*100) test_files<