home *** CD-ROM | disk | FTP | other *** search
- -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C)
- -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
- --
- class TEST_ARRAY2
-
- creation {ANY}
- make
-
- feature {ANY}
-
- a, b: ARRAY2[INTEGER];
-
- make is
- local
- i1, i2, v: INTEGER;
- do
- !!a.make(1,2,3,4);
- is_true(a.count = 4);
- is_true(a.lower1 = 1);
- is_true(a.upper1 = 2);
- is_true(a.lower2 = 3);
- is_true(a.upper2 = 4);
- is_true(a.item(1,3) = 0);
-
- !!a.make(1,3,1,3);
- is_true(a.count = 9);
- is_true(a.lower1 = 1);
- is_true(a.upper1 = 3);
- is_true(a.lower1 = 1);
- is_true(a.upper2 = 3);
- !!b.array2(<<<<0,0,0>>,
- <<0,0,0>>,
- <<0,0,0>>>>);
- is_true(b.count = 9);
- is_true(b.lower1 = 1);
- is_true(b.upper1 = 3);
- is_true(b.lower1 = 1);
- is_true(b.upper2 = 3);
-
- is_true(a.is_equal(b));
- is_true(equal(a,b));
-
-
- from
- !!a.array2(<<<<1,2,3>>,
- <<4,5,6>>,
- <<7,8,9>>>>);
- i1 := a.lower1;
- i2 := a.lower2;
- v := 1;
- until
- v > 9
- loop
- is_true(v = a.item(i1,i2));
- v := v + 1;
- if i2 = a.upper2 then
- i1 := i1 + 1;
- i2 := a.lower2;
- else
- i2 := i2 + 1;
- end;
- end;
-
-
- from
- b := clone(a);
- i1 := a.lower1;
- i2 := a.lower2;
- v := 1;
- until
- v > 9
- loop
- is_true(v = a.item(i1,i2));
- is_true(v = b.item(i1,i2));
- v := v + 1;
- if i2 = a.upper2 then
- i1 := i1 + 1;
- i2 := a.lower2;
- else
- i2 := i2 + 1;
- end;
- end;
-
- is_true(equal(a,b));
- b.put(0,2,2);
- is_true(not equal(a,b));
-
-
- !!a.array2(<<<<1,2,2>>,
- <<4,5,6>>,
- <<7,8,9>>>>);
- is_true(a.nb_occurrences(2) = 2);
- is_true(a.nb_occurrences(3) = 0);
- is_true(a.nb_occurrences(4) = 1);
-
- is_true(a.fast_nb_occurrences(2) = 2);
- is_true(a.fast_nb_occurrences(3) = 0);
- is_true(a.fast_nb_occurrences(4) = 1);
- end;
-
- is_true(bool: BOOLEAN) is
- do
- cpt := cpt + 1;
- if not bool then
- std_output.put_string("TEST_ARRAY2: ERROR Test # ");
- std_output.put_integer(cpt);
- std_output.put_string("%N");
- else
- -- std_output.put_string("Yes%N");
- end;
- end;
-
- cpt: INTEGER;
-
- end -- TEST_ARRAY2
-