Skip to content

Commit 1d247b7

Browse files
committed
wrapper/rust/: fix unit tests to avoid out-of-order wolfCrypt_Cleanup().
1 parent f878c43 commit 1d247b7

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

wrapper/rust/wolfssl-wolfcrypt/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ pub mod sha;
5050
/// ```rust
5151
/// use wolfssl_wolfcrypt::*;
5252
/// wolfcrypt_init().expect("Error with wolfcrypt_init()");
53+
/// // ... use the library ...
54+
/// wolfcrypt_cleanup().expect("wolfCrypt_Cleanup failed");
5355
/// ```
5456
pub fn wolfcrypt_init() -> Result<(), i32> {
5557
let rc = unsafe { sys::wolfCrypt_Init() };
@@ -66,12 +68,7 @@ pub fn wolfcrypt_init() -> Result<(), i32> {
6668
/// Returns either Ok(()) on success or Err(e) containing the wolfSSL
6769
/// library error code value.
6870
///
69-
/// # Example
70-
///
71-
/// ```rust
72-
/// use wolfssl_wolfcrypt::*;
73-
/// wolfcrypt_cleanup().expect("Error with wolfcrypt_cleanup()");
74-
/// ```
71+
/// See also: [`wolfcrypt_init`]
7572
pub fn wolfcrypt_cleanup() -> Result<(), i32> {
7673
let rc = unsafe { sys::wolfCrypt_Cleanup() };
7774
if rc != 0 {
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
use wolfssl_wolfcrypt::*;
22

33
#[test]
4-
fn test_wolfcrypt_init() {
4+
fn test_wolfcrypt_init_and_cleanup() {
55
wolfcrypt_init().expect("Error with wolfcrypt_init()");
6-
}
7-
8-
#[test]
9-
fn test_wolfcrypt_cleanup() {
106
wolfcrypt_cleanup().expect("Error with wolfcrypt_cleanup()");
117
}

0 commit comments

Comments
 (0)