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
c4336998
Commit
c4336998
authored
Sep 05, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add initial BASP application unit tests
parent
04d918ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
5 deletions
+51
-5
libcaf_net/caf/net/basp/application.hpp
libcaf_net/caf/net/basp/application.hpp
+5
-1
libcaf_net/test/application.cpp
libcaf_net/test/application.cpp
+46
-4
No files found.
libcaf_net/caf/net/basp/application.hpp
View file @
c4336998
...
...
@@ -79,6 +79,10 @@ public:
static
expected
<
std
::
vector
<
byte
>>
serialize
(
actor_system
&
sys
,
const
type_erased_tuple
&
x
);
connection_state
state
()
const
noexcept
{
return
state_
;
}
private:
// -- message handling -------------------------------------------------------
...
...
@@ -91,7 +95,7 @@ private:
// -- member variables -------------------------------------------------------
/// Stores what we are expecting to receive next.
connection_state
state_
=
connection_state
::
shutdown
;
connection_state
state_
=
connection_state
::
await_magic_number
;
/// Caches the last header;we need to store it when waiting for the payload.
header
hdr_
;
...
...
libcaf_net/test/application.cpp
View file @
c4336998
...
...
@@ -16,26 +16,68 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#define CAF_SUITE application
#define CAF_SUITE
basp.
application
#include "caf/net/basp/application.hpp"
#include "caf/test/dsl.hpp"
#include <vector>
#include "caf/byte.hpp"
#include "caf/net/basp/connection_state.hpp"
#include "caf/net/basp/constants.hpp"
#include "caf/net/basp/ec.hpp"
#include "caf/none.hpp"
using
namespace
caf
;
using
namespace
caf
::
net
;
#define REQUIRE_OK(statement) \
if (auto err = statement) \
CAF_FAIL("failed to serialize data: " << sys.render(err));
namespace
{
struct
fixture
{
struct
fixture
:
test_coordinator_fixture
<>
{
using
buffer_type
=
std
::
vector
<
byte
>
;
fixture
()
{
REQUIRE_OK
(
app
.
init
(
*
this
));
}
template
<
class
...
Ts
>
void
set_input
(
const
Ts
&
...
xs
)
{
serializer_impl
<
buffer_type
>
sink
{
nullptr
,
input
};
REQUIRE_OK
(
sink
(
xs
...));
}
buffer_type
input
;
buffer_type
output
;
basp
::
application
app
;
};
}
// namespace
CAF_TEST_FIXTURE_SCOPE
(
application_tests
,
fixture
)
CAF_TEST
(
todo
)
{
// implement me
CAF_TEST
(
invalid
magic
number
)
{
CAF_CHECK_EQUAL
(
app
.
state
(),
basp
::
connection_state
::
await_magic_number
);
set_input
(
basp
::
magic_number
+
1
);
CAF_CHECK_EQUAL
(
app
.
handle_data
(
*
this
,
input
),
basp
::
ec
::
invalid_magic_number
);
}
CAF_TEST
(
handshake
sequence
)
{
basp
::
application
app
;
REQUIRE_OK
(
app
.
init
(
*
this
));
CAF_CHECK_EQUAL
(
app
.
state
(),
basp
::
connection_state
::
await_magic_number
);
set_input
(
basp
::
magic_number
);
REQUIRE_OK
(
app
.
handle_data
(
*
this
,
input
));
CAF_CHECK_EQUAL
(
app
.
state
(),
basp
::
connection_state
::
await_handshake_header
);
}
CAF_TEST_FIXTURE_SCOPE_END
()
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