Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
65b6e237
Commit
65b6e237
authored
Aug 17, 2023
by
Eric Pouech
Committed by
Alexandre Julliard
Aug 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt/tests: Add tests for freopen().
Signed-off-by:
Eric Pouech
<
epouech@codeweavers.com
>
parent
3505cdbf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
file.c
dlls/msvcrt/tests/file.c
+74
-0
No files found.
dlls/msvcrt/tests/file.c
View file @
65b6e237
...
...
@@ -1167,6 +1167,79 @@ static void test_fputwc(void)
_unlink
(
tempfile
);
}
static
void
test_freopen
(
void
)
{
char
filename1
[
8
]
=
"AXXXXXX"
;
char
filename2
[
8
]
=
"BXXXXXX"
;
FILE
*
file
;
FILE
*
new
;
int
ret
;
int
fd
;
char
ch
;
long
pos
;
mktemp
(
filename1
);
mktemp
(
filename2
);
file
=
fopen
(
filename1
,
"wt"
);
ok
(
file
!=
NULL
,
"fopen(filename1) returned NULL
\n
"
);
ret
=
fwrite
(
"1"
,
1
,
1
,
file
);
ok
(
ret
==
1
,
"fwrite() returned %d (%d)
\n
"
,
ret
,
errno
);
ret
=
fclose
(
file
);
ok
(
ret
==
0
,
"fclose() returned %d
\n
"
,
ret
);
file
=
fopen
(
filename2
,
"wt"
);
ok
(
file
!=
NULL
,
"fopen(filename1) returned NULL
\n
"
);
ret
=
fwrite
(
"2"
,
1
,
1
,
file
);
ok
(
ret
==
1
,
"fwrite() returned %d (%d)
\n
"
,
ret
,
errno
);
ret
=
fclose
(
file
);
ok
(
ret
==
0
,
"fclose() returned %d
\n
"
,
ret
);
file
=
fopen
(
filename1
,
"rt"
);
ok
(
file
!=
NULL
,
"fopen(filename1) returned NULL
\n
"
);
file
=
freopen
(
filename2
,
"rt"
,
file
);
ok
(
file
!=
NULL
,
"fopen(filename2) returned NULL
\n
"
);
ch
=
'#'
;
ret
=
fread
(
&
ch
,
1
,
1
,
file
);
ok
(
ret
==
1
,
"fread() returned %d
\n
"
,
ret
);
ok
(
ch
==
'2'
,
"fread() read %c
\n
"
,
ch
);
ret
=
fclose
(
file
);
ok
(
ret
==
0
,
"fclose() returned %d
\n
"
,
ret
);
file
=
fopen
(
filename1
,
"at"
);
ok
(
file
!=
NULL
,
"fopen(filename1) returned NULL
\n
"
);
file
=
freopen
(
filename1
,
"rt"
,
file
);
ok
(
file
!=
NULL
,
"fopen(filename1) returned NULL
\n
"
);
pos
=
ftell
(
file
);
ok
(
pos
==
0
,
"ftell() returned %ld
\n
"
,
pos
);
ch
=
'#'
;
ret
=
fread
(
&
ch
,
1
,
1
,
file
);
ok
(
ret
==
1
,
"fread() returned %d
\n
"
,
ret
);
ok
(
ch
==
'1'
,
"fread() read %c
\n
"
,
ch
);
ret
=
fclose
(
file
);
ok
(
ret
==
0
,
"fclose() returned %d
\n
"
,
ret
);
file
=
fopen
(
filename1
,
"rt"
);
ok
(
file
!=
NULL
,
"fopen(filename1) returned NULL
\n
"
);
fd
=
fileno
(
file
);
ok
(
fd
>
0
,
"fileno() returned %d
\n
"
,
fd
);
/* invalid filename */
new
=
freopen
(
"_:"
,
"rt"
,
file
);
ok
(
new
==
NULL
,
"fopen(_:) returned non NULL
\n
"
);
errno
=
0xdeadbeef
;
ch
=
'#'
;
ret
=
read
(
fd
,
&
ch
,
1
);
ok
(
ret
==
-
1
,
"read() returned %d
\n
"
,
ret
);
ok
(
errno
==
EBADF
,
"errno is %d
\n
"
,
errno
);
errno
=
0xdeadbeef
;
ret
=
fclose
(
file
);
ok
(
ret
==
EOF
,
"fclose(file) succeeded
\n
"
);
ok
(
errno
==
0xdeadbeef
,
"errno is %d
\n
"
,
errno
);
unlink
(
filename1
);
unlink
(
filename2
);
}
static
void
test_ctrlz
(
void
)
{
char
*
tempf
;
...
...
@@ -2977,6 +3050,7 @@ START_TEST(file)
test_fgetwc_locale
(
"AB
\x83\xa9
"
,
"C"
,
0
);
test_fgetwc_unicode
();
test_fputwc
();
test_freopen
();
test_ctrlz
();
test_file_put_get
();
test_tmpnam
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment