Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
db05a3f6
Commit
db05a3f6
authored
May 14, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of verbose switch-case statements
parent
b375fa2e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
84 deletions
+18
-84
libcaf_test/caf/test/unit_test.hpp
libcaf_test/caf/test/unit_test.hpp
+12
-18
libcaf_test/caf/test/unit_test_impl.hpp
libcaf_test/caf/test/unit_test_impl.hpp
+6
-66
No files found.
libcaf_test/caf/test/unit_test.hpp
View file @
db05a3f6
...
...
@@ -74,7 +74,7 @@ struct dummy_fixture { };
template
<
class
T
>
class
test_impl
:
public
test
{
public:
test_impl
(
std
::
string
name
)
:
test
(
std
::
move
(
name
))
{
test_impl
(
std
::
string
test_name
)
:
test
(
std
::
move
(
test_
name
))
{
// nop
}
...
...
@@ -286,23 +286,17 @@ class engine {
int
m_argc
=
0
;
char
**
m_argv
=
nullptr
;
char
*
m_path
=
nullptr
;
const
char
*
m_reset
=
"
\033
[0m"
;
const
char
*
m_black
=
"
\033
[30m"
;
const
char
*
m_red
=
"
\033
[31m"
;
const
char
*
m_green
=
"
\033
[32m"
;
const
char
*
m_yellow
=
"
\033
[33m"
;
const
char
*
m_blue
=
"
\033
[34m"
;
const
char
*
m_magenta
=
"
\033
[35m"
;
const
char
*
m_cyan
=
"
\033
[36m"
;
const
char
*
m_white
=
"
\033
[37m"
;
const
char
*
m_bold_black
=
"
\033
[1m
\033
[30m"
;
const
char
*
m_bold_red
=
"
\033
[1m
\033
[31m"
;
const
char
*
m_bold_green
=
"
\033
[1m
\033
[32m"
;
const
char
*
m_bold_yellow
=
"
\033
[1m
\033
[33m"
;
const
char
*
m_bold_blue
=
"
\033
[1m
\033
[34m"
;
const
char
*
m_bold_magenta
=
"
\033
[1m
\033
[35m"
;
const
char
*
m_bold_cyan
=
"
\033
[1m
\033
[36m"
;
const
char
*
m_bold_white
=
"
\033
[1m
\033
[37m"
;
const
char
*
m_colors
[
9
][
2
]
=
{
{
"
\033
[0m"
,
"
\033
[0m"
},
// reset
{
"
\033
[30m"
,
"
\033
[1m
\033
[30m"
},
// black
{
"
\033
[31m"
,
"
\033
[1m
\033
[31m"
},
// red
{
"
\033
[32m"
,
"
\033
[1m
\033
[32m"
},
// green
{
"
\033
[33m"
,
"
\033
[1m
\033
[33m"
},
// yellow
{
"
\033
[34m"
,
"
\033
[1m
\033
[34m"
},
// blue
{
"
\033
[35m"
,
"
\033
[1m
\033
[35m"
},
// magenta
{
"
\033
[36m"
,
"
\033
[1m
\033
[36m"
},
// cyan
{
"
\033
[37m"
,
"
\033
[1m
\033
[37m"
}
// white
};
const
char
*
m_check_file
=
"<none>"
;
size_t
m_check_line
=
0
;
test
*
m_current_test
=
nullptr
;
...
...
libcaf_test/caf/test/unit_test_impl.hpp
View file @
db05a3f6
...
...
@@ -268,23 +268,11 @@ bool engine::run(bool colorize,
return
true
;
}
if
(
!
colorize
)
{
instance
().
m_reset
=
""
;
instance
().
m_black
=
""
;
instance
().
m_red
=
""
;
instance
().
m_green
=
""
;
instance
().
m_yellow
=
""
;
instance
().
m_blue
=
""
;
instance
().
m_magenta
=
""
;
instance
().
m_cyan
=
""
;
instance
().
m_white
=
""
;
instance
().
m_bold_black
=
""
;
instance
().
m_bold_red
=
""
;
instance
().
m_bold_green
=
""
;
instance
().
m_bold_yellow
=
""
;
instance
().
m_bold_blue
=
""
;
instance
().
m_bold_magenta
=
""
;
instance
().
m_bold_cyan
=
""
;
instance
().
m_bold_white
=
""
;
for
(
size_t
i
=
0
;
i
<=
static_cast
<
size_t
>
(
white
);
++
i
)
{
for
(
size_t
j
=
0
;
j
<=
static_cast
<
size_t
>
(
bold
);
++
j
)
{
instance
().
m_colors
[
i
][
j
]
=
""
;
}
}
}
if
(
!
logger
::
init
(
verbosity_console
,
verbosity_file
,
log_file
))
{
return
false
;
...
...
@@ -445,55 +433,7 @@ bool engine::run(bool colorize,
}
const
char
*
engine
::
color
(
color_value
v
,
color_face
t
)
{
if
(
v
==
reset
)
{
return
instance
().
m_reset
;
}
switch
(
t
)
{
default:
return
nullptr
;
case
normal
:
switch
(
v
)
{
default:
return
nullptr
;
case
black
:
return
instance
().
m_black
;
case
red
:
return
instance
().
m_red
;
case
green
:
return
instance
().
m_green
;
case
yellow
:
return
instance
().
m_yellow
;
case
blue
:
return
instance
().
m_blue
;
case
magenta
:
return
instance
().
m_magenta
;
case
cyan
:
return
instance
().
m_cyan
;
case
white
:
return
instance
().
m_white
;
}
case
bold
:
switch
(
v
)
{
default:
return
nullptr
;
case
black
:
return
instance
().
m_bold_black
;
case
red
:
return
instance
().
m_bold_red
;
case
green
:
return
instance
().
m_bold_green
;
case
yellow
:
return
instance
().
m_bold_yellow
;
case
blue
:
return
instance
().
m_bold_blue
;
case
magenta
:
return
instance
().
m_bold_magenta
;
case
cyan
:
return
instance
().
m_bold_cyan
;
case
white
:
return
instance
().
m_bold_white
;
}
}
return
instance
().
m_colors
[
static_cast
<
size_t
>
(
v
)][
static_cast
<
size_t
>
(
t
)];
}
const
char
*
engine
::
last_check_file
()
{
...
...
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