-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Abbas Bracken Ziad
committed
Apr 27, 2021
1 parent
7ac8ab9
commit 27160db
Showing
3 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* |
43 changes: 43 additions & 0 deletions
43
...LE/tests/UNITTESTS/FEATURE_BLE/source/common/ble_trace_helpers/test_ble_trace_helpers.cpp
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,43 @@ | ||
/* mbed Microcontroller Library | ||
* Copyright (c) 2021 ARM Limited | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "ble_trace_helpers.h" | ||
#include "ble/common/UUID.h" | ||
|
||
TEST(to_string, UUID) | ||
{ | ||
static constexpr const size_t HYPHENS_DELIMITER_COUNT = 4; | ||
static constexpr const size_t LENGTH_OF_LONG_UUID_STRING = \ | ||
2 * UUID::LENGTH_OF_LONG_UUID + HYPHENS_DELIMITER_COUNT + 1; | ||
|
||
static constexpr const char *STRING_UUID_0 = "53880000-65FD-4651-BA8E-91527F06C887"; | ||
static constexpr const char *STRING_UUID_1 = "53880001-65FD-4651-BA8E-91527F06C887"; | ||
static constexpr const char *STRING_UUID_2 = "53880002-65FD-4651-BA8E-91527F06C887"; | ||
static constexpr const char *STRING_UUID_3 = "53880003-65FD-4651-BA8E-91527F06C887"; | ||
|
||
const UUID UUID_0 = UUID(STRING_UUID_0); | ||
const UUID UUID_1 = UUID(STRING_UUID_1); | ||
const UUID UUID_2 = UUID(STRING_UUID_2); | ||
const UUID UUID_3 = UUID(STRING_UUID_3); | ||
|
||
EXPECT_TRUE(0 == std::memcmp(ble::to_string(UUID_0), STRING_UUID_0, LENGTH_OF_LONG_UUID_STRING)); | ||
EXPECT_TRUE(0 == std::memcmp(ble::to_string(UUID_1), STRING_UUID_1, LENGTH_OF_LONG_UUID_STRING)); | ||
EXPECT_TRUE(0 == std::memcmp(ble::to_string(UUID_2), STRING_UUID_2, LENGTH_OF_LONG_UUID_STRING)); | ||
EXPECT_TRUE(0 == std::memcmp(ble::to_string(UUID_3), STRING_UUID_3, LENGTH_OF_LONG_UUID_STRING)); | ||
} |
28 changes: 28 additions & 0 deletions
28
...ty/FEATURE_BLE/tests/UNITTESTS/FEATURE_BLE/source/common/ble_trace_helpers/unittest.cmake
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,28 @@ | ||
#################### | ||
# UNIT TESTS | ||
#################### | ||
|
||
set(unittest-includes ${unittest-includes} | ||
../connectivity/FEATURE_BLE/source/common | ||
../connectivity/FEATURE_BLE/source | ||
../connectivity/FEATURE_BLE/include/ble | ||
../connectivity/FEATURE_BLE/include | ||
../connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/cfg | ||
../connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include | ||
../connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include | ||
|
||
../platform/mbed-trace/include/mbed-trace | ||
) | ||
|
||
set(unittest-sources | ||
../connectivity/FEATURE_BLE/source/common/ble_trace_helpers.cpp | ||
|
||
../platform/mbed-trace/source/mbed_trace.c | ||
) | ||
|
||
set(unittest-test-sources | ||
${CMAKE_CURRENT_LIST_DIR}/test_ble_trace_helpers.cpp | ||
) | ||
|
||
# BLE requires at least one role 'BROADCASTER' or 'OBSERVER' to be enabled | ||
add_compile_definitions(BLE_ROLE_BROADCASTER=1) |