#make sure the relevant folder with our libraries is in the require path lib_path=File.expand_path(File.dirname(__FILE__)+"//..//lib") $:.unshift(lib_path) unless $:.include?(lib_path) require 'test/unit' require 'DSK' class TestNADOLDisks 0,"#{dskname} should have at least one file") nadol_file=dsk.files["NADOL"] assert(nadol_file!=nil,"#{dskname} should have a file called NADOL") assert(nadol_file.to_s.length==16128,"NADOL should be 16128 bytes long") assert(nadol_file.respond_to?(:disassembly),"NADOL can be disassembled") assert(!NADOLTokenisedFile.can_be_nadol_tokenised_file?(nadol_file.contents),"NADOL should not be NADOL tokenised file") brickout_file=dsk.files["BRICKOUT"] assert(brickout_file!=nil,"#{dskname} should have a file called BRICKOUT") assert(NADOLTokenisedFile.can_be_nadol_tokenised_file?(dsk.files["BRICKOUT"].contents),"BRICKOUT should be NADOL tokenised file") assert(nadol_file.respond_to?(:disassembly),"BRICKOUT can't be disassembled") s=brickout_file.to_s assert(!brickout_file.can_be_picture?,"BRICK-OUT should NOT be viewable as a picture") assert_equal("; LORES BRICK-OUT GAME",s[0..21],"BRICK-OUT source should detokenise") assert_equal("; @ \"NAIII\"",dsk.files["NAIII"].to_s[0..10],"NAIII source should detokenise") test_file=NADOLFile.new("TESTFILE","Is this mike on?") assert(test_file!=dsk.files["LOGO"],"comparison between files doesn't have false positive") dsk.add_file(test_file) assert(dsk.files[test_file.filename]!=nil,"#{dskname} should have a file called #{test_file.filename}") assert_equal(test_file,dsk.files[test_file.filename]) #try to round_trip a tokenised NADOL file copy_of_tokenised_file=dsk.make_file("BBALL2",dsk.files["BOUNCINGBALL"].to_s,{:tokenise=>true}) assert_equal(dsk.files["BOUNCINGBALL"].to_s,copy_of_tokenised_file.to_s,"NADOL tokenised file should round-trip") dsk.add_file(copy_of_tokenised_file) #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.make_file("TEST#{i}","TEST #{i} "+"*"*i*100) test_files<