aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-09-01 23:31:59 +0200
committerSven Gothel <[email protected]>2021-09-01 23:31:59 +0200
commit501ffc3cf8386905a546df6a9ff43467ed2d9a7a (patch)
tree818d8c7b6b0226bf3addd848e09867ee88e3e450 /test
parent39b34d8480a6a2516665845c98cb153c788555b9 (diff)
Support std::error_code for 'enum class HCIStatusCode'
Diffstat (limited to 'test')
-rw-r--r--test/direct_bt/CMakeLists.txt3
-rw-r--r--test/direct_bt/test_misc_types.cpp34
2 files changed, 36 insertions, 1 deletions
diff --git a/test/direct_bt/CMakeLists.txt b/test/direct_bt/CMakeLists.txt
index 716f942d..0fb63d3a 100644
--- a/test/direct_bt/CMakeLists.txt
+++ b/test/direct_bt/CMakeLists.txt
@@ -5,9 +5,10 @@ include_directories(
# These examples use the standard separate compilation
set( SOURCES_IDIOMATIC_EXAMPLES
+ test_attpdu01.cpp
test_btaddress01.cpp
+ test_misc_types.cpp
test_uuid.cpp
- test_attpdu01.cpp
)
string( REPLACE ".cpp" "" BASENAMES_IDIOMATIC_EXAMPLES "${SOURCES_IDIOMATIC_EXAMPLES}" )
diff --git a/test/direct_bt/test_misc_types.cpp b/test/direct_bt/test_misc_types.cpp
new file mode 100644
index 00000000..e9e7673d
--- /dev/null
+++ b/test/direct_bt/test_misc_types.cpp
@@ -0,0 +1,34 @@
+#include <iostream>
+#include <cassert>
+#include <cinttypes>
+#include <cstring>
+
+#define CATCH_CONFIG_RUNNER
+// #define CATCH_CONFIG_MAIN
+#include <catch2/catch_amalgamated.hpp>
+#include <jau/test/catch2_ext.hpp>
+
+#include <direct_bt/HCITypes.hpp>
+
+using namespace direct_bt;
+
+TEST_CASE( "HCIStatusCodeCategory std::error_code Test", "[HCIStatusCode][HCIStatusCodeCategory][error_code]" ) {
+ std::error_code ec_0 = HCIStatusCode::SUCCESS;
+ std::error_code ec_12(HCIStatusCode::COMMAND_DISALLOWED);
+ std::error_code ec_42 = make_error_code(HCIStatusCode::DIFFERENT_TRANSACTION_COLLISION);
+
+ std::cout << "ec_0: " << ec_0 << std::endl;
+ std::cerr << "ec_12: " << ec_12 << std::endl;
+ std::cerr << "ec_42: " << ec_42 << std::endl;
+
+ REQUIRE( HCIStatusCodeCategory::get() == ec_0.category() );
+ REQUIRE( HCIStatusCodeCategory::get() == ec_12.category() );
+ REQUIRE( HCIStatusCodeCategory::get() == ec_42.category() );
+ REQUIRE( false == static_cast<bool>(ec_0) ); // explicit op bool
+ REQUIRE( true == static_cast<bool>(ec_12) ); // explicit op bool
+ REQUIRE( true == static_cast<bool>(ec_42) ); // explicit op bool
+ REQUIRE( 0 == ec_0.value() );
+ REQUIRE( 12 == ec_12.value() );
+ REQUIRE( 42 == ec_42.value() );
+
+}