#[test] fn is_err() { // This code doesn't work without initializing NSS first.
fixture_init();
set_error_code(err::ssl::SSL_ERROR_BAD_MAC_READ); let r = result(ssl::SECFailure);
assert!(r.is_err()); match r.unwrap_err() {
Error::NssError { name, code, desc } => {
assert_eq!(name, "SSL_ERROR_BAD_MAC_READ");
assert_eq!(code, -12273);
assert_eq!(
desc, "SSL received a record with an incorrect Message Authentication Code."
);
}
_ => unreachable!(),
}
}
#[test] fn is_err_zero_code() { // This code doesn't work without initializing NSS first.
fixture_init();
set_error_code(0); let r = result(ssl::SECFailure);
assert!(r.is_err()); match r.unwrap_err() {
Error::NssError { name, code, .. } => {
assert_eq!(name, "UNKNOWN_ERROR");
assert_eq!(code, 0); // Note that we don't test |desc| here because that comes from // strerror(0), which is platform-dependent.
}
_ => unreachable!(),
}
}
#[test] fn blocked_as_error() { // This code doesn't work without initializing NSS first.
fixture_init();
set_error_code(nspr::PR_WOULD_BLOCK_ERROR); let r = result(ssl::SECFailure);
assert!(r.is_err()); match r.unwrap_err() {
Error::NssError { name, code, desc } => {
assert_eq!(name, "PR_WOULD_BLOCK_ERROR");
assert_eq!(code, -5998);
assert_eq!(desc, "The operation would have blocked");
}
_ => panic!("bad error type"),
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.