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
d3b17836
Commit
d3b17836
authored
Apr 30, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test.
parent
0bece942
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
17 deletions
+23
-17
format-test.cc
format-test.cc
+23
-17
No files found.
format-test.cc
View file @
d3b17836
...
...
@@ -281,34 +281,40 @@ TEST(UtilTest, SystemError) {
EXPECT_EQ
(
42
,
e
.
error_code
());
}
#ifndef _WIN32
const
int
TEST_ERROR
=
EDOM
;
std
::
string
GetTestErrorMessage
()
{
return
strerror
(
TEST_ERROR
);
}
#else
const
int
TEST_ERROR
=
ERROR_FILE_EXISTS
;
std
::
string
GetTestErrorMessage
()
{
LPWSTR
message
=
0
;
FormatMessageW
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
0
,
ERROR_FILE_EXISTS
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
reinterpret_cast
<
LPWSTR
>
(
&
message
),
0
,
0
);
fmt
::
internal
::
UTF16ToUTF8
utf8_message
(
message
);
LocalFree
(
message
);
return
fmt
::
str
(
utf8_message
);
TEST
(
UtilTest
,
ThrowSystemError
)
{
const
int
TEST_ERROR
=
EDOM
;
fmt
::
SystemError
error
(
""
,
0
);
try
{
fmt
::
ThrowSystemError
(
TEST_ERROR
,
"test {}"
)
<<
"error"
;
}
catch
(
const
fmt
::
SystemError
&
e
)
{
error
=
e
;
}
EXPECT_EQ
(
str
(
fmt
::
Format
(
"test error: {}"
)
<<
strerror
(
TEST_ERROR
)),
error
.
what
());
EXPECT_EQ
(
TEST_ERROR
,
error
.
error_code
());
}
#endif
TEST
(
UtilTest
,
ThrowSystemError
)
{
#ifdef _WIN32
TEST
(
UtilTest
,
ThrowWinError
)
{
const
int
TEST_ERROR
=
ERROR_FILE_EXISTS
;
fmt
::
SystemError
error
(
""
,
0
);
try
{
fmt
::
ThrowSystemError
(
TEST_ERROR
,
"test {}"
)
<<
"error"
;
}
catch
(
const
fmt
::
SystemError
&
e
)
{
error
=
e
;
}
EXPECT_EQ
(
str
(
fmt
::
Format
(
"test error: {}"
)
<<
GetTestErrorMessage
()),
LPWSTR
message
=
0
;
FormatMessageW
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
0
,
ERROR_FILE_EXISTS
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
reinterpret_cast
<
LPWSTR
>
(
&
message
),
0
,
0
);
fmt
::
internal
::
UTF16ToUTF8
utf8_message
(
message
);
LocalFree
(
message
);
EXPECT_EQ
(
str
(
fmt
::
Format
(
"test error: {}"
)
<<
fmt
::
str
(
utf8_message
)),
error
.
what
());
EXPECT_EQ
(
TEST_ERROR
,
error
.
error_code
());
}
#endif
class
TestString
{
private:
...
...
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