aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-10-24 15:15:04 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-11-26 18:56:23 +0100
commit116523fbee311aa7af5151d1a601c8a0f11965e9 (patch)
tree8ad7fcb85deb8d80d76da09d564c7fddb241951b
parent536d2b40239cbff94d7e562a0c0c9cf4f462576f (diff)
downloadlibnitrokey-116523fbee311aa7af5151d1a601c8a0f11965e9.tar.gz
libnitrokey-116523fbee311aa7af5151d1a601c8a0f11965e9.tar.bz2
Test: reduced code bloat
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--unittest/test2.cc38
1 files 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<typename CMDTYPE>
+void execute_password_command(Device &stick, const char *password) {
+ auto p = get_payload<CMDTYPE>();
+ 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<EnableEncryptedPartition>();
-// p.set_kind_user();
-// strcpyT(p.password, "123456");
-// EnableEncryptedPartition::CommandTransaction::run(stick, p);
-// }
-// {
-// auto p = get_payload<DisableEncryptedPartition>();
-// p.set_kind_user();
-// strcpyT(p.password, "123456");
-// DisableEncryptedPartition::CommandTransaction::run(stick, p);
-// }
-
- {
- auto p = get_payload<EnableEncryptedPartition>();
- p.set_kind_user();
- strcpyT(p.password, "123456");
- EnableEncryptedPartition::CommandTransaction::run(stick, p);
- }
+// execute_password_command<EnableEncryptedPartition>(stick, "123456");
+// execute_password_command<DisableEncryptedPartition>(stick, "123456");
+ execute_password_command<EnableEncryptedPartition>(stick, "123456");
this_thread::sleep_for(1000ms);
- {
- auto p = get_payload<EnableHiddenEncryptedPartition>();
- p.set_kind_user();
- strcpyT(p.password, "123123123");
- EnableHiddenEncryptedPartition::CommandTransaction::run(stick, p);
- }
+ execute_password_command<EnableHiddenEncryptedPartition>(stick, "123123123");
this_thread::sleep_for(1000ms);
stick10::LockDevice::CommandTransaction::run(stick);