-- $Source: /commtar/monoBANK/CICS_INTF/fc_c_1.ada,v $ -- $Revision: 1.2 $ $Date: 88/03/23 15:20:41 $ $Author: chris $ with CICS_test_reporter; use CICS_test_reporter; with File_control_testing_utility; use File_control_testing_utility; with Host_character_pkg; use Host_character_pkg; with CICS_exceptions; use CICS_exceptions; ---------------- procedure fc_c_1 ---------------- is use Numbered_line_file_pkg; package NLF renames Numbered_line_file; Host_rec : Host_numbered_line_record; Rec : Numbered_line_record; Key : Count_type; begin Start_module("fc_c_1", "write-read-rewrite sequence for Data Type Files"); Flush_numbered_line_file; declare begin Start_test("fc_c_1_a", "write records to prime file"); for i in Key_range loop Key := Pad(integer'image(i), Count_length); Rec.Count := Key; Rec.Line := Pad( "This is record number " & integer'image(i), Line_length); NLF.Write(File=>Recfile, From=>To_host(Rec), Key=>To_host_string(Key)); end loop; Pass_test; exception when Not_open => Unexpected_exception("Not_open"); when Not_Found => Unexpected_exception("Not_found"); when Duplicate_key => Unexpected_exception("Duplicate_key"); when Duplicate_record => Unexpected_exception("Duplicate_record"); when End_file => Unexpected_exception("End_file"); when Others => Unexpected_exception("undocumented exception"); end; declare begin Start_test("fc_c_1_b", "read just written records from file"); for i in Key_range loop Key := Pad(integer'image(i), Key'length); NLF.Read(File=>Recfile, Element=>Host_rec, Key=>To_host_string(Key)); end loop; Pass_test; exception when Not_open => Unexpected_exception("Not_open"); when Not_Found => Unexpected_exception("Not_found"); when Duplicate_key => Unexpected_exception("Duplicate_key"); when Duplicate_record => Unexpected_exception("Duplicate_record"); when End_file => Unexpected_exception("End_file"); when Others => Unexpected_exception("undocumented exception"); end; declare Fail : Boolean := False; begin Start_test("fc_c_1_c", "verify data in records written to file , " & "(tests write, read, To_string, and To_host_string)"); for i in Key_range loop Key := Pad(integer'image(i), Key'length); Rec.Count := Key; NLF.Read(File=>Recfile, Element=>Host_rec, Key=>To_host_string(Key)); Rec := To_rec(Host_rec); if (Pad( "This is record number " & integer'image(i), Rec.Line'length) /= Rec.Line) or (Pad(integer'image(i), Key'length) /= Rec.Count) then Fail_test; Fail := True; exit; end if; end loop; If not Fail then Pass_test; end if; Fail := FALSE; exception when Not_open => Unexpected_exception("Not_open"); when Not_Found => Unexpected_exception("Not_found"); when Duplicate_key => Unexpected_exception("Duplicate_key"); when Duplicate_record => Unexpected_exception("Duplicate_record"); when End_file => Unexpected_exception("End_file"); when Others => Unexpected_exception("undocumented exception"); end; declare Fail : Boolean := False; begin Start_test("fc_c_1_d", "rewrite records to file and verify via read" ); for i in Key_range loop Key := Pad(integer'image(i), Key'length); NLF.Read(File=>Recfile, Element=>Host_rec, Key=>To_host_string(Key), Update=>TRUE); Rec := To_rec(Host_rec); Rec.Line := Pad( "This is rewritten record number " & integer'image(i), Rec.Line'length); NLF.Rewrite(File=>Recfile, From=>To_Host(Rec)); NLF.Read(File=>Recfile, Element=>Host_rec, Key=>To_host_string(Key), Update=>FALSE); Rec := To_rec(Host_rec); if (Pad( "This is rewritten record number " & integer'image(i), Rec.Line'length) /= Rec.line) or (Pad(integer'image(i), Key'length) /= Rec.Count) then Fail_test; Fail := True; exit; end if; end loop; If not Fail then Pass_test; end if; Fail := FALSE; exception when Not_open => Unexpected_exception("Not_open"); when Not_Found => Unexpected_exception("Not_found"); when Duplicate_key => Unexpected_exception("Duplicate_key"); when Duplicate_record => Unexpected_exception("Duplicate_record"); when End_file => Unexpected_exception("End_file"); when Others => Unexpected_exception("undocumented exception"); end; End_module; end;