-- $Source: /commtar/monoBANK/CICS_INTF/fc_c_8.ada,v $ -- $Revision: 1.3 $ $Date: 88/04/01 12:53:42 $ $Author: rac $ 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_8 ---------------- is use Line_file_pkg; package LF renames Line_file; begin Start_module("fc_c_8", "File and field manipulation for String Files"); declare Rec_length : integer := LF.Length(Id) + LF.Length(Line); Rec : string (1..Rec_length); Key : string (1..LF.Length(Id)); Line_val : string (1..LF.Length(Line)); begin Start_test("fc_c_8_a", "set fields and write records to prime file"); for i in Key_range loop Key := Pad(integer'image(i), Key'length); LF.Set_field(Rec, Id, Key); Line_val := Pad("This is record number" & integer'image(i), LF.Length(Line)); LF.Set_field(Rec, Line, Line_val); LF.Write(File=>Strfile, From=>Rec, Key=>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 Rec_length : integer := LF.Length(Id) + LF.Length(Line); Rec : string (1..Rec_length); Key : string (1..LF.Length(Id)); Fail : boolean := FALSE; begin Start_test("fc_c_8_b", "verify data in records just written to file " & " using get fields"); for i in Key_range loop Key := Pad(integer'image(i), Key'length); LF.Read(File=>Strfile, Element=>Rec, Key=>Key); if (LF.Field(Rec, Id) /= Key) or (LF.Field(Rec, Line) /= Pad("This is record number" & integer'image(i), LF.Length(Line))) 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 begin Start_test("fc_c_8_c", "Test length of field function"); if (LF.Length(Id) /= 6) or (LF.Length(Line) /= 80) then Fail_test; else Pass_test; end if; 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 Rec_length : integer := LF.Length(Id) + LF.Length(Line); Rec : string (1..Rec_length); Key : string (1..LF.Length(Id)); Subkey : string(1..lf.Length(id)-1); begin Start_test("fc_c_8_d", "delete records using generic key"); Subkey := Pad(integer'image(9000), Subkey'length); LF.Delete(File=>Strfile, Key=>Subkey, Generic_key=>TRUE); Subkey := Pad(integer'image(8999), Subkey'length); LF.Delete(File=>Strfile, Key=>Subkey, Generic_key=>TRUE); declare begin Subkey := Pad(integer'image(9000), Subkey'length); LF.Read(File=>Strfile, Element=>Rec, Key=>Subkey, Generic_key=>TRUE); Fail_test; exception when Not_Found => Null;--look for rest of file in next declare block when Others => Unexpected_exception("undocumented exception"); end; declare begin Subkey := Pad(integer'image(8999), Subkey'length); LF.Read(File=>Strfile, Element=>Rec, Key=>Subkey, Generic_key=>TRUE); Fail_test; exception when Not_Found => Pass_test; when Others => Unexpected_exception("undocumented exception"); end; 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;