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
dc5a9bb5
Commit
dc5a9bb5
authored
May 09, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tests for projections
parent
01b91604
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
unit_testing/test__match.cpp
unit_testing/test__match.cpp
+51
-0
No files found.
unit_testing/test__match.cpp
View file @
dc5a9bb5
...
@@ -152,6 +152,57 @@ size_t test__match()
...
@@ -152,6 +152,57 @@ size_t test__match()
bool
invoked
=
false
;
bool
invoked
=
false
;
auto
kvp_split1
=
[](
const
string
&
str
)
->
vector
<
string
>
{
auto
pos
=
str
.
find
(
'='
);
if
(
pos
!=
string
::
npos
&&
pos
==
str
.
rfind
(
'='
))
{
return
vector
<
string
>
{
str
.
substr
(
0
,
pos
),
str
.
substr
(
pos
+
1
)};
}
return
{};
};
/*
auto kvp_split2 = [](const string& str) -> option<vector<string> > {
auto pos = str.find('=');
if (pos != string::npos && pos == str.rfind('='))
{
return vector<string>{str.substr(0, pos-1), str.substr(pos+1)};
}
return {};
};
*/
match
(
"value=42"
)
(
on
(
kvp_split1
).
when
(
_x1
.
not_empty
())
>>
[
&
](
const
vector
<
string
>&
vec
)
{
CPPA_CHECK_EQUAL
(
vec
[
0
],
"value"
);
CPPA_CHECK_EQUAL
(
vec
[
1
],
"42"
);
invoked
=
true
;
}
);
CPPA_CHECK
(
invoked
);
invoked
=
false
;
auto
toint
=
[](
const
string
&
str
)
->
option
<
int
>
{
char
*
endptr
=
nullptr
;
int
result
=
static_cast
<
int
>
(
strtol
(
str
.
c_str
(),
&
endptr
,
10
));
if
(
endptr
!=
nullptr
&&
*
endptr
==
'\0'
)
{
return
result
;
}
return
{};
};
match
(
"42"
)
(
on
(
toint
)
>>
[
&
](
int
i
)
{
CPPA_CHECK_EQUAL
(
i
,
42
);
invoked
=
true
;
}
);
CPPA_CHECK
(
invoked
);
invoked
=
false
;
match
(
"abc"
)
match
(
"abc"
)
(
(
on
<
string
>
().
when
(
_x1
==
"abc"
)
>>
[
&
]()
on
<
string
>
().
when
(
_x1
==
"abc"
)
>>
[
&
]()
...
...
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