-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d2d582
commit 79ad956
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// This software is distributed under the terms of the MIT License. | ||
// Copyright (c) 2016-2021 UAVCAN Development Team. | ||
|
||
#include "exposed.hpp" | ||
#include "helpers.hpp" | ||
|
||
TEST_CASE("FilterSubject") | ||
{ | ||
const heartbeat_subject_id = 7509; | ||
CanardFilter heartbeat_config = canardMakeFilterForSubject(heartbeat_subject_id); | ||
REQUIRE(heartbeat_config.extended_can_id & (heartbeat_subject_id << OFFSET_SUBJECT_ID)); | ||
REQUIRE(heartbeat_config.extended_mask & FLAG_SERVICE_NOT_MESSAGE); | ||
REQUIRE(heartbeat_config.extended_mask & FLAG_RESERVED_07); | ||
REQUIRE(heartbeat_config.extended_mask & (CANARD_SUBJECT_ID_MAX << OFFSET_SUBJECT_ID)); | ||
} | ||
|
||
TEST_CASE("FilterService") | ||
{ | ||
const access_service_id = 7509; | ||
const node_id = 42; | ||
CanardFilter access_config = canardMakeFilterForService(access_service_id, node_id); | ||
REQUIRE(access_config.extended_can_id & (access_subject_id << OFFSET_SERVICE_ID)); | ||
REQUIRE(access_config.extended_can_id & (node_id << OFFSET_DST_NODE_ID)); | ||
REQUIRE(access_config.extended_can_id & FLAG_SERVICE_NOT_MESSAGE); | ||
REQUIRE(access_config.extended_mask & FLAG_SERVICE_NOT_MESSAGE); | ||
REQUIRE(access_config.extended_mask & FLAG_RESERVED_23); | ||
REQUIRE(access_config.extended_mask & (CANARD_SERVICE_ID_MAX << OFFSET_SERVICE_ID)); | ||
REQUIRE(access_config.extended_mask & (CANARD_NODE_ID_MAX << OFFSET_DST_NODE_ID)); | ||
} | ||
|
||
TEST_CASE("FilterServices") | ||
{ | ||
const node_id = 42; | ||
access_config = canardMakeFilterForServices(node_id); | ||
REQUIRE(access_config.extended_can_id & (node_id << OFFSET_DST_NODE_ID)); | ||
REQUIRE(access_config.extended_can_id & FLAG_SERVICE_NOT_MESSAGE); | ||
REQUIRE(access_config.extended_mask & FLAG_SERVICE_NOT_MESSAGE); | ||
REQUIRE(access_config.extended_mask & FLAG_RESERVED_23); | ||
REQUIRE(access_config.extended_mask & (CANARD_NODE_ID_MAX << OFFSET_DST_NODE_ID)); | ||
} | ||
|
||
TEST_CASE("Consolidate") | ||
{ | ||
const heartbeat_subject_id = 7509; | ||
CanardFilter heartbeat_config = canardMakeFilterForSubject(heartbeat_subject_id); | ||
|
||
const access_service_id = 7509; | ||
const node_id = 42; | ||
CanardFilter access_config = canardMakeFilterForService(access_service_id, node_id); | ||
|
||
CanardFilter combined = canardConsolidateFilters(&heartbeat_config, &access_config); | ||
REQUIRE((combined.extended_mask | heartbeat_config.extended_mask) == heartbeat_config.extended_mask); | ||
REQUIRE((combined.extended_mask | access_config.extended_mask) == access_config.extended_mask); | ||
} |