From 99e417b8b5ca921f45f59f85b887f9bf6f03a267 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 10 Jul 2018 12:34:03 +0200 Subject: Fix generic connections (connect()) to return correct device This patch fixes the generic connect() method to return a DeviceWrapper of the correct type. This is enabled by the NK_get_device_model() method introduced in libnitrokey v3.4. --- src/tests/device.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/tests') diff --git a/src/tests/device.rs b/src/tests/device.rs index 60ca33a..c2c5336 100644 --- a/src/tests/device.rs +++ b/src/tests/device.rs @@ -33,6 +33,10 @@ fn connect_pro() { assert!(::connect().is_ok()); assert!(::Pro::connect().is_ok()); assert!(::Storage::connect().is_err()); + match ::connect().unwrap() { + ::DeviceWrapper::Pro(_) => assert!(true), + ::DeviceWrapper::Storage(_) => assert!(false), + }; } #[test] @@ -41,6 +45,10 @@ fn connect_storage() { assert!(::connect().is_ok()); assert!(::Pro::connect().is_err()); assert!(::Storage::connect().is_ok()); + match ::connect().unwrap() { + ::DeviceWrapper::Pro(_) => assert!(false), + ::DeviceWrapper::Storage(_) => assert!(true), + }; } fn assert_empty_serial_number() { -- cgit v1.2.3