diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-10-14 14:01:10 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-10-19 16:34:34 +0200 |
commit | 5e72941919f19c43c1cd7f79c5cb913caf2705e4 (patch) | |
tree | d83ced389eb5a34bba49295fc8c250a586d8b3d7 /unittest/test_C_API.cpp | |
parent | 6f2769cb57c06d4ee10532b80482b8610aae4f2b (diff) | |
download | libnitrokey-5e72941919f19c43c1cd7f79c5cb913caf2705e4.tar.gz libnitrokey-5e72941919f19c43c1cd7f79c5cb913caf2705e4.tar.bz2 |
Test C API in C++ (Catch)
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest/test_C_API.cpp')
-rw-r--r-- | unittest/test_C_API.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/unittest/test_C_API.cpp b/unittest/test_C_API.cpp new file mode 100644 index 0000000..37d3c7f --- /dev/null +++ b/unittest/test_C_API.cpp @@ -0,0 +1,34 @@ +static const int TOO_LONG_STRING = 200; + +#include "catch.hpp" + +#include <iostream> +#include <string> +#include "log.h" +#include "../NK_C_API.h" + +TEST_CASE("C API connect", "[BASIC]") { + auto login = NK_login_auto(); + REQUIRE(login != 0); + NK_logout(); + login = NK_login_auto(); + REQUIRE(login != 0); + NK_logout(); + login = NK_login_auto(); + REQUIRE(login != 0); +} + +TEST_CASE("Check retry count", "[BASIC]") { + REQUIRE(NK_get_admin_retry_count() == 3); + REQUIRE(NK_get_user_retry_count() == 3); +} + +TEST_CASE("Check long strings", "[STANDARD]") { + char* longPin = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + char *pin = "123123123"; + auto result = NK_change_user_PIN(longPin, pin); + REQUIRE(result == TOO_LONG_STRING); + result = NK_change_user_PIN(pin, longPin); + REQUIRE(result == TOO_LONG_STRING); + CAPTURE(result); +}
\ No newline at end of file |