-- $Source: /commtar/monoBANK/CICS_INTF/fc_c_5.ada,v $ -- $Revision: 1.10 $ $Date: 88/04/04 10:41:29 $ $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_5 ---------------- is use Numbered_line_file_pkg; package NLF renames Numbered_line_file; Host_Rec : NLF.Element_Ptr_Type; Host_key : Host_count_type(1..6); Rec : Numbered_line_record; Key : Count_type; Fail : boolean := FALSE; begin Start_module("fc_c_5", "browse sequence for Data Type Files"); Flush_numbered_line_file; for i in Key_range loop -- prime file Key := Pad(integer'image(i), Key'length); Rec.Count := Key; Rec.Line := Pad( "This is record number " & integer'image(i), Rec.Line'length); NLF.Write(File=>Recfile, From=>To_host(Rec), Key=>To_host_string(Key)); end loop; declare begin Start_test("fc_c_5_a", "Start browse at first record in file using " & "the exact key"); Key := Pad(" 89990", Key'length); NLF.Start_browse(File=>Recfile, Key=>To_host_string(Key), Gt_Eq=>FALSE); 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_5_b", "Read sequentially through file in " & "ascending key order until end of file"); for i in Key_range loop Host_Key := To_Host_String(Pad(integer'image(i), Host_Key'length)); NLF.Read_next(File=>Recfile, Element_Ptr=>Host_Rec, Key=>Host_key); Rec := To_rec(Host_Rec.all); if Rec.Count /= Pad(integer'image(i), Key'length) then Fail_test; exit; end if; 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 => Pass_test; when Others => Unexpected_exception("undocumented exception"); end; declare begin Start_test("fc_c_5_c", "Reset browse at last record in file using " & "the exact key"); Key := Pad(" 90010", Key'length); NLF.Reset_browse(File=>Recfile, Key=>To_host_string(key), Gt_Eq=>FALSE); 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_5_d", "Read sequentially through file in " & "descending key order until end of file"); for i in reverse Key_range loop NLF.Read_prev(File=>Recfile, Element_Ptr=>Host_Rec, Key=>Host_key); Rec := To_rec(Host_Rec.all); if Rec.Count /= Pad(integer'image(i), Key'length) then Fail_test; exit; end if; 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 => Pass_test; when Others => Unexpected_exception("undocumented exception"); end; declare Startkey : Small_string := " "; begin Start_test("fc_c_5_e", "Reset browse at first record in file using " & "a key value of ' '"); NLF.Reset_browse(File=>Recfile, Key=>To_host_string(StartKey), Gt_Eq=>True,Generic_Key=>True); 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_5_f", "Read file sequentially " & "intermixing direction of read"); NLF.Read_next(File=>Recfile, Element_Ptr=>Host_Rec, Key=>Host_key); Rec := To_rec(Host_Rec.all); if Rec.Count /= Pad(" 89990", Key'length) then Fail_test; else NLF.Read_next(File=>Recfile, Element_Ptr=>Host_Rec, Key=>Host_key); Rec := To_rec(Host_Rec.all); if Rec.Count /= Pad(" 89991", Key'length) then Fail_test; else NLF.Read_next(File=>Recfile, Element_Ptr=>Host_Rec, Key=>Host_key); Rec := To_rec(Host_Rec.all); if Rec.Count /= Pad(" 89992", Key'length) then Fail_test; else NLF.Read_prev(File=>Recfile, Element_Ptr=>Host_Rec, Key=>Host_key); Rec := To_rec(Host_Rec.all); if Rec.Count /= Pad(" 89991", Key'length) then Fail_test; else NLF.Read_prev(File=>Recfile, Element_Ptr=>Host_Rec, Key=>Host_key); Rec := To_rec(Host_Rec.all); if Rec.Count /= Pad(" 89990", Key'length) then Fail_test; else declare begin NLF.Read_prev(File=>Recfile, Element_Ptr=>Host_Rec, Key=>Host_key); Fail_test; -- should have reached end of file exception when End_file => Pass_test; when Others => Unexpected_exception( "undocumented exception"); end; end if; end if; end if; end if; 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 begin Start_test("fc_c_5_g", "Read file 'Skip-sequentially'"); Key := Pad(" 89990", Key'length); Host_key := To_host_string( Key ); NLF.Reset_browse(File=>Recfile, Key=>Host_key, Gt_Eq=>FALSE); Host_key := To_host_string( Pad(" 90000", Key'length) ); NLF.Read_next(File=>Recfile, Element_Ptr=>Host_Rec, Key=>Host_key); Rec := To_rec(Host_Rec.all); if Rec.Count /= Key then Fail_test; else Key := Pad(" 89995", Key'length); Host_key := To_host_string(Key); NLF.Read_prev(File=>Recfile, Element_Ptr=>Host_Rec, Key=>Host_key); Rec := To_rec(Host_Rec.all); if Rec.Count /= Key then Fail_test; end if; end if; 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_5_h", "End browse session"); NLF.End_browse(File=>Recfile); 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; Flush_numbered_line_file; End_module; end;