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
bb38e40a
Commit
bb38e40a
authored
Feb 07, 2013
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better diagnostic on `CPPA_CHECK_NOT_EQUAL`
parent
996ab01d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
17 deletions
+20
-17
unit_testing/test.hpp
unit_testing/test.hpp
+11
-9
unit_testing/test_atom.cpp
unit_testing/test_atom.cpp
+9
-8
No files found.
unit_testing/test.hpp
View file @
bb38e40a
...
...
@@ -57,19 +57,21 @@ inline void cppa_failed(const V1& v1,
template
<
typename
V1
,
typename
V2
>
inline
void
cppa_check_value
(
const
V1
&
v1
,
const
V2
&
v2
,
const
char
*
fname
,
int
line_number
,
int
line
,
bool
expected
=
true
,
typename
enable_integral
<
false
,
V1
,
V2
>::
type
*
=
0
)
{
if
(
v1
==
v2
)
cppa_passed
(
fname
,
line_number
);
else
cppa_failed
(
v1
,
v2
,
fname
,
line
_number
);
if
(
(
v1
==
v2
)
==
expected
)
cppa_passed
(
fname
,
line
);
else
cppa_failed
(
v1
,
v2
,
fname
,
line
);
}
template
<
typename
V1
,
typename
V2
>
inline
void
cppa_check_value
(
V1
v1
,
V2
v2
,
const
char
*
fname
,
int
line_number
,
int
line
,
bool
expected
=
true
,
typename
enable_integral
<
true
,
V1
,
V2
>::
type
*
=
0
)
{
if
(
v1
==
static_cast
<
V1
>
(
v2
))
cppa_passed
(
fname
,
line_number
);
else
cppa_failed
(
v1
,
v2
,
fname
,
line
_number
);
if
(
(
v1
==
static_cast
<
V1
>
(
v2
))
==
expected
)
cppa_passed
(
fname
,
line
);
else
cppa_failed
(
v1
,
v2
,
fname
,
line
);
}
#define CPPA_TEST(name) \
...
...
@@ -101,14 +103,14 @@ inline void cppa_check_value(V1 v1, V2 v2,
#define CPPA_CHECK_EQUAL(lhs_loc, rhs_loc) \
cppa_check_value((lhs_loc), (rhs_loc), __FILE__, __LINE__)
#define CPPA_CHECK_NOT_EQUAL(lhs_loc, rhs_loc) \
cppa_check_value((lhs_loc), (rhs_loc), __FILE__, __LINE__, false)
#define CPPA_ERROR(err_msg) \
std::cerr << "ERROR in file " << __FILE__ << " on line " << __LINE__ \
<< ": " << err_msg << std::endl; \
cppa_inc_error_count()
#define CPPA_CHECK_NOT_EQUAL(lhs_loc, rhs_loc) \
CPPA_CHECK(!((lhs_loc) == (rhs_loc)))
#define CPPA_CHECKPOINT() \
std::cout << "checkpoint at line " << __LINE__ << " passed" << std::endl
...
...
unit_testing/test_atom.cpp
View file @
bb38e40a
...
...
@@ -35,11 +35,12 @@ int main() {
CPPA_TEST
(
test__atom
);
// check if there are leading bits that distinguish "zzz" and "000 "
CPPA_CHECK_NOT_EQUAL
(
atom
(
"zzz"
),
atom
(
"000 "
));
// check if there are leading bits that distinguish "abc" and " abc"
CPPA_CHECK_NOT_EQUAL
(
atom
(
"abc"
),
atom
(
" abc"
));
// 'illegal' characters are mapped to whitespaces
CPPA_CHECK_EQUAL
(
atom
(
" "
),
atom
(
"@!?"
));
CPPA_CHECK_NOT_EQUAL
(
atom
(
"abc"
),
atom
(
" abc"
));
// check to_string impl.
CPPA_CHECK_EQUAL
(
to_string
(
s_foo
),
"FooBar"
);
CPPA_CHECK_EQUAL
(
"FooBar"
,
to_string
(
s_foo
)
);
self
<<
make_cow_tuple
(
atom
(
"foo"
),
static_cast
<
std
::
uint32_t
>
(
42
))
<<
make_cow_tuple
(
atom
(
":Attach"
),
atom
(
":Baz"
),
"cstring"
)
<<
make_cow_tuple
(
atom
(
"b"
),
atom
(
"a"
),
atom
(
"c"
),
23.
f
)
...
...
@@ -48,22 +49,22 @@ int main() {
receive_for
(
i
,
3
)
(
on
<
atom
(
"foo"
),
std
::
uint32_t
>
()
>>
[
&
](
std
::
uint32_t
value
)
{
matched_pattern
[
0
]
=
true
;
CPPA_CHECK_EQUAL
(
value
,
42
);
CPPA_CHECK_EQUAL
(
42
,
value
);
},
on
<
atom
(
":Attach"
),
atom
(
":Baz"
),
string
>
()
>>
[
&
](
const
string
&
str
)
{
matched_pattern
[
1
]
=
true
;
CPPA_CHECK_EQUAL
(
str
,
"cstring"
);
CPPA_CHECK_EQUAL
(
"cstring"
,
str
);
},
on
<
atom
(
"a"
),
atom
(
"b"
),
atom
(
"c"
),
float
>
()
>>
[
&
](
float
value
)
{
matched_pattern
[
2
]
=
true
;
CPPA_CHECK_EQUAL
(
value
,
23.
f
);
CPPA_CHECK_EQUAL
(
23.
f
,
value
);
}
);
CPPA_CHECK
(
matched_pattern
[
0
]
&&
matched_pattern
[
1
]
&&
matched_pattern
[
2
]);
receive
(
others
()
>>
[]()
{
// "erase" message { atom("b"), atom("a"), atom("c"), 23.f }
}
// "erase" message { atom("b"), atom("a"), atom("c"), 23.f }
others
()
>>
CPPA_CHECKPOINT_CB
(),
after
(
std
::
chrono
::
seconds
(
0
))
>>
CPPA_UNEXPECTED_TOUT_CB
()
);
return
CPPA_TEST_RESULT
();
}
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