wrapper/rust/: fix unit tests to avoid out-of-order wolfCrypt_Cleanup().

This commit is contained in:
Daniel Pouzzner
2026-01-13 14:43:50 -06:00
parent f878c43814
commit 1d247b744c
2 changed files with 4 additions and 11 deletions

View File

@@ -50,6 +50,8 @@ pub mod sha;
/// ```rust
/// use wolfssl_wolfcrypt::*;
/// wolfcrypt_init().expect("Error with wolfcrypt_init()");
/// // ... use the library ...
/// wolfcrypt_cleanup().expect("wolfCrypt_Cleanup failed");
/// ```
pub fn wolfcrypt_init() -> Result<(), i32> {
let rc = unsafe { sys::wolfCrypt_Init() };
@@ -66,12 +68,7 @@ pub fn wolfcrypt_init() -> Result<(), i32> {
/// Returns either Ok(()) on success or Err(e) containing the wolfSSL
/// library error code value.
///
/// # Example
///
/// ```rust
/// use wolfssl_wolfcrypt::*;
/// wolfcrypt_cleanup().expect("Error with wolfcrypt_cleanup()");
/// ```
/// See also: [`wolfcrypt_init`]
pub fn wolfcrypt_cleanup() -> Result<(), i32> {
let rc = unsafe { sys::wolfCrypt_Cleanup() };
if rc != 0 {

View File

@@ -1,11 +1,7 @@
use wolfssl_wolfcrypt::*;
#[test]
fn test_wolfcrypt_init() {
fn test_wolfcrypt_init_and_cleanup() {
wolfcrypt_init().expect("Error with wolfcrypt_init()");
}
#[test]
fn test_wolfcrypt_cleanup() {
wolfcrypt_cleanup().expect("Error with wolfcrypt_cleanup()");
}