From 116523fbee311aa7af5151d1a601c8a0f11965e9 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 24 Oct 2016 15:15:04 +0200 Subject: Test: reduced code bloat Signed-off-by: Szczepan Zalega --- unittest/test2.cc | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/unittest/test2.cc b/unittest/test2.cc index 883e37b..503ab49 100644 --- a/unittest/test2.cc +++ b/unittest/test2.cc @@ -17,6 +17,15 @@ using namespace nitrokey::log; using namespace nitrokey::misc; +template +void execute_password_command(Device &stick, const char *password) { + auto p = get_payload(); + p.set_kind_user(); + strcpyT(p.password, password); + CMDTYPE::CommandTransaction::run(stick, p); +} + + TEST_CASE("test", "[test]") { Stick20 stick; bool connected = stick.connect(); @@ -25,32 +34,11 @@ TEST_CASE("test", "[test]") { Log::instance().set_loglevel(Loglevel::DEBUG_L2); stick10::LockDevice::CommandTransaction::run(stick); -// { -// auto p = get_payload(); -// p.set_kind_user(); -// strcpyT(p.password, "123456"); -// EnableEncryptedPartition::CommandTransaction::run(stick, p); -// } -// { -// auto p = get_payload(); -// p.set_kind_user(); -// strcpyT(p.password, "123456"); -// DisableEncryptedPartition::CommandTransaction::run(stick, p); -// } - - { - auto p = get_payload(); - p.set_kind_user(); - strcpyT(p.password, "123456"); - EnableEncryptedPartition::CommandTransaction::run(stick, p); - } +// execute_password_command(stick, "123456"); +// execute_password_command(stick, "123456"); + execute_password_command(stick, "123456"); this_thread::sleep_for(1000ms); - { - auto p = get_payload(); - p.set_kind_user(); - strcpyT(p.password, "123123123"); - EnableHiddenEncryptedPartition::CommandTransaction::run(stick, p); - } + execute_password_command(stick, "123123123"); this_thread::sleep_for(1000ms); stick10::LockDevice::CommandTransaction::run(stick); -- cgit v1.2.3