------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 1995 by International Computer Science Institute            --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- This  library  is distributed  in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details.       --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------

-- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>

class FGAP_LIST_TEST is
   -- Test of `FGAP_LIST{T}'.
   include TEST;
   
   main is
      -- Test of `GAP_LIST{T}'.
      class_name("FGAP_LIST{INT}");
      l: FGAP_LIST{INT} := list_of_range(0,14);
      resl:ARRAY{INT} := |0,1,2,3,4,5,6,7,8,9,10,11,12,13,14|;
      test("list entries", l.str,resl.str);
      test("size", l.size.str, 15.str);
      test("is_empty 1", l.is_empty, false);
      l := l.delete(2);
      lres2 ::= #ARRAY{INT}(|0,1,3,4,5,6,7,8,9,10,11,12,13,14|);
      test("delete", l,lres2.str);
      l := l.insert(4, 17);
      lres3 ::= #ARRAY{INT}(|0,1,3,4,17,5,6,7,8,9,10,11,12,13,14|);
      test("insert", l,lres3.str);
      test("get", l.get(4), 17);
      l.replace(4, 19);
      lres4 ::= #ARRAY{INT}(|0,1,3,4,19,5,6,7,8,9,10,11,12,13,14|);
      test("replace", l.str,lres4.str);
      l.clear;
      lres5 ::= #ARRAY{INT};
      test("clear",l.str, lres5.str);
      test("is_empty 2", l.is_empty, true);
      finish;
   end; -- main
   
   list_of_range(l,h: INT): FGAP_LIST{INT} is   
      -- A gap list containing `l,...,h'.
      res ::= #FGAP_LIST{INT};
      i:INT := l; loop until!(i>h); res := res.insert(res.size, i);i:=i+1 end;
      return res;
   end; -- list_of_range

end; 

--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
