From d92707ca48137b47800006a09539470acb4e4d69 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Sat, 5 Mar 2016 17:10:14 +0100 Subject: adding basic tests --- unittest/test.cc | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'unittest/test.cc') diff --git a/unittest/test.cc b/unittest/test.cc index 2c77b60..2004d1e 100644 --- a/unittest/test.cc +++ b/unittest/test.cc @@ -22,9 +22,10 @@ std::string getSlotName(Stick10 &stick, int slotNo) { TEST_CASE("Slot names are correct", "[slotNames]") { Stick10 stick; - stick.connect(); + bool connected = stick.connect(); + REQUIRE(connected == true); - Log::instance().set_loglevel(Loglevel::DEBUG_L2); + // Log::instance().set_loglevel(Loglevel::DEBUG_L2); auto resp = GetStatus::CommandTransaction::run(stick); @@ -34,5 +35,39 @@ TEST_CASE("Slot names are correct", "[slotNames]") { REQUIRE(getSlotName(stick, 0x20) == std::string("1")); REQUIRE(getSlotName(stick, 0x21) == std::string("slot2")); + + { + auto resp = GetPasswordRetryCount::CommandTransaction::run(stick); + REQUIRE( resp.password_retry_count == 3 ); + } + { + auto resp = GetUserPasswordRetryCount::CommandTransaction::run(stick); + REQUIRE( resp.password_retry_count == 3 ); + } + + { + GetPasswordSafeSlotName::CommandTransaction::CommandPayload slot; + slot.slot_number = 0; + auto resp2 = GetPasswordSafeSlotName::CommandTransaction::run(stick, slot); + std::string sName(reinterpret_cast(resp2.slot_name)); + REQUIRE(sName == std::string("web1")); + } + + { + GetPasswordSafeSlotPassword::CommandTransaction::CommandPayload slot; + slot.slot_number = 0; + auto resp2 = GetPasswordSafeSlotPassword::CommandTransaction::run(stick, slot); + std::string sName(reinterpret_cast(resp2.slot_password)); + REQUIRE(sName == std::string("pass1")); + } + + { + GetPasswordSafeSlotLogin::CommandTransaction::CommandPayload slot; + slot.slot_number = 0; + auto resp2 = GetPasswordSafeSlotLogin::CommandTransaction::run(stick, slot); + std::string sName(reinterpret_cast(resp2.slot_login)); + REQUIRE(sName == std::string("login1")); + } + stick.disconnect(); } -- cgit v1.2.1