Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
2e50361a
Commit
2e50361a
authored
May 06, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dup -> copy
parent
b322a1f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
test/gtest-extra-test.cc
test/gtest-extra-test.cc
+13
-13
No files found.
test/gtest-extra-test.cc
View file @
2e50361a
...
@@ -387,8 +387,8 @@ TEST(BufferedFileTest, Fileno) {
...
@@ -387,8 +387,8 @@ TEST(BufferedFileTest, Fileno) {
EXPECT_DEATH
(
f
.
fileno
(),
""
);
EXPECT_DEATH
(
f
.
fileno
(),
""
);
f
=
OpenFile
(
".travis.yml"
);
f
=
OpenFile
(
".travis.yml"
);
EXPECT_TRUE
(
f
.
fileno
()
!=
-
1
);
EXPECT_TRUE
(
f
.
fileno
()
!=
-
1
);
File
dup
=
File
::
dup
(
f
.
fileno
());
File
copy
=
File
::
dup
(
f
.
fileno
());
EXPECT_READ
(
dup
,
"language: cpp"
);
EXPECT_READ
(
copy
,
"language: cpp"
);
}
}
TEST
(
FileTest
,
DefaultCtor
)
{
TEST
(
FileTest
,
DefaultCtor
)
{
...
@@ -526,10 +526,10 @@ TEST(FileTest, WriteError) {
...
@@ -526,10 +526,10 @@ TEST(FileTest, WriteError) {
TEST
(
FileTest
,
Dup
)
{
TEST
(
FileTest
,
Dup
)
{
File
f
(
".travis.yml"
,
File
::
RDONLY
);
File
f
(
".travis.yml"
,
File
::
RDONLY
);
File
dup
=
File
::
dup
(
f
.
descriptor
());
File
copy
=
File
::
dup
(
f
.
descriptor
());
EXPECT_NE
(
f
.
descriptor
(),
dup
.
descriptor
());
EXPECT_NE
(
f
.
descriptor
(),
copy
.
descriptor
());
const
char
EXPECTED
[]
=
"language: cpp"
;
const
char
EXPECTED
[]
=
"language: cpp"
;
EXPECT_EQ
(
EXPECTED
,
Read
(
dup
,
sizeof
(
EXPECTED
)
-
1
));
EXPECT_EQ
(
EXPECTED
,
Read
(
copy
,
sizeof
(
EXPECTED
)
-
1
));
}
}
TEST
(
FileTest
,
DupError
)
{
TEST
(
FileTest
,
DupError
)
{
...
@@ -597,7 +597,7 @@ TEST(OutputRedirectTest, FlushErrorInCtor) {
...
@@ -597,7 +597,7 @@ TEST(OutputRedirectTest, FlushErrorInCtor) {
File
read_end
,
write_end
;
File
read_end
,
write_end
;
File
::
pipe
(
read_end
,
write_end
);
File
::
pipe
(
read_end
,
write_end
);
int
write_fd
=
write_end
.
descriptor
();
int
write_fd
=
write_end
.
descriptor
();
File
write_
dup
=
write_end
.
dup
(
write_fd
);
File
write_
copy
=
write_end
.
dup
(
write_fd
);
BufferedFile
f
=
write_end
.
fdopen
(
"w"
);
BufferedFile
f
=
write_end
.
fdopen
(
"w"
);
// Put a character in a file buffer.
// Put a character in a file buffer.
EXPECT_EQ
(
'x'
,
fputc
(
'x'
,
f
.
get
()));
EXPECT_EQ
(
'x'
,
fputc
(
'x'
,
f
.
get
()));
...
@@ -606,18 +606,18 @@ TEST(OutputRedirectTest, FlushErrorInCtor) {
...
@@ -606,18 +606,18 @@ TEST(OutputRedirectTest, FlushErrorInCtor) {
EXPECT_SYSTEM_ERROR_NOASSERT
(
redir
=
new
OutputRedirect
(
f
.
get
()),
EXPECT_SYSTEM_ERROR_NOASSERT
(
redir
=
new
OutputRedirect
(
f
.
get
()),
EBADF
,
fmt
::
Format
(
"cannot flush stream"
));
EBADF
,
fmt
::
Format
(
"cannot flush stream"
));
delete
redir
;
delete
redir
;
write_
dup
.
dup2
(
write_fd
);
// "undo" close or dtor will fail
write_
copy
.
dup2
(
write_fd
);
// "undo" close or dtor will fail
}
}
TEST
(
OutputRedirectTest
,
DupErrorInCtor
)
{
TEST
(
OutputRedirectTest
,
DupErrorInCtor
)
{
BufferedFile
f
=
OpenFile
(
".travis.yml"
);
BufferedFile
f
=
OpenFile
(
".travis.yml"
);
int
fd
=
f
.
fileno
();
int
fd
=
f
.
fileno
();
File
dup
=
File
::
dup
(
fd
);
File
copy
=
File
::
dup
(
fd
);
FMT_POSIX
(
close
(
fd
));
FMT_POSIX
(
close
(
fd
));
OutputRedirect
*
redir
=
0
;
OutputRedirect
*
redir
=
0
;
EXPECT_SYSTEM_ERROR_NOASSERT
(
redir
=
new
OutputRedirect
(
f
.
get
()),
EXPECT_SYSTEM_ERROR_NOASSERT
(
redir
=
new
OutputRedirect
(
f
.
get
()),
EBADF
,
fmt
::
Format
(
"cannot duplicate file descriptor {}"
)
<<
fd
);
EBADF
,
fmt
::
Format
(
"cannot duplicate file descriptor {}"
)
<<
fd
);
dup
.
dup2
(
fd
);
// "undo" close or dtor will fail
copy
.
dup2
(
fd
);
// "undo" close or dtor will fail
delete
redir
;
delete
redir
;
}
}
...
@@ -640,7 +640,7 @@ TEST(OutputRedirectTest, FlushErrorInRestoreAndRead) {
...
@@ -640,7 +640,7 @@ TEST(OutputRedirectTest, FlushErrorInRestoreAndRead) {
File
read_end
,
write_end
;
File
read_end
,
write_end
;
File
::
pipe
(
read_end
,
write_end
);
File
::
pipe
(
read_end
,
write_end
);
int
write_fd
=
write_end
.
descriptor
();
int
write_fd
=
write_end
.
descriptor
();
File
write_
dup
=
write_end
.
dup
(
write_fd
);
File
write_
copy
=
write_end
.
dup
(
write_fd
);
BufferedFile
f
=
write_end
.
fdopen
(
"w"
);
BufferedFile
f
=
write_end
.
fdopen
(
"w"
);
OutputRedirect
redir
(
f
.
get
());
OutputRedirect
redir
(
f
.
get
());
// Put a character in a file buffer.
// Put a character in a file buffer.
...
@@ -648,14 +648,14 @@ TEST(OutputRedirectTest, FlushErrorInRestoreAndRead) {
...
@@ -648,14 +648,14 @@ TEST(OutputRedirectTest, FlushErrorInRestoreAndRead) {
FMT_POSIX
(
close
(
write_fd
));
FMT_POSIX
(
close
(
write_fd
));
EXPECT_SYSTEM_ERROR_NOASSERT
(
redir
.
RestoreAndRead
(),
EXPECT_SYSTEM_ERROR_NOASSERT
(
redir
.
RestoreAndRead
(),
EBADF
,
fmt
::
Format
(
"cannot flush stream"
));
EBADF
,
fmt
::
Format
(
"cannot flush stream"
));
write_
dup
.
dup2
(
write_fd
);
// "undo" close or dtor will fail
write_
copy
.
dup2
(
write_fd
);
// "undo" close or dtor will fail
}
}
TEST
(
OutputRedirectTest
,
ErrorInDtor
)
{
TEST
(
OutputRedirectTest
,
ErrorInDtor
)
{
File
read_end
,
write_end
;
File
read_end
,
write_end
;
File
::
pipe
(
read_end
,
write_end
);
File
::
pipe
(
read_end
,
write_end
);
int
write_fd
=
write_end
.
descriptor
();
int
write_fd
=
write_end
.
descriptor
();
File
write_
dup
=
write_end
.
dup
(
write_fd
);
File
write_
copy
=
write_end
.
dup
(
write_fd
);
BufferedFile
f
=
write_end
.
fdopen
(
"w"
);
BufferedFile
f
=
write_end
.
fdopen
(
"w"
);
OutputRedirect
*
redir
=
new
OutputRedirect
(
f
.
get
());
OutputRedirect
*
redir
=
new
OutputRedirect
(
f
.
get
());
// Put a character in a file buffer.
// Put a character in a file buffer.
...
@@ -668,7 +668,7 @@ TEST(OutputRedirectTest, ErrorInDtor) {
...
@@ -668,7 +668,7 @@ TEST(OutputRedirectTest, ErrorInDtor) {
FMT_POSIX
(
close
(
write_fd
));
FMT_POSIX
(
close
(
write_fd
));
SUPPRESS_ASSERT
(
delete
redir
);
SUPPRESS_ASSERT
(
delete
redir
);
},
FormatSystemErrorMessage
(
EBADF
,
"cannot flush stream"
));
},
FormatSystemErrorMessage
(
EBADF
,
"cannot flush stream"
));
write_
dup
.
dup2
(
write_fd
);
// "undo" close or dtor of BufferedFile will fail
write_
copy
.
dup2
(
write_fd
);
// "undo" close or dtor of BufferedFile will fail
}
}
// TODO: test EXPECT_SYSTEM_ERROR
// TODO: test EXPECT_SYSTEM_ERROR
...
...
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