------------------------->  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 ARRAY3_TEST is
   include TEST;
   
-- INT and its iters should be tested before this class is tested.
   main is
      -- Note: Some operations are tested in the matrix class
      -- (transpose, to_portion_of).
      -- More convenient to do the tests there??
      class_name("ARRAY3");
      a ::= #ARRAY3{INT}(3,4,5);
      test("create1 and size1",a.size1.str,"3");
      test("create1 and size2",a.size2.str,"4");
      test("create1 and size3",a.size3.str,"5");
      test("create1 and nr",a.nr.str,"3");
      test("create1 and nc",a.nc.str,"4");
      test("create1 and ne",a.ne.str,"5");
      ainit: ARRAY{ARRAY{ARRAY{INT}}} := 
      |||0,1,2,3|,|10,11,12,13|,|20,21,22,23||,
      ||100,101,102,103|,|110,111,112,113|,|120,121,122,123||,
      ||200,201,202,203|,|210,211,212,213|,|220,221,222,223||,
      ||300,301,302,303|,|310,311,312,313|,|320,321,322,323|||;
      a2 ::= #ARRAY3{INT}(ainit);
      test("create2 and size1",a2.size1.str,"4");
      test("create2 and size2",a2.size2.str,"3");
      test("create2 and size3",a2.size3.str,"4");
      test("create2 and nr",a2.nr.str,"4");
      test("create2 and nc",a2.nc.str,"3");
      test("create2 and ne",a2.ne.str,"4");
      test("aget",a2[0,0,2].str,"2");
      test("aget",a2[0,2,0].str,"20");
      test("aget",a2[1,2,3].str,"123");
      test("aget[3,2,1]",a2[3,2,1].str,"321");
      a2[0,0,2] := 3; test("aset",a2[0,0,2].str,"3");
      a2[0,0,2] := 2; test("aset",a2[0,0,2].str,"2");
      a2[1,1,1] := 99; test("aset",a2[1,1,1].str,"99");
      a2[1,1,1] := 11; test("aset",a2[1,1,1].str,"11");


      res::="";   loop res := res+" "+a.ind1! end;
      test("ind1",res," 0 1 2");
      res:="";  loop res := res+" "+a.ind2! end;
      test("ind2",res," 0 1 2 3");
      res:="";  loop res := res+" "+a.ind3! end;
      test("ind3",res," 0 1 2 3 4");
      
      res:="";   loop res := res+" "+a.row_ind! end;
      test("row",res," 0 1 2");
      res:="";  loop res := res+" "+a.col_ind! end;
      test("col",res," 0 1 2 3");
      res:="";  loop res := res+" "+a.elem_ind! end;
      test("elem",res," 0 1 2 3 4");

      res:=""; 
      loop 
	 res := res+" "+a.inds!.t1+","+a.inds!.t2+","+a.inds!.t3 end;
      test("inds",res,
      " 0,0,0 0,0,1 0,0,2 0,0,3 0,0,4"
      " 0,1,0 0,1,1 0,1,2 0,1,3 0,1,4"
      " 0,2,0 0,2,1 0,2,2 0,2,3 0,2,4"
      " 0,3,0 0,3,1 0,3,2 0,3,3 0,3,4"
      " 1,0,0 1,0,1 1,0,2 1,0,3 1,0,4"
      " 1,1,0 1,1,1 1,1,2 1,1,3 1,1,4"
      " 1,2,0 1,2,1 1,2,2 1,2,3 1,2,4"
      " 1,3,0 1,3,1 1,3,2 1,3,3 1,3,4"
      " 2,0,0 2,0,1 2,0,2 2,0,3 2,0,4"
      " 2,1,0 2,1,1 2,1,2 2,1,3 2,1,4"
      " 2,2,0 2,2,1 2,2,2 2,2,3 2,2,4"
      " 2,3,0 2,3,1 2,3,2 2,3,3 2,3,4");
      
      finish;
      end;
   
end;
   
      

