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
9b2d839e
Commit
9b2d839e
authored
Jan 18, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed debug output
parent
529a3e14
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
11 deletions
+24
-11
unit_testing/test__pattern.cpp
unit_testing/test__pattern.cpp
+24
-11
No files found.
unit_testing/test__pattern.cpp
View file @
9b2d839e
#include <string>
#include <string>
#include <sstream>
#include "test.hpp"
#include "test.hpp"
...
@@ -23,15 +24,17 @@
...
@@ -23,15 +24,17 @@
using
namespace
cppa
;
using
namespace
cppa
;
template
<
typename
Arr
>
template
<
typename
Arr
>
void
plot
(
Arr
const
&
arr
)
std
::
string
plot
(
Arr
const
&
arr
)
{
{
cout
<<
"{ "
;
std
::
ostringstream
oss
;
oss
<<
"{ "
;
for
(
size_t
i
=
0
;
i
<
arr
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
arr
.
size
();
++
i
)
{
{
if
(
i
>
0
)
cout
<<
", "
;
if
(
i
>
0
)
oss
<<
", "
;
cout
<<
"arr["
<<
i
<<
"] = "
<<
((
arr
[
i
])
?
arr
[
i
]
->
name
()
:
"anything"
);
oss
<<
"arr["
<<
i
<<
"] = "
<<
((
arr
[
i
])
?
arr
[
i
]
->
name
()
:
"anything"
);
}
}
cout
<<
" }"
<<
endl
;
oss
<<
" }"
;
return
oss
.
str
();
}
}
typedef
std
::
pair
<
int
,
int
>
foobar
;
typedef
std
::
pair
<
int
,
int
>
foobar
;
...
@@ -59,28 +62,38 @@ match_helper match(any_tuple const& x)
...
@@ -59,28 +62,38 @@ match_helper match(any_tuple const& x)
size_t
test__pattern
()
size_t
test__pattern
()
{
{
CPPA_TEST
(
test__pattern
);
match
(
make_tuple
(
1
,
2
,
3
))
match
(
make_tuple
(
1
,
2
,
3
))
(
(
on_arg_match
>>
[](
int
a
,
int
b
,
int
c
)
on_arg_match
>>
[
&
](
int
a
,
int
b
,
int
c
)
{
{
cout
<<
"MATCH: "
<<
a
<<
", "
<<
b
<<
", "
<<
c
<<
endl
;
CPPA_CHECK_EQUAL
(
a
,
1
);
CPPA_CHECK_EQUAL
(
b
,
2
);
CPPA_CHECK_EQUAL
(
c
,
3
);
}
}
);
);
pattern
<
int
,
anything
,
int
>
i3
;
pattern
<
int
,
anything
,
int
>
i3
;
any_tuple
i3_any_tup
=
make_tuple
(
1
,
2
,
3
);
any_tuple
i3_any_tup
=
make_tuple
(
1
,
2
,
3
);
auto
opt
=
tuple_cast
(
i3_any_tup
,
i3
);
auto
opt
=
tuple_cast
(
i3_any_tup
,
i3
);
CPPA_CHECK
(
opt
.
valid
());
if
(
opt
.
valid
())
if
(
opt
.
valid
())
{
{
cout
<<
"x = ( "
<<
get
<
0
>
(
*
opt
)
<<
", "
<<
get
<
1
>
(
*
opt
)
<<
" )"
<<
endl
;
CPPA_CHECK_EQUAL
(
get
<
0
>
(
*
opt
),
1
);
CPPA_CHECK_EQUAL
(
get
<
1
>
(
*
opt
),
3
);
}
}
announce
<
foobar
>
(
&
foobar
::
first
,
&
foobar
::
second
);
announce
<
foobar
>
(
&
foobar
::
first
,
&
foobar
::
second
);
plot
(
arr1
);
static
constexpr
char
const
*
arr1_as_string
=
plot
(
arr2
);
"{ arr[0] = @i32, arr[1] = anything, arr[2] = float }"
;
CPPA_CHECK_EQUAL
(
plot
(
arr1
),
arr1_as_string
);
static
constexpr
char
const
*
arr2_as_string
=
"{ arr[0] = @i32, arr[1] = anything, "
"arr[2] = std::pair<@i32,@i32> }"
;
CPPA_CHECK_EQUAL
(
plot
(
arr2
),
arr2_as_string
);
CPPA_TEST
(
test__pattern
);
// some pattern objects to play with
// some pattern objects to play with
pattern
<
atom_value
,
int
,
std
::
string
>
p0
{
util
::
wrapped
<
atom_value
>
()};
pattern
<
atom_value
,
int
,
std
::
string
>
p0
{
util
::
wrapped
<
atom_value
>
()};
pattern
<
atom_value
,
int
,
std
::
string
>
p1
(
atom
(
"FooBar"
));
pattern
<
atom_value
,
int
,
std
::
string
>
p1
(
atom
(
"FooBar"
));
...
...
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