------------------------->  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>  <--------------

class LLIST_TEST
is
    include TEST;

    str(l:LLIST{INT}): STR
    is
        res ::= "";
        loop res := res + ",".separate!(l.elt!.str) end;
        return res;
    end;

    main
    is
        l ::= #LLIST{INT};
        class_name := "LLIST";
        test("state",l.dbg_state,"ok");
        test("is_empty",l.is_empty.str,"true");
        test("at_end",l.at_end.str,"true");
        l.insert_before(1);
        test("state",l.dbg_state,"ok");
        test("is_empty",l.is_empty.str,"false");
        test("at_end",l.at_end.str,"true");
        test("at_last",l.at_last.str,"false");
        l.insert_before(2);
        test("state",l.dbg_state,"ok");
        test("insert_before",str(l),"1,2");
        test("at_end",l.at_end.str,"true");
        test("at_last",l.at_last.str,"false");
        l.rewind;
        test("state",l.dbg_state,"ok");
        test("current",l.current.str,"1");
        test("at_end",l.at_end.str,"false");
        test("at_last",l.at_last.str,"false");
        l.advance;
        test("state",l.dbg_state,"ok");
        test("current",l.current.str,"2");
        test("at_end",l.at_end.str,"false");
        test("at_last",l.at_last.str,"true");
        l.insert_after(3);
        test("state",l.dbg_state,"ok");
        test("insert_after",str(l),"1,2,3");
        test("at_last",l.at_last.str,"false");
        l.insert_after(4);
        test("state",l.dbg_state,"ok");
        test("insert_after",str(l),"1,2,4,3");
        l.insert_before(5);
        test("state",l.dbg_state,"ok");
        test("insert_before",str(l),"1,5,2,4,3");
        l.delete;
        test("state",l.dbg_state,"ok");
        test("delete",str(l),"1,5,4,3");
        l.rewind; l.delete;
        test("state",l.dbg_state,"ok");
        test("delete",str(l),"5,4,3");
        l.advance; l.advance; l.delete;
        test("state",l.dbg_state,"ok");
        test("delete",str(l),"5,4");
        l.delete_all;
        test("state",l.dbg_state,"ok");
        test("delete_all",str(l),"");
        finish;
    end;
end;


