home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / SmallEiffel 0.3.3 / SmallEiffel 68k / lib_test / bug_std_file_read_write.e < prev    next >
Encoding:
Text File  |  1996-06-13  |  2.1 KB  |  102 lines  |  [TEXT/EDIT]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class TEST_STD_FILE_READ_WRITE
  5.  
  6. creation {ANY}
  7.    make
  8.    
  9. feature {ANY}
  10.    
  11.    path: STRING is "test_std_file_read_write.dat";
  12.    
  13.    sfr: STD_FILE_READ;
  14.    
  15.    sfw: STD_FILE_WRITE;
  16.    
  17.    sfrw: STD_FILE_READ_WRITE;
  18.    
  19.    
  20.    before: STRING is "A? A%N? B%NCC? CC%NDDDDD%NEEEEEE%N";
  21.    after : STRING is "A?1A%N?2B%NCC?3CC%NDDDDD%NEEEEEE%N";
  22.    
  23.    make is
  24.       local
  25.      i: INTEGER;
  26.       do
  27.      !!sfw.connect_to(path);
  28.      is_true(sfw.is_connected);
  29.      sfw.put_string(before);
  30.      sfw.disconnect;
  31.      is_true(not sfw.is_connected);
  32.      is_true(file_exists(path));
  33.      
  34.      !!sfr.connect_to(path);
  35.      is_true(sfr.is_connected);
  36.      from  
  37.         i := 1;
  38.      until
  39.         i > before.count
  40.      loop
  41.         sfr.read_character;
  42.         is_true(not sfr.end_of_input);
  43.         is_true(sfr.last_character = before.item(i));
  44.         i := i + 1;
  45.      end;
  46.      sfr.disconnect;
  47.      is_true(not sfr.is_connected);
  48.      
  49.      !!sfrw.connect_to(path);
  50.      is_true(sfrw.is_connected);
  51.      from  
  52.         i := 1;
  53.      until
  54.         i > before.count
  55.      loop
  56.         sfrw.read_character;
  57.         is_true(not sfrw.end_of_input);
  58.         is_true(sfrw.last_character = before.item(i));
  59.         if before.item(i) = '?' then
  60.            i := i + 1;
  61.            sfrw.put_character(after.item(i));
  62.         end;
  63.         i := i + 1;
  64.      end;
  65.      sfrw.disconnect;
  66.      is_true(not sfrw.is_connected);
  67.       
  68.      !!sfr.connect_to(path);
  69.      is_true(sfr.is_connected);
  70.      from  
  71.         i := 1;
  72.      until
  73.         i > after.count
  74.      loop
  75.         sfr.read_character;
  76.         is_true(not sfr.end_of_input);
  77.         is_true(sfr.last_character = after.item(i));
  78.         i := i + 1;
  79.      end;
  80.      sfr.disconnect;
  81.      is_true(not sfr.is_connected);
  82.      
  83.      remove_file(path);
  84.      is_true(not file_exists(path));
  85.       end;
  86.    
  87.    is_true(b: BOOLEAN) is
  88.       do
  89.      cpt := cpt + 1;
  90.      if not b then
  91.         std_output.put_string("TEST_STD_FILE_READ_WRITE: ERROR Test # ");
  92.         std_output.put_integer(cpt);
  93.         std_output.put_string("%N");
  94.      else
  95.         -- std_output.put_string("Yes%N");
  96.      end;
  97.       end;
  98.    
  99.    cpt: INTEGER;
  100.    
  101. end -- TEST_STD_FILE_READ_WRITE
  102.