aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--device.cc6
-rw-r--r--unittest/test_offline.cc15
2 files changed, 19 insertions, 2 deletions
diff --git a/device.cc b/device.cc
index da54e33..80e4b38 100644
--- a/device.cc
+++ b/device.cc
@@ -69,8 +69,10 @@ bool Device::_disconnect() {
LOG(std::string(__FUNCTION__) + std::string(m_model == DeviceModel::PRO ? "PRO" : "STORAGE"), Loglevel::DEBUG_L2);
LOG(std::string(__FUNCTION__) + std::string(" *IN* "), Loglevel::DEBUG_L2);
- LOG(std::string("Disconnection: handle already freed: ") + std::to_string(mp_devhandle == nullptr) + " ("+m_path+")", Loglevel::DEBUG_L1);
- if(mp_devhandle == nullptr) return false;
+ if(mp_devhandle == nullptr) {
+ LOG(std::string("Disconnection: handle already freed: ") + std::to_string(mp_devhandle == nullptr) + " ("+m_path+")", Loglevel::DEBUG_L1);
+ return false;
+ }
hid_close(mp_devhandle);
mp_devhandle = nullptr;
diff --git a/unittest/test_offline.cc b/unittest/test_offline.cc
index 468849e..808c617 100644
--- a/unittest/test_offline.cc
+++ b/unittest/test_offline.cc
@@ -160,3 +160,18 @@ TEST_CASE("Test device commands ids", "[fast]") {
REQUIRE(STICK20_CMD_CHANGE_UPDATE_PIN == static_cast<uint8_t>(CommandID::CHANGE_UPDATE_PIN));
}
+
+
+TEST_CASE("Connect should not return true after second attempt", "[fast]") {
+ int result = 0;
+
+ result = NK_login("S");
+ REQUIRE(result == 0);
+
+ result = NK_login_auto();
+ REQUIRE(result == 0);
+
+ result = NK_logout();
+ REQUIRE(result == 0);
+
+}