From 43bb63424fb7e78c245341c1baf326557ef896e8 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 31 Jan 2017 18:53:14 +0100 Subject: C++ tests fixed Signed-off-by: Szczepan Zalega --- unittest/test3.cc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'unittest/test3.cc') diff --git a/unittest/test3.cc b/unittest/test3.cc index 9049365..215df78 100644 --- a/unittest/test3.cc +++ b/unittest/test3.cc @@ -26,13 +26,15 @@ using namespace nitrokey::proto::stick10_08; using namespace nitrokey::log; using namespace nitrokey::misc; -void connect_and_setup(Stick10 &stick) { - bool connected = stick.connect(); +using Dev10 = std::shared_ptr; + +void connect_and_setup(Dev10 stick) { + bool connected = stick->connect(); REQUIRE(connected == true); Log::instance().set_loglevel(Loglevel::DEBUG); } -void authorize(Stick10 &stick) { +void authorize(Dev10 stick) { auto authreq = get_payload(); strcpy((char *) (authreq.card_password), default_admin_pin); strcpy((char *) (authreq.temporary_password), temporary_password); @@ -45,7 +47,8 @@ void authorize(Stick10 &stick) { } TEST_CASE("write slot", "[pronew]"){ - Stick10 stick; + auto stick = make_shared(); + connect_and_setup(stick); authorize(stick); @@ -81,7 +84,7 @@ TEST_CASE("write slot", "[pronew]"){ TEST_CASE("erase slot", "[pronew]"){ - Stick10 stick; + auto stick = make_shared(); connect_and_setup(stick); authorize(stick); @@ -107,7 +110,7 @@ TEST_CASE("erase slot", "[pronew]"){ } TEST_CASE("write general config", "[pronew]") { - Stick10 stick; + auto stick = make_shared(); connect_and_setup(stick); authorize(stick); @@ -121,7 +124,7 @@ TEST_CASE("write general config", "[pronew]") { } TEST_CASE("authorize user HOTP", "[pronew]") { - Stick10 stick; + auto stick = make_shared(); connect_and_setup(stick); authorize(stick); @@ -164,7 +167,7 @@ TEST_CASE("authorize user HOTP", "[pronew]") { } TEST_CASE("check firmware version", "[pronew]") { - Stick10 stick; + auto stick = make_shared(); connect_and_setup(stick); auto p = GetStatus::CommandTransaction::run(stick); @@ -172,7 +175,7 @@ TEST_CASE("check firmware version", "[pronew]") { } TEST_CASE("authorize user TOTP", "[pronew]") { - Stick10 stick; + auto stick = make_shared(); connect_and_setup(stick); authorize(stick); -- cgit v1.2.1 From fa02c23ee2f4bef6be8a502e11fc568dc74b4235 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 6 Feb 2017 09:25:03 +0100 Subject: Use CMake instead of Make Signed-off-by: Szczepan Zalega --- unittest/test3.cc | 5 ----- 1 file changed, 5 deletions(-) (limited to 'unittest/test3.cc') diff --git a/unittest/test3.cc b/unittest/test3.cc index 215df78..5302044 100644 --- a/unittest/test3.cc +++ b/unittest/test3.cc @@ -1,8 +1,3 @@ -// -// Created by sz on 08.11.16. -// - -#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() static const char *const default_admin_pin = "12345678"; static const char *const default_user_pin = "123456"; -- cgit v1.2.1 From c9867bccc816854f3670309f44c6dfbcb73429c5 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 6 Feb 2017 10:53:08 +0100 Subject: Use alias for easy device change Signed-off-by: Szczepan Zalega --- unittest/test3.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'unittest/test3.cc') diff --git a/unittest/test3.cc b/unittest/test3.cc index 5302044..9e0ef11 100644 --- a/unittest/test3.cc +++ b/unittest/test3.cc @@ -21,7 +21,8 @@ using namespace nitrokey::proto::stick10_08; using namespace nitrokey::log; using namespace nitrokey::misc; -using Dev10 = std::shared_ptr; +using Dev = Stick10; +using Dev10 = std::shared_ptr; void connect_and_setup(Dev10 stick) { bool connected = stick->connect(); @@ -42,7 +43,7 @@ void authorize(Dev10 stick) { } TEST_CASE("write slot", "[pronew]"){ - auto stick = make_shared(); + auto stick = make_shared(); connect_and_setup(stick); authorize(stick); @@ -79,7 +80,7 @@ TEST_CASE("write slot", "[pronew]"){ TEST_CASE("erase slot", "[pronew]"){ - auto stick = make_shared(); + auto stick = make_shared(); connect_and_setup(stick); authorize(stick); @@ -105,7 +106,7 @@ TEST_CASE("erase slot", "[pronew]"){ } TEST_CASE("write general config", "[pronew]") { - auto stick = make_shared(); + auto stick = make_shared(); connect_and_setup(stick); authorize(stick); @@ -119,7 +120,7 @@ TEST_CASE("write general config", "[pronew]") { } TEST_CASE("authorize user HOTP", "[pronew]") { - auto stick = make_shared(); + auto stick = make_shared(); connect_and_setup(stick); authorize(stick); @@ -162,7 +163,7 @@ TEST_CASE("authorize user HOTP", "[pronew]") { } TEST_CASE("check firmware version", "[pronew]") { - auto stick = make_shared(); + auto stick = make_shared(); connect_and_setup(stick); auto p = GetStatus::CommandTransaction::run(stick); @@ -170,7 +171,7 @@ TEST_CASE("check firmware version", "[pronew]") { } TEST_CASE("authorize user TOTP", "[pronew]") { - auto stick = make_shared(); + auto stick = make_shared(); connect_and_setup(stick); authorize(stick); -- cgit v1.2.1