Skip to content

Commit

Permalink
test(kyberlib): ✅ Add unit tests for KyberLibError
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienrousseau committed May 9, 2024
1 parent 5c9797c commit f41d7fe
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,40 @@ fn test_kyber_lib_error_display() {
error.to_string(),
"Random bytes generation function failed"
);

let error = KyberLibError::InvalidKey;
assert_eq!(
error.to_string(),
"The secret and public key given does not match."
);
}

#[test]
fn test_kyber_lib_error_partial_eq() {
let error1 = KyberLibError::InvalidInput;
let error2 = KyberLibError::InvalidInput;
assert_eq!(error1, error2);

let error1 = KyberLibError::Decapsulation;
let error2 = KyberLibError::Decapsulation;
assert_eq!(error1, error2);

let error1 = KyberLibError::RandomBytesGeneration;
let error2 = KyberLibError::RandomBytesGeneration;
assert_eq!(error1, error2);

let error1 = KyberLibError::InvalidKey;
let error2 = KyberLibError::InvalidKey;
assert_eq!(error1, error2);

let error1 = KyberLibError::InvalidInput;
let error2 = KyberLibError::Decapsulation;
assert_ne!(error1, error2);
}

#[cfg(feature = "std")]
#[test]
fn test_kyber_lib_error_std_error() {
let error = KyberLibError::InvalidInput;
let _std_error: &dyn std::error::Error = &error;
}

0 comments on commit f41d7fe

Please sign in to comment.