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
75b5eb4b
Commit
75b5eb4b
authored
Jul 27, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More fixes for
https://github.com/cppformat/cppformat/issues/50
.
parent
5d4803a5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
35 additions
and
35 deletions
+35
-35
format.cc
format.cc
+9
-9
format.h
format.h
+3
-3
test/format-test.cc
test/format-test.cc
+1
-1
test/gtest-extra-test.cc
test/gtest-extra-test.cc
+8
-8
test/gtest-extra.cc
test/gtest-extra.cc
+2
-2
test/gtest-extra.h
test/gtest-extra.h
+2
-2
test/posix-test.cc
test/posix-test.cc
+2
-2
test/util-test.cc
test/util-test.cc
+8
-8
No files found.
format.cc
View file @
75b5eb4b
...
...
@@ -211,13 +211,13 @@ inline Arg::StringValue<wchar_t> ignore_incompatible_str(
Arg
::
StringValue
<
wchar_t
>
s
)
{
return
s
;
}
}
// namespace
int
fmt
::
internal
::
SignBitNoI
nline
(
double
value
)
{
return
SignBit
(
value
);
}
int
fmt
::
internal
::
signbit_noi
nline
(
double
value
)
{
return
SignBit
(
value
);
}
void
fmt
::
SystemError
::
init
(
int
error_code
,
StringRef
format_str
,
const
ArgList
&
args
)
{
error_code_
=
error_code
;
Writer
w
;
internal
::
FormatSystemErrorMessage
(
w
,
error_code
,
format
(
format_str
,
args
));
internal
::
format_system_error
(
w
,
error_code
,
format
(
format_str
,
args
));
std
::
runtime_error
&
base
=
*
this
;
base
=
std
::
runtime_error
(
w
.
str
());
}
...
...
@@ -326,7 +326,7 @@ void fmt::WindowsError::init(
int
error_code
,
StringRef
format_str
,
const
ArgList
&
args
)
{
error_code_
=
error_code
;
Writer
w
;
internal
::
FormatWinErrorMessage
(
w
,
error_code
,
format
(
format_str
,
args
));
internal
::
format_windows_error
(
w
,
error_code
,
format
(
format_str
,
args
));
std
::
runtime_error
&
base
=
*
this
;
base
=
std
::
runtime_error
(
w
.
str
());
}
...
...
@@ -361,7 +361,7 @@ int fmt::internal::safe_strerror(
return
result
;
}
void
fmt
::
internal
::
FormatSystemErrorMessage
(
void
fmt
::
internal
::
format_system_error
(
fmt
::
Writer
&
out
,
int
error_code
,
fmt
::
StringRef
message
)
{
Array
<
char
,
INLINE_BUFFER_SIZE
>
buffer
;
buffer
.
resize
(
INLINE_BUFFER_SIZE
);
...
...
@@ -382,7 +382,7 @@ void fmt::internal::FormatSystemErrorMessage(
}
#ifdef _WIN32
void
fmt
::
internal
::
FormatWinErrorMessage
(
void
fmt
::
internal
::
format_windows_error
(
fmt
::
Writer
&
out
,
int
error_code
,
fmt
::
StringRef
message
)
{
class
String
{
private:
...
...
@@ -1123,15 +1123,15 @@ void fmt::BasicFormatter<Char>::Format(
void
fmt
::
ReportSystemError
(
int
error_code
,
fmt
::
StringRef
message
)
FMT_NOEXCEPT
(
true
)
{
// FIXME:
FormatSystemErrorMessage
may throw
ReportError
(
internal
::
FormatSystemErrorMessage
,
error_code
,
message
);
// FIXME:
format_system_error
may throw
ReportError
(
internal
::
format_system_error
,
error_code
,
message
);
}
#ifdef _WIN32
void
fmt
::
ReportWinError
(
int
error_code
,
fmt
::
StringRef
message
)
FMT_NOEXCEPT
(
true
)
{
// FIXME:
FormatWinErrorMessage
may throw
ReportError
(
internal
::
FormatWinErrorMessage
,
error_code
,
message
);
// FIXME:
format_windows_error
may throw
ReportError
(
internal
::
format_windows_error
,
error_code
,
message
);
}
#endif
...
...
format.h
View file @
75b5eb4b
...
...
@@ -410,7 +410,7 @@ inline bool is_negative(T value) {
return
SignChecker
<
std
::
numeric_limits
<
T
>::
is_signed
>::
is_negative
(
value
);
}
int
SignBitNoI
nline
(
double
value
);
int
signbit_noi
nline
(
double
value
);
template
<
typename
T
>
struct
IntTraits
{
...
...
@@ -537,11 +537,11 @@ class UTF16ToUTF8 {
int
safe_strerror
(
int
error_code
,
char
*&
buffer
,
std
::
size_t
buffer_size
)
FMT_NOEXCEPT
(
true
);
void
FormatSystemErrorMessage
(
void
format_system_error
(
fmt
::
Writer
&
out
,
int
error_code
,
fmt
::
StringRef
message
);
#ifdef _WIN32
void
FormatWinErrorMessage
(
void
format_windows_error
(
fmt
::
Writer
&
out
,
int
error_code
,
fmt
::
StringRef
message
);
#endif
...
...
test/format-test.cc
View file @
75b5eb4b
...
...
@@ -1229,7 +1229,7 @@ TEST(FormatterTest, FormatNaN) {
double
nan
=
std
::
numeric_limits
<
double
>::
quiet_NaN
();
EXPECT_EQ
(
"nan"
,
format
(
"{}"
,
nan
));
EXPECT_EQ
(
"+nan"
,
format
(
"{:+}"
,
nan
));
if
(
fmt
::
internal
::
SignBitNoI
nline
(
-
nan
))
if
(
fmt
::
internal
::
signbit_noi
nline
(
-
nan
))
EXPECT_EQ
(
"-nan"
,
format
(
"{}"
,
-
nan
));
else
fmt
::
print
(
"Warning: compiler doesn't handle negative NaN correctly"
);
...
...
test/gtest-extra-test.cc
View file @
75b5eb4b
...
...
@@ -308,8 +308,8 @@ TEST(ExpectTest, EXPECT_SYSTEM_ERROR) {
"ThrowSystemError() throws an exception with a different message.
\n
"
"Expected: {}
\n
"
" Actual: {}"
,
FormatSystemErrorMessage
(
EDOM
,
"other"
),
FormatSystemErrorMessage
(
EDOM
,
"test"
)));
format_system_error
(
EDOM
,
"other"
),
format_system_error
(
EDOM
,
"test"
)));
}
// Tests EXPECT_WRITE.
...
...
@@ -347,10 +347,10 @@ TEST(StreamingAssertionsTest, EXPECT_WRITE) {
<<
"expected failure"
,
"expected failure"
);
}
TEST
(
UtilTest
,
FormatSystemError
Message
)
{
TEST
(
UtilTest
,
FormatSystemError
)
{
fmt
::
Writer
out
;
fmt
::
internal
::
FormatSystemErrorMessage
(
out
,
EDOM
,
"test message"
);
EXPECT_EQ
(
out
.
str
(),
FormatSystemErrorMessage
(
EDOM
,
"test message"
));
fmt
::
internal
::
format_system_error
(
out
,
EDOM
,
"test message"
);
EXPECT_EQ
(
out
.
str
(),
format_system_error
(
EDOM
,
"test message"
));
}
#if FMT_USE_FILE_DESCRIPTORS
...
...
@@ -500,7 +500,7 @@ TEST(BufferedFileTest, CloseErrorInDtor) {
// redirection.
FMT_POSIX
(
close
(
f
->
fileno
()));
SUPPRESS_ASSERT
(
delete
f
);
},
FormatSystemErrorMessage
(
EBADF
,
"cannot close file"
)
+
"
\n
"
);
},
format_system_error
(
EBADF
,
"cannot close file"
)
+
"
\n
"
);
}
TEST
(
BufferedFileTest
,
Close
)
{
...
...
@@ -624,7 +624,7 @@ TEST(FileTest, CloseErrorInDtor) {
// redirection.
FMT_POSIX
(
close
(
f
->
descriptor
()));
SUPPRESS_ASSERT
(
delete
f
);
},
FormatSystemErrorMessage
(
EBADF
,
"cannot close file"
)
+
"
\n
"
);
},
format_system_error
(
EBADF
,
"cannot close file"
)
+
"
\n
"
);
}
TEST
(
FileTest
,
Close
)
{
...
...
@@ -825,7 +825,7 @@ TEST(OutputRedirectTest, ErrorInDtor) {
// redirection.
FMT_POSIX
(
close
(
write_fd
));
SUPPRESS_ASSERT
(
delete
redir
);
},
FormatSystemErrorMessage
(
EBADF
,
"cannot flush stream"
));
},
format_system_error
(
EBADF
,
"cannot flush stream"
));
write_copy
.
dup2
(
write_fd
);
// "undo" close or dtor of BufferedFile will fail
}
...
...
test/gtest-extra.cc
View file @
75b5eb4b
...
...
@@ -91,8 +91,8 @@ std::string OutputRedirect::RestoreAndRead() {
#endif // FMT_USE_FILE_DESCRIPTORS
std
::
string
FormatSystemErrorMessage
(
int
error_code
,
fmt
::
StringRef
message
)
{
std
::
string
format_system_error
(
int
error_code
,
fmt
::
StringRef
message
)
{
fmt
::
Writer
out
;
fmt
::
internal
::
FormatSystemErrorMessage
(
out
,
error_code
,
message
);
fmt
::
internal
::
format_system_error
(
out
,
error_code
,
message
);
return
out
.
str
();
}
test/gtest-extra.h
View file @
75b5eb4b
...
...
@@ -81,11 +81,11 @@
FMT_TEST_THROW_(statement, expected_exception, \
expected_message, GTEST_NONFATAL_FAILURE_)
std
::
string
FormatSystemErrorMessage
(
int
error_code
,
fmt
::
StringRef
message
);
std
::
string
format_system_error
(
int
error_code
,
fmt
::
StringRef
message
);
#define EXPECT_SYSTEM_ERROR(statement, error_code, message) \
EXPECT_THROW_MSG(statement, fmt::SystemError, \
FormatSystemErrorMessage
(error_code, message))
format_system_error
(error_code, message))
#if FMT_USE_FILE_DESCRIPTORS
...
...
test/posix-test.cc
View file @
75b5eb4b
...
...
@@ -169,7 +169,7 @@ TEST(FileTest, CloseNoRetryInDtor) {
delete
f
;
saved_close_count
=
close_count
;
close_count
=
0
;
},
FormatSystemErrorMessage
(
EINTR
,
"cannot close file"
)
+
"
\n
"
);
},
format_system_error
(
EINTR
,
"cannot close file"
)
+
"
\n
"
);
EXPECT_EQ
(
2
,
saved_close_count
);
}
...
...
@@ -299,7 +299,7 @@ TEST(BufferedFileTest, CloseNoRetryInDtor) {
delete
f
;
saved_fclose_count
=
fclose_count
;
fclose_count
=
0
;
},
FormatSystemErrorMessage
(
EINTR
,
"cannot close file"
)
+
"
\n
"
);
},
format_system_error
(
EINTR
,
"cannot close file"
)
+
"
\n
"
);
EXPECT_EQ
(
2
,
saved_fclose_count
);
}
...
...
test/util-test.cc
View file @
75b5eb4b
...
...
@@ -387,7 +387,7 @@ TEST(UtilTest, UTF8ToUTF16) {
template
<
typename
Converter
>
void
CheckUTFConversionError
(
const
char
*
message
)
{
fmt
::
Writer
out
;
fmt
::
internal
::
FormatWinErrorMessage
(
out
,
ERROR_INVALID_PARAMETER
,
message
);
fmt
::
internal
::
format_windows_error
(
out
,
ERROR_INVALID_PARAMETER
,
message
);
fmt
::
SystemError
error
(
0
,
""
);
try
{
Converter
(
0
);
...
...
@@ -471,20 +471,20 @@ void CheckThrowError(int error_code, FormatErrorMessage format) {
EXPECT_EQ
(
error_code
,
error
.
error_code
());
}
TEST
(
UtilTest
,
FormatSystemError
Message
)
{
TEST
(
UtilTest
,
FormatSystemError
)
{
fmt
::
Writer
message
;
fmt
::
internal
::
FormatSystemErrorMessage
(
message
,
EDOM
,
"test"
);
fmt
::
internal
::
format_system_error
(
message
,
EDOM
,
"test"
);
EXPECT_EQ
(
fmt
::
format
(
"test: {}"
,
GetSystemErrorMessage
(
EDOM
)),
message
.
str
());
}
TEST
(
UtilTest
,
ThrowSystemError
)
{
CheckThrowError
<
fmt
::
SystemError
>
(
EDOM
,
fmt
::
internal
::
FormatSystemErrorMessage
);
CheckThrowError
<
fmt
::
SystemError
>
(
EDOM
,
fmt
::
internal
::
format_system_error
);
}
TEST
(
UtilTest
,
ReportSystemError
)
{
fmt
::
Writer
out
;
fmt
::
internal
::
FormatSystemErrorMessage
(
out
,
EDOM
,
"test error"
);
fmt
::
internal
::
format_system_error
(
out
,
EDOM
,
"test error"
);
out
<<
'\n'
;
EXPECT_WRITE
(
stderr
,
fmt
::
ReportSystemError
(
EDOM
,
"test error"
),
out
.
str
());
}
...
...
@@ -500,7 +500,7 @@ TEST(UtilTest, FormatWinErrorMessage) {
fmt
::
internal
::
UTF16ToUTF8
utf8_message
(
message
);
LocalFree
(
message
);
fmt
::
Writer
actual_message
;
fmt
::
internal
::
FormatWinErrorMessage
(
fmt
::
internal
::
format_windows_error
(
actual_message
,
ERROR_FILE_EXISTS
,
"test"
);
EXPECT_EQ
(
fmt
::
format
(
"test: {}"
,
utf8_message
.
str
()),
actual_message
.
str
());
...
...
@@ -508,12 +508,12 @@ TEST(UtilTest, FormatWinErrorMessage) {
TEST
(
UtilTest
,
ThrowWinError
)
{
CheckThrowError
<
fmt
::
WindowsError
>
(
ERROR_FILE_EXISTS
,
fmt
::
internal
::
FormatWinErrorMessage
);
ERROR_FILE_EXISTS
,
fmt
::
internal
::
format_windows_error
);
}
TEST
(
UtilTest
,
ReportWinError
)
{
fmt
::
Writer
out
;
fmt
::
internal
::
FormatWinErrorMessage
(
out
,
ERROR_FILE_EXISTS
,
"test error"
);
fmt
::
internal
::
format_windows_error
(
out
,
ERROR_FILE_EXISTS
,
"test error"
);
out
<<
'\n'
;
EXPECT_WRITE
(
stderr
,
fmt
::
ReportWinError
(
ERROR_FILE_EXISTS
,
"test error"
),
out
.
str
());
...
...
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