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
0935d0e3
Commit
0935d0e3
authored
Aug 01, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix missing-braces warning on Clang
parent
e3c616d3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
16 deletions
+21
-16
libcaf_core/caf/ipv4_address.hpp
libcaf_core/caf/ipv4_address.hpp
+5
-0
libcaf_core/src/ipv4_address.cpp
libcaf_core/src/ipv4_address.cpp
+6
-0
libcaf_core/test/ipv4_address.cpp
libcaf_core/test/ipv4_address.cpp
+3
-8
libcaf_core/test/ipv4_subnet.cpp
libcaf_core/test/ipv4_subnet.cpp
+1
-3
libcaf_core/test/ipv6_address.cpp
libcaf_core/test/ipv6_address.cpp
+5
-4
libcaf_core/test/ipv6_subnet.cpp
libcaf_core/test/ipv6_subnet.cpp
+1
-1
No files found.
libcaf_core/caf/ipv4_address.hpp
View file @
0935d0e3
...
@@ -108,6 +108,11 @@ private:
...
@@ -108,6 +108,11 @@ private:
// -- related free functions ---------------------------------------------------
// -- related free functions ---------------------------------------------------
/// Convenience function for creating an IPv4 address from octets.
/// @relates ipv4_address
ipv4_address
make_ipv4_address
(
uint8_t
oct1
,
uint8_t
oct2
,
uint8_t
oct3
,
uint8_t
oct4
);
/// Returns a human-readable string representation of the address.
/// Returns a human-readable string representation of the address.
/// @relates ipv4_address
/// @relates ipv4_address
std
::
string
to_string
(
const
ipv4_address
&
x
);
std
::
string
to_string
(
const
ipv4_address
&
x
);
...
...
libcaf_core/src/ipv4_address.cpp
View file @
0935d0e3
...
@@ -71,6 +71,12 @@ bool ipv4_address::is_multicast() const noexcept {
...
@@ -71,6 +71,12 @@ bool ipv4_address::is_multicast() const noexcept {
// -- related free functions ---------------------------------------------------
// -- related free functions ---------------------------------------------------
ipv4_address
make_ipv4_address
(
uint8_t
oct1
,
uint8_t
oct2
,
uint8_t
oct3
,
uint8_t
oct4
)
{
ipv4_address
::
array_type
bytes
{{
oct1
,
oct2
,
oct3
,
oct4
}};
return
ipv4_address
{
bytes
};
}
std
::
string
to_string
(
const
ipv4_address
&
x
)
{
std
::
string
to_string
(
const
ipv4_address
&
x
)
{
using
std
::
to_string
;
using
std
::
to_string
;
std
::
string
result
;
std
::
string
result
;
...
...
libcaf_core/test/ipv4_address.cpp
View file @
0935d0e3
...
@@ -31,20 +31,15 @@ using namespace caf;
...
@@ -31,20 +31,15 @@ using namespace caf;
namespace
{
namespace
{
using
array_type
=
ipv4_address
::
array_type
;
const
auto
addr
=
make_ipv4_address
;
ipv4_address
addr
(
uint8_t
oct1
,
uint8_t
oct2
,
uint8_t
oct3
,
uint8_t
oct4
)
{
return
ipv4_address
({
oct1
,
oct2
,
oct3
,
oct4
});
}
}
// namespace <anonymous>
}
// namespace <anonymous>
CAF_TEST
(
constructing
)
{
CAF_TEST
(
constructing
)
{
ipv4_address
localhost
({
127
,
0
,
0
,
1
}
);
auto
localhost
=
addr
(
127
,
0
,
0
,
1
);
CAF_CHECK_EQUAL
(
localhost
.
bits
(),
to_network_order
(
0x7F000001u
));
CAF_CHECK_EQUAL
(
localhost
.
bits
(),
to_network_order
(
0x7F000001u
));
CAF_CHECK_EQUAL
(
localhost
.
data
(),
array_type
({
127
,
0
,
0
,
1
}));
ipv4_address
zero
;
ipv4_address
zero
;
CAF_CHECK_EQUAL
(
zero
.
data
(),
array_type
({
0
,
0
,
0
,
0
})
);
CAF_CHECK_EQUAL
(
zero
.
bits
(),
0u
);
}
}
CAF_TEST
(
to
and
from
string
)
{
CAF_TEST
(
to
and
from
string
)
{
...
...
libcaf_core/test/ipv4_subnet.cpp
View file @
0935d0e3
...
@@ -27,9 +27,7 @@ using namespace caf;
...
@@ -27,9 +27,7 @@ using namespace caf;
namespace
{
namespace
{
ipv4_address
addr
(
uint8_t
oct1
,
uint8_t
oct2
,
uint8_t
oct3
,
uint8_t
oct4
)
{
const
auto
addr
=
make_ipv4_address
;
return
ipv4_address
({
oct1
,
oct2
,
oct3
,
oct4
});
}
ipv4_subnet
operator
/
(
ipv4_address
addr
,
uint8_t
prefix
)
{
ipv4_subnet
operator
/
(
ipv4_address
addr
,
uint8_t
prefix
)
{
return
{
addr
,
prefix
};
return
{
addr
,
prefix
};
...
...
libcaf_core/test/ipv6_address.cpp
View file @
0935d0e3
...
@@ -40,9 +40,10 @@ ipv6_address addr(std::initializer_list<uint16_t> prefix,
...
@@ -40,9 +40,10 @@ ipv6_address addr(std::initializer_list<uint16_t> prefix,
}
// namespace <anonymous>
}
// namespace <anonymous>
CAF_TEST
(
constructing
)
{
CAF_TEST
(
constructing
)
{
ipv6_address
localhost
({
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
});
ipv6_address
::
array_type
localhost_bytes
{{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
CAF_CHECK_EQUAL
(
localhost
.
data
(),
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
}};
array_type
({
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
}));
ipv6_address
localhost
{
localhost_bytes
};
CAF_CHECK_EQUAL
(
localhost
.
data
(),
localhost_bytes
);
CAF_CHECK_EQUAL
(
localhost
,
addr
({},
{
0x01
}));
CAF_CHECK_EQUAL
(
localhost
,
addr
({},
{
0x01
}));
}
}
...
@@ -50,7 +51,7 @@ CAF_TEST(comparison) {
...
@@ -50,7 +51,7 @@ CAF_TEST(comparison) {
CAF_CHECK_EQUAL
(
addr
({
1
,
2
,
3
}),
addr
({
1
,
2
,
3
}));
CAF_CHECK_EQUAL
(
addr
({
1
,
2
,
3
}),
addr
({
1
,
2
,
3
}));
CAF_CHECK_NOT_EQUAL
(
addr
({
3
,
2
,
1
}),
addr
({
1
,
2
,
3
}));
CAF_CHECK_NOT_EQUAL
(
addr
({
3
,
2
,
1
}),
addr
({
1
,
2
,
3
}));
CAF_CHECK_EQUAL
(
addr
({},
{
0xFFFF
,
0x7F00
,
0x0001
}),
CAF_CHECK_EQUAL
(
addr
({},
{
0xFFFF
,
0x7F00
,
0x0001
}),
ipv4_address
({
127
,
0
,
0
,
1
}
));
make_ipv4_address
(
127
,
0
,
0
,
1
));
}
}
CAF_TEST
(
from
string
)
{
CAF_TEST
(
from
string
)
{
...
...
libcaf_core/test/ipv6_subnet.cpp
View file @
0935d0e3
...
@@ -46,7 +46,7 @@ CAF_TEST(constains) {
...
@@ -46,7 +46,7 @@ CAF_TEST(constains) {
}
}
CAF_TEST
(
embedding
)
{
CAF_TEST
(
embedding
)
{
ipv4_subnet
v4_local
{
ipv4_address
({
127
,
0
,
0
,
1
}
),
8
};
ipv4_subnet
v4_local
{
make_ipv4_address
(
127
,
0
,
0
,
1
),
8
};
ipv6_subnet
local
{
v4_local
};
ipv6_subnet
local
{
v4_local
};
CAF_CHECK
(
local
.
embeds_v4
());
CAF_CHECK
(
local
.
embeds_v4
());
CAF_CHECK_EQUAL
(
local
.
prefix_length
(),
104u
);
CAF_CHECK_EQUAL
(
local
.
prefix_length
(),
104u
);
...
...
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