Test Case to show Wine-MSVCRT still misshandling ASCII Mode

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Sun Jan 25 11:56:04 CST 2009


Hello,

appended patch adds a test case that show that wine builtin msvcrt still
doesn't handle ASCII mode right, if CR is present in the file.

Bye

-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index 44ca961..8c1280e 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -306,6 +306,7 @@ static void test_asciimode(void)
 {
     FILE *fp;
     char buf[64];
+    int c, i, j;
 
     /* Simple test of CR CR LF handling.  Test both fgets and fread code paths, they're different! */
     fp = fopen("ascii.tst", "wb");
@@ -334,6 +335,45 @@ static void test_asciimode(void)
     ok((fread(buf, 1, sizeof(buf), fp) == 0), "fread after logical EOF\n");
     fclose(fp);
 
+    /* Show ASCII mode mishandling*/
+    fp= fopen("ascii.tst","wb");
+    fputs("0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n", fp);
+    fclose(fp);
+
+    fp = fopen("ascii.tst", "r");
+    c= fgetc(fp);
+    c= fgetc(fp);
+    fseek(fp,0,SEEK_CUR);
+    todo_wine {
+	for(i=1; i<10; i++) {
+	    ok((j = ftell(fp)) == i*3, "ftell fails in TEXT mode\n");
+	    fseek(fp,0,SEEK_CUR);
+	    ok((c = fgetc(fp)) == '0'+ i, "fgetc after fseek failed in line %d\n", i);
+	    c= fgetc(fp);
+	}
+	/* Show that fseek doesn't skip \\r !*/
+	rewind(fp);
+	c= fgetc(fp);
+	fseek(fp, 2 ,SEEK_CUR);
+	for(i=1; i<10; i++) {
+	    ok((c = fgetc(fp)) == '0'+ i, "fgetc after fseek with pos Offset failed in line %d\n", i);
+	    fseek(fp, 2 ,SEEK_CUR);
+	}
+	fseek(fp, 9*3 ,SEEK_SET);
+	c = fgetc(fp);
+	fseek(fp, -4 ,SEEK_CUR);
+	for(i= 8; i>=0; i--) {
+	    ok((c = fgetc(fp)) == '0'+ i, "fgetc after fseek with neg Offset failed in line %d\n", i);
+	    fseek(fp, -4 ,SEEK_CUR);
+	}
+    }
+    /* Show what happens is fseek positions filepointer on \\r */
+    fclose(fp);
+    fp = fopen("ascii.tst", "r");
+    fseek(fp, 3 ,SEEK_SET);
+    ok((c = fgetc(fp)) == '1', "fgetc fails to read nect char when positioned on \\r \n");
+    fclose(fp);
+    
     unlink("ascii.tst");
 }
 



More information about the wine-patches mailing list