------------------------------------------------------------------------- --| --| I N D E X E D L I S T T E S T --| --| Abstract : This file contains a procedure to test the implementation --| of indexed list operations. --| --| Related compilation units contained in this directory are: --| --| Type Name File --| ---- ---- ---- --| Test Procedure indexed_list_test This file --| Procedure get_word get_word.ada --| --| Specification indexed_list_package indexed_list.ada --| Implementation indexed_list_package indexed_list.ada --| --------------------------------------------------------------------------- --| Date 4/22/93 Version 1.0 --------------------------------------------------------------------------- with text_io; use text_io; with get_word; with indexed_list_package; procedure indexed_list_test is package indexed_list_pak is new indexed_list_package(integer); package iio is new integer_io(integer); use iio; operation : string(1..20); line : string(1..80); n, len, last : natural; object : integer; at_index : positive; indexed_list : indexed_list_pak.indexed_list(7); procedure put_object(object : integer) is begin iio.put(object,3); end put_object; procedure display_indexed_list is new indexed_list_pak.display(put_object); begin loop1 : loop begin -- This begin block is included so that exceptions -- generated by the package being tested will not -- cuase termination of the test program. loop2 : loop if end_of_file then exit loop1; else get_line(line, len); -- Get next command line. end if; get_word(line(1..len), operation, n); -- Isolate command. if n = 0 then exit loop1; end if; -- Empty line; terminate test. put(line(1..len)); if operation(1..2) = "--" -- Command is a comment. then new_line; else set_col(20); put("=> "); if operation(1..n) = "insert" then iio.get(line(n+1..len), at_index, last); iio.get(line(last+1..len), object, last); indexed_list_pak.insert(indexed_list,at_index,object); elsif operation(1..n) = "list_object" then iio.get(line(n+1..len), at_index, last); put_object(indexed_list_pak.list_object(indexed_list, at_index)); elsif operation(1..n) = "change" then iio.get(line(n+1..len), at_index, last); iio.get(line(last+1..len), object, last); indexed_list_pak.change(indexed_list,at_index,object); elsif operation(1..n) = "delete" then iio.get(line(n+1..len), at_index, last); indexed_list_pak.delete(indexed_list,at_index); elsif operation(1..n) = "clear" then indexed_list_pak.clear(indexed_list); else put("??????"); end if; set_col(30); display_indexed_list(indexed_list); new_line; end if; end loop loop2; exception when indexed_list_pak.list_empty => set_col(30); put_line("list_empty exception raised"); when indexed_list_pak.list_full => set_col(30); put_line("list_full exception raised"); when indexed_list_pak.faulty_position => set_col(30); put_line("faulty_position exception raised"); end; end loop loop1; new_line(2); put_line("indexed_list test completed."); end indexed_list_test;