home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / eiffel / smalleif.97 / se.t / SmallEiffel / lib_test / test_array_expanded.e < prev    next >
Encoding:
Text File  |  1996-05-02  |  1.8 KB  |  95 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class TEST_ARRAY_EXPANDED
  5.    
  6. creation {ANY}
  7.    make
  8.    
  9. feature {ANY}
  10.    
  11.    a: ARRAY[INTEGER];
  12.    c1,c2,c3,cv: INTEGER;
  13.    i: INTEGER;
  14.      
  15.    make is
  16.       do
  17.      c1 := 31;
  18.      c2 := 32;
  19.      c3 := 33;
  20.      
  21.      !!a.make(1,0);
  22.      is_true(a.lower = 1);
  23.      is_true(a.upper = 0);
  24.      is_true(a.count = 0);
  25.      is_true(a.empty);
  26.      
  27.      a.make(1,1);
  28.      is_true(a.count = 1);
  29.      is_true(a.lower = 1);
  30.      is_true(a.upper = 1);
  31.      is_true(a.item(1) = 0);
  32.      
  33.      !!a.make(1,4);
  34.      is_true(a.count = 4);
  35.      from  
  36.         i := 1;
  37.      until
  38.         i > a.count
  39.      loop
  40.         is_true(a.item(i) = 0);
  41.         i := i + 1;
  42.      end;
  43.      
  44.      !!a.make(-1,-2);
  45.      is_true(a.count = 0);
  46.      a.add_last(c1);
  47.      is_true(a.count = 1);
  48.      is_true(a.item(-1) = c1);
  49.      
  50.          a := <<c1>>;
  51.      is_true(a.count = 1);
  52.      is_true(a.item(1) = c1);
  53.      a.add_last(c2);
  54.      is_true(a.count = 2);
  55.      is_true(a.item(1) = c1);
  56.      is_true(a.item(2) = c2);
  57.            
  58.      !!a.make(1,3);
  59.          a.put(c2,2);
  60.      is_true(equal(a,<<0,c2,0>>));
  61.      a.put(67,2);
  62.      is_true(equal(a,<<0,67,0>>));
  63.          a.make(1,3);
  64.      is_true(equal(a,<<0,0,0>>));
  65.  
  66.      !!a.make(2,2);
  67.          a.force(c1,1);
  68.      is_true(equal(a,<<c1,0>>));
  69.      a.force(c3,3);
  70.      is_true(equal(a,<<c1,0,c3>>));
  71.       
  72.      a := <<1,2,3,4>>;
  73.      is_true(a.index_of(1) = 1);
  74.      is_true(equal(a.index_of(1),1));
  75.      is_true(equal(1,a.index_of(1)));
  76.      is_true(a.index_of(3) = 3);
  77.      is_true(equal(3,a.index_of(3)));
  78.       end;
  79.    
  80.    is_true(b: BOOLEAN) is
  81.       do
  82.      cpt := cpt + 1;
  83.      if not b then
  84.         std_output.put_string("TEST_ARRAY_EXPANDED: ERROR Test # ");
  85.         std_output.put_integer(cpt);
  86.         std_output.put_string("%N");
  87.      else
  88.         -- std_output.put_string("yes%N");
  89.      end;
  90.       end;
  91.    
  92.    cpt: INTEGER;
  93.    
  94. end -- XX43
  95.