home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-13 | 2.1 KB | 102 lines | [TEXT/EDIT] |
- -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C)
- -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
- --
- class TEST_STD_FILE_READ_WRITE
-
- creation {ANY}
- make
-
- feature {ANY}
-
- path: STRING is "test_std_file_read_write.dat";
-
- sfr: STD_FILE_READ;
-
- sfw: STD_FILE_WRITE;
-
- sfrw: STD_FILE_READ_WRITE;
-
-
- before: STRING is "A? A%N? B%NCC? CC%NDDDDD%NEEEEEE%N";
- after : STRING is "A?1A%N?2B%NCC?3CC%NDDDDD%NEEEEEE%N";
-
- make is
- local
- i: INTEGER;
- do
- !!sfw.connect_to(path);
- is_true(sfw.is_connected);
- sfw.put_string(before);
- sfw.disconnect;
- is_true(not sfw.is_connected);
- is_true(file_exists(path));
-
- !!sfr.connect_to(path);
- is_true(sfr.is_connected);
- from
- i := 1;
- until
- i > before.count
- loop
- sfr.read_character;
- is_true(not sfr.end_of_input);
- is_true(sfr.last_character = before.item(i));
- i := i + 1;
- end;
- sfr.disconnect;
- is_true(not sfr.is_connected);
-
- !!sfrw.connect_to(path);
- is_true(sfrw.is_connected);
- from
- i := 1;
- until
- i > before.count
- loop
- sfrw.read_character;
- is_true(not sfrw.end_of_input);
- is_true(sfrw.last_character = before.item(i));
- if before.item(i) = '?' then
- i := i + 1;
- sfrw.put_character(after.item(i));
- end;
- i := i + 1;
- end;
- sfrw.disconnect;
- is_true(not sfrw.is_connected);
-
- !!sfr.connect_to(path);
- is_true(sfr.is_connected);
- from
- i := 1;
- until
- i > after.count
- loop
- sfr.read_character;
- is_true(not sfr.end_of_input);
- is_true(sfr.last_character = after.item(i));
- i := i + 1;
- end;
- sfr.disconnect;
- is_true(not sfr.is_connected);
-
- remove_file(path);
- is_true(not file_exists(path));
- end;
-
- is_true(b: BOOLEAN) is
- do
- cpt := cpt + 1;
- if not b then
- std_output.put_string("TEST_STD_FILE_READ_WRITE: 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_STD_FILE_READ_WRITE
-