with ourQueue; with ada.text_io; with ada.integer_text_io; procedure testQueue2b is -- instantiate a queue of integers myQ : ourQueue.queue; result : boolean; number : integer; package bool_io is new ada.text_io.enumeration_io(boolean); begin -- create the queue i.e. make the queue empty. ourQueue.makeEmpty(myQ); ada.text_io.put_line (" have just made queue empty(i.e. created it) "); -- asking what is the size of the queue number := ourQueue.SizeOfThing(myQ); ada.text_io.put (" after creation, the size of the queue is "); ada.integer_text_io.put (number); ada.text_io.new_line; -- ask "is the queue empty?" -- expect true result := ourQueue.isThingEmpty(myQ); ada.text_io.put (" asking isThingEmpty, expect true, got: "); bool_io.put(result); ada.text_io.new_line; -- ask "is the queue full?" -- expect false result := ourQueue.isThingFull(myQ); ada.text_io.put (" asking isThingFull, expect false, got: "); bool_io.put (result); ada.text_io.new_line; -- try to delete from the queue -- without testing for emptiness ada.text_io.put_line (" trying to delete from empty queue"); -- if not(ourQueue.isThingEmpty(myQ)) then ourQueue.RemoveSomething(myQ); -- end if; -- if not (ourQueue.isThingEmpty(myQ)) then ourQueue.RemoveSomething(number, myQ); ada.integer_text_io.put (number); ada.text_io.put_line (" was returned from the empty queue"); -- end if; -- fill the queue ada.text_io.put_line (" filling queue with 20 items "); for i in 1..20 loop ourQueue.addSomething(i, myQ); end loop; -- ask for the value of the first thing in the queue ada.text_io.put (" asking for first element in queue, expect 1, got: "); number := ourQueue.firstThing(myQ); ada.integer_text_io.put (number); ada.text_io.new_line; -- ask "is the queue full?" -- expect true -- result := ourQueue.isThingFull(myQ); ada.text_io.put (" ask isThingFull, expect false, got : "); -- bool_io.put (result); ada.text_io.new_line; -- ask "is the queue empty?" -- expect false result := ourQueue.isThingEmpty(myQ); ada.text_io.put (" asking isThingEmpty, expect false, got: "); bool_io.put(result); ada.text_io.new_line; -- ask " what is the size of the queue" number := ourQueue.sizeOfThing(myQ); ada.text_io.put (" asking sizeOfThing, expect 20, got: "); ada.integer_text_io.put (number); ada.text_io.new_line; -- delete an element and return it ourQueue.RemoveSomething(number, myQ); ada.text_io.put(" The number deleted from the queue is: "); ada.integer_text_io.put (number); ada.text_io.new_line; -- ask " what is the size of the queue" number := ourQueue.sizeOfThing(myQ); ada.text_io.put (" asking sizeOfThing, expect 19, got: "); ada.integer_text_io.put (number); ada.text_io.new_line; -- delete another element without returning it ada.text_io.put_line (" deleting another element without returning it "); ourQueue.removeSomething(myQ); -- ask " what is the size of the queue" number := ourQueue.sizeOfThing(myQ); ada.text_io.put (" asking sizeOfThing, expect 18, got: "); ada.integer_text_io.put (number); ada.text_io.new_line; -- insert an element ada.text_io.put (" adding 3 elements to the queue"); ourQueue.addSomething(-36,myQ); ourQueue.addSomething(65,myQ); ourQueue.addSomething(192,myQ); -- see how many elements in the queue now - expect 21 number := ourQueue.SizeOfThing(myQ); ada.text_io.put (" asking sizeOfThing, expect 21, got: "); ada.integer_text_io.put (number); ada.text_io.new_line; -- delete all the elements in the queue ada.text_io.put_line (" emptying the queue and showing elements removed "); while not (ourQueue.isThingEmpty(myQ)) loop ourQueue.RemoveSomething(number, myQ); ada.integer_text_io.put (number,4); end loop; ada.text_io.new_line; -- ask "is the queue empty?" -- expect true result := ourQueue.isThingEmpty(myQ); ada.text_io.put (" asking isThingEmpty, expect true, got: "); bool_io.put(result); ada.text_io.new_line; -- ask "is the queue full?" -- expect false result := ourQueue.isThingFull(myQ); ada.text_io.put (" asking isThingFull, expect false, got: "); bool_io.put (result); ada.text_io.new_line; -- asking what is the size of the queue number := ourQueue.SizeOfThing(myQ); ada.text_io.put (" queue has been emptied asking SizeOfQueue, expect 0, got: " ); ada.integer_text_io.put (number); ada.text_io.new_line; end testQueue2b;