summaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-04-02 15:02:36 +0200
committerRobin Krahl <robin.krahl@ireas.org>2020-04-02 15:20:29 +0200
commit67b14773cf4ab1812af85d3aaf99bdc6119c5a8a (patch)
tree44b1df4dacb8a477312eb92fff424e1e8c368f0d /unittest
parent6100df4127eca5f9733cd5fa51acd32c8febd754 (diff)
downloadlibnitrokey-67b14773cf4ab1812af85d3aaf99bdc6119c5a8a.tar.gz
libnitrokey-67b14773cf4ab1812af85d3aaf99bdc6119c5a8a.tar.bz2
NitrokeyManager: Also return serial number as u32
This patch adds the get_serial_number_as_u32 method to NitrokeyManager. It returns the serial number as a 32-bit unsigned integer. Previously, we only returned it as a string generated from the integer value, get_serial_number. While get_serial_number returns an empty string if no device is connected and "NA" if an unknown model is connected, the new method throws a DeviceNotConnected exception in the first case and returns zero in the second case as we cannot express the three states in one integer return value.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/test_offline.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/unittest/test_offline.cc b/unittest/test_offline.cc
index 320ad48..3ca3905 100644
--- a/unittest/test_offline.cc
+++ b/unittest/test_offline.cc
@@ -67,6 +67,10 @@ TEST_CASE("Test C++ side behaviour in offline", "[fast]") {
REQUIRE(serial_number.empty());
REQUIRE_THROWS_AS(
+ i->get_serial_number_as_u32(), DeviceNotConnected
+ );
+
+ REQUIRE_THROWS_AS(
i->get_status(), DeviceNotConnected
);