3 { Copyright (C) 2009 Bas Steendijk and Peter Green
\r 
   4   For conditions of distribution and use, see copyright notice in zlib_license.txt
\r 
   5   which is included in the package
\r 
   6   ----------------------------------------------------------------------------- }
\r 
   9 program testreadtxt2;
\r 
  10 uses readtxt2, classes;
\r 
  15 procedure writestring(var f: file; s : string);
\r 
  17   blockwrite(f,s[1],length(s));
\r 
  21   assignfile(f,'mixed.txt');
\r 
  23   writestring(f,'DOS'#13#10);
\r 
  24   writestring(f,'UNIX'#10);
\r 
  25   writestring(f,'MAC'#13);
\r 
  26   writestring(f,'UNIX'#10);
\r 
  27   writestring(f,'NONE');
\r 
  30   writeln('reading test file in default mode (all line endings treated as line endings)');
\r 
  31   t := treadtxt.createf('mixed.txt');
\r 
  32   if t.readline = 'DOS' then writeln('DOS success') else writeln('DOS fail');
\r 
  33   if t.readline = 'UNIX' then writeln('UNIX success') else writeln('UNIX fail');
\r 
  34   if t.readline = 'MAC' then writeln('MAC success') else writeln('MAC fail');
\r 
  35   if t.readline = 'UNIX' then writeln('UNIX success') else writeln('UNIX fail');
\r 
  36   if t.readline = 'NONE' then writeln('NONE success') else writeln('NONE fail');
\r 
  39   writeln('reading test file with only CR treated as a line ending');
\r 
  40   t := treadtxt.createf('mixed.txt');
\r 
  41   t.allowedeol := eoltype_cr;
\r 
  42   if t.readline = 'DOS' then writeln('DOS success') else writeln('DOS fail');
\r 
  43   if t.readline = #10'UNIX'#10'MAC' then writeln('LF+UNIX+LF+MAC success') else writeln('LF+UNIX+LF+MAC fail');
\r 
  44   if t.readline = 'UNIX'#10'NONE' then writeln('UNIX+LF+NONE success') else writeln('UNIX+LF+NONE fail');
\r 
  47   writeln('reading test file with only LF treated as a line ending');
\r 
  48   t := treadtxt.createf('mixed.txt');
\r 
  49   t.allowedeol := eoltype_lf;
\r 
  50   if t.readline = 'DOS'#13 then writeln('DOS+CR success') else writeln('DOS+CR fail');
\r 
  51   if t.readline = 'UNIX' then writeln('UNIX success') else writeln('UNIX fail');
\r 
  52   if t.readline = 'MAC'#13'UNIX' then writeln('MAC+CR+UNIX success') else writeln('MAC+CR+UNIX fail');
\r 
  53   if t.readline = 'NONE' then writeln('NONE success') else writeln('NONE fail');
\r 
  56   writeln('reading test file with only CRLF treated as a line ending');
\r 
  57   t := treadtxt.createf('mixed.txt');
\r 
  58   t.allowedeol := eoltype_crlf;
\r 
  59   if t.readline = 'DOS' then writeln('DOS success') else writeln('DOS fail');
\r 
  60   if t.readline = 'UNIX'#10'MAC'#13'UNIX'#10'NONE' then writeln('UNIX+LF+MAC+CR+UNIX+LF+NONE success') else writeln('UNIX+LF+MAC+CR+UNIX+LF+NONE fail');
\r 
  65     //make things a little easier to test in the delphi GUI
\r