ok() does not support '%S'. Store the Ansi version, convert to Unicode
[wine] / dlls / msvcrt / tests / file.c
1 /*
2  * Unit test suite for file functions
3  *
4  * Copyright 2002 Bill Currie
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <windef.h>
22 #include <stdio.h>
23 #include <fcntl.h>
24 #include <io.h>
25
26 #include "wine/test.h"
27
28 static void test_fdopen( void )
29 {
30     static char buffer[] = {0,1,2,3,4,5,6,7,8,9};
31         int fd;
32         FILE *file;
33
34         fd = open ("fdopen.tst", O_WRONLY | O_CREAT | O_BINARY);
35         write (fd, buffer, sizeof (buffer));
36         close (fd);
37
38         fd = open ("fdopen.tst", O_RDONLY | O_BINARY);
39         lseek (fd, 5, SEEK_SET);
40         file = fdopen (fd, "rb");
41         ok (fread (buffer, 1, sizeof (buffer), file) == 5, "read wrong byte count");
42         ok (memcmp (buffer, buffer + 5, 5) == 0, "read wrong bytes");
43         fclose (file);
44         unlink ("fdopen.tst");
45 }
46
47
48 START_TEST(file)
49 {
50     test_fdopen();
51 }