Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
dea6a7c2
Commit
dea6a7c2
authored
Oct 05, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests: Fixed some clang-tidy warnings
parent
887a104d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
4 deletions
+21
-4
errors.cpp
tests/errors.cpp
+2
-0
file_log.cpp
tests/file_log.cpp
+2
-0
test_pattern_formatter.cpp
tests/test_pattern_formatter.cpp
+0
-3
utils.cpp
tests/utils.cpp
+17
-1
No files found.
tests/errors.cpp
View file @
dea6a7c2
...
...
@@ -83,7 +83,9 @@ TEST_CASE("async_error_handler", "[errors]]")
logger
->
set_error_handler
([
=
](
const
std
::
string
&
)
{
std
::
ofstream
ofs
(
"logs/custom_err.txt"
);
if
(
!
ofs
)
{
throw
std
::
runtime_error
(
"Failed open logs/custom_err.txt"
);
}
ofs
<<
err_msg
;
});
logger
->
info
(
"Good message #1"
);
...
...
tests/file_log.cpp
View file @
dea6a7c2
...
...
@@ -62,7 +62,9 @@ TEST_CASE("rotating_file_logger2", "[rotating_logger]]")
std
::
string
basename
=
"logs/rotating_log"
;
auto
logger
=
spdlog
::
rotating_logger_mt
(
"logger"
,
basename
,
max_size
,
1
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
logger
->
info
(
"Test message {}"
,
i
);
}
logger
->
flush
();
auto
filename
=
basename
;
...
...
tests/test_pattern_formatter.cpp
View file @
dea6a7c2
...
...
@@ -20,9 +20,6 @@ TEST_CASE("custom eol", "[pattern_formatter]")
{
std
::
string
msg
=
"Hello custom eol test"
;
std
::
string
eol
=
";)"
;
// auto formatter = std::make_shared<spdlog::pattern_formatter>("%v", spdlog::pattern_time_type::local, ";)");
std
::
unique_ptr
<
spdlog
::
formatter
>
(
new
spdlog
::
pattern_formatter
(
"%v"
,
spdlog
::
pattern_time_type
::
local
,
";)"
));
REQUIRE
(
log_to_str
(
msg
,
"%v"
,
spdlog
::
pattern_time_type
::
local
,
";)"
)
==
msg
+
eol
);
}
...
...
tests/utils.cpp
View file @
dea6a7c2
...
...
@@ -8,8 +8,15 @@ void prepare_logdir()
system
(
"del /F /Q logs
\\
*"
);
#else
auto
rv
=
system
(
"mkdir -p logs"
);
if
(
rv
!=
0
)
{
throw
std
::
runtime_error
(
"Failed to mkdir -p logs"
);
}
rv
=
system
(
"rm -f logs/*"
);
(
void
)
rv
;
if
(
rv
!=
0
)
{
throw
std
::
runtime_error
(
"Failed to rm -f logs/*"
);
}
#endif
}
...
...
@@ -17,7 +24,9 @@ std::string file_contents(const std::string &filename)
{
std
::
ifstream
ifs
(
filename
);
if
(
!
ifs
)
{
throw
std
::
runtime_error
(
"Failed open file "
);
}
return
std
::
string
((
std
::
istreambuf_iterator
<
char
>
(
ifs
)),
(
std
::
istreambuf_iterator
<
char
>
()));
}
...
...
@@ -25,7 +34,9 @@ std::size_t count_lines(const std::string &filename)
{
std
::
ifstream
ifs
(
filename
);
if
(
!
ifs
)
{
throw
std
::
runtime_error
(
"Failed open file "
);
}
std
::
string
line
;
size_t
counter
=
0
;
...
...
@@ -38,7 +49,9 @@ std::size_t get_filesize(const std::string &filename)
{
std
::
ifstream
ifs
(
filename
,
std
::
ifstream
::
ate
|
std
::
ifstream
::
binary
);
if
(
!
ifs
)
{
throw
std
::
runtime_error
(
"Failed open file "
);
}
return
static_cast
<
std
::
size_t
>
(
ifs
.
tellg
());
}
...
...
@@ -47,6 +60,9 @@ std::size_t get_filesize(const std::string &filename)
bool
ends_with
(
std
::
string
const
&
value
,
std
::
string
const
&
ending
)
{
if
(
ending
.
size
()
>
value
.
size
())
{
return
false
;
}
return
std
::
equal
(
ending
.
rbegin
(),
ending
.
rend
(),
value
.
rbegin
());
}
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