Add testcase for embedded CRs
authorali <ali@juiblex.co.uk>
Mon Feb 20 08:13:47 2012 +0000 (2012-02-20)
changeset 3551a0beae92f6
parent 34 8744c913ccdd
child 36 c6d5c23b0ff1
Add testcase for embedded CRs
test/compatibility/Makefile.am
test/compatibility/embedded-cr.tst
test/harness/testcaseinput.c
     1.1 --- a/test/compatibility/Makefile.am	Sun Feb 19 23:14:54 2012 +0000
     1.2 +++ b/test/compatibility/Makefile.am	Mon Feb 20 08:13:47 2012 +0000
     1.3 @@ -7,6 +7,6 @@
     1.4  	dashes.tst control-characters.tst unusual-characters.tst \
     1.5  	windows-1252.tst periods.tst long-line.tst unmarked-paragraph.tst \
     1.6  	hebe-jeebies.tst mail-from.tst scannos.tst before-comma.tst \
     1.7 -	before-period.tst double-punctuation.tst genatives.tst
     1.8 +	before-period.tst double-punctuation.tst genatives.tst embedded-cr.tst
     1.9  
    1.10  dist_pkgdata_DATA=$(TESTS)
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/compatibility/embedded-cr.tst	Mon Feb 20 08:13:47 2012 +0000
     2.3 @@ -0,0 +1,11 @@
     2.4 +**************** INPUT ****************
     2.5 +The return to Cedarville was a great event. Dora clasped her mother in␍
     2.6 +her arms and laughed and wept by turns, and then threw herself into
     2.7 +Dick's␍embrace.
     2.8 +**************** EXPECTED ****************
     2.9 +
    2.10 +The return to Cedarville was a great event. Dora clasped her mother in
    2.11 +    Line 1 - Two successive CRs?
    2.12 +
    2.13 +Dick's
    2.14 +    Line 3 column 7 - CR without LF?
     3.1 --- a/test/harness/testcaseinput.c	Sun Feb 19 23:14:54 2012 +0000
     3.2 +++ b/test/harness/testcaseinput.c	Mon Feb 20 08:13:47 2012 +0000
     3.3 @@ -32,12 +32,14 @@
     3.4  }
     3.5  
     3.6  /*
     3.7 - * Replace \n with \r\n and U+240A (visible symbol for LF) with \n
     3.8 + * Replace \n with \r\n, U+240A (visible symbol for LF) with \n
     3.9 + * and U+240D (visible symbol for CR) with \r.
    3.10   */
    3.11  static char *unix2dos(const char *text)
    3.12  {
    3.13      gunichar c;
    3.14      const gunichar visible_lf=0x240A;
    3.15 +    const gunichar visible_cr=0x240D;
    3.16      GString *string;
    3.17      string=g_string_new(NULL);
    3.18      while(*text)
    3.19 @@ -48,6 +50,8 @@
    3.20  	    g_string_append(string,"\r\n");
    3.21  	else if (c==visible_lf)
    3.22  	    g_string_append_c(string,'\n');
    3.23 +	else if (c==visible_cr)
    3.24 +	    g_string_append_c(string,'\r');
    3.25  	else
    3.26  	    g_string_append_unichar(string,c);
    3.27      }