-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for service and characteristics classes
Issue #5
- Loading branch information
Showing
3 changed files
with
67 additions
and
5 deletions.
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
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,53 @@ | ||
/** | ||
* @file test_service_container.cc | ||
* @copyright (c) 2018, natersoz. Distributed under the Apache 2.0 license. | ||
*/ | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "ble/gatt_service_container.h" | ||
#include "ble/service/gap_service.h" | ||
#include "ble/service/battery_service.h" | ||
#include "ble/service/current_time_service.h" | ||
#include "ble/gap_connection_parameters.h" | ||
|
||
TEST(ServiceContainerTest, GAP_Battery_Time) | ||
{ | ||
// --- GAP service | ||
constexpr char const device_name[] = "periph"; | ||
constexpr size_t const device_name_length = std::size(device_name) - 1u; | ||
|
||
ble::gap::connection_parameters const gap_connection_parameters( | ||
ble::gap::connection_interval_msec(100), | ||
ble::gap::connection_interval_msec(200), | ||
0u, | ||
ble::gap::supervision_timeout_msec(4000u)); | ||
|
||
ble::service::device_name device_name_characteristic(device_name, device_name_length); | ||
ble::service::appearance appearance_characteristic(ble::gatt::appearance::unknown); | ||
ble::service::ppcp ppcp_characteristic(gap_connection_parameters); | ||
ble::service::gap_service gap_service; | ||
|
||
gap_service.characteristic_add(device_name_characteristic); | ||
gap_service.characteristic_add(appearance_characteristic); | ||
gap_service.characteristic_add(ppcp_characteristic); | ||
|
||
// --- Battery Service | ||
ble::service::battery_level battery_level_characteristic; | ||
ble::service::battery_power_state battery_power_characteristic; | ||
ble::service::battery_service battery_service; | ||
|
||
battery_service.characteristic_add(battery_level_characteristic); | ||
battery_service.characteristic_add(battery_power_characteristic); | ||
|
||
// --- Current Time Service | ||
ble::service::current_time_service current_time_service; | ||
|
||
ble::gatt::service_container service_container; | ||
service_container.push_back(gap_service); | ||
service_container.push_back(battery_service); | ||
service_container.push_back(current_time_service); | ||
|
||
|
||
} | ||
|