From 388cf5fcb33f24bc04f79cd1fbea980214518d54 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 4 Dec 2017 19:21:09 +0100 Subject: List devices by unique SC:SD id Add C API and tests Add mutexes Signed-off-by: Szczepan Zalega --- unittest/test_C_API.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'unittest/test_C_API.cpp') diff --git a/unittest/test_C_API.cpp b/unittest/test_C_API.cpp index be47f08..2d83ef4 100644 --- a/unittest/test_C_API.cpp +++ b/unittest/test_C_API.cpp @@ -43,6 +43,7 @@ TEST_CASE("C API connect", "[BASIC]") { TEST_CASE("Check retry count", "[BASIC]") { REQUIRE(login != 0); + NK_set_debug_level(3); REQUIRE(NK_get_admin_retry_count() == 3); REQUIRE(NK_get_user_retry_count() == 3); } @@ -56,4 +57,31 @@ TEST_CASE("Check long strings", "[STANDARD]") { result = NK_change_user_PIN(pin, longPin); REQUIRE(result == TOO_LONG_STRING); CAPTURE(result); +} + +#include + +TEST_CASE("multiple devices with ID", "[BASIC]") { + NK_logout(); + NK_set_debug_level(3); + auto s = NK_list_devices_by_cpuID(); + REQUIRE(s!=nullptr); + REQUIRE(strnlen(s, 4096) < 4096); + REQUIRE(strnlen(s, 4096) > 2*4); + std::cout << s << std::endl; + + char *string, *token; + int t; + + string = strndup(s, 4096); + free ( (void*) s); + + while ((token = strsep(&string, ";")) != nullptr){ + if (strnlen(token, 4096) < 3) continue; + std::cout << token << " connecting: "; + std::cout << (t=NK_connect_with_ID(token)) << std::endl; + REQUIRE(t == 1); + } + + free (string); } \ No newline at end of file -- cgit v1.2.1