#![allow(missing_docs)]
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
use codec_multibase::{multibase_to_bytes, MultibaseError};
#[test]
fn multibyte_first_char_does_not_panic() {
assert!(matches!(
multibase_to_bytes("é"),
Err(MultibaseError::UnsupportedPrefix)
));
assert!(matches!(
multibase_to_bytes("€zzz"),
Err(MultibaseError::UnsupportedPrefix)
));
assert!(matches!(
multibase_to_bytes("🔑abc"),
Err(MultibaseError::UnsupportedPrefix)
));
}
#[test]
fn empty_input_is_rejected_but_empty_multibase_payloads_round_trip() {
assert!(matches!(
multibase_to_bytes(""),
Err(MultibaseError::TooShort)
));
assert_eq!(
multibase_to_bytes("z").expect("empty base58btc"),
Vec::new()
);
assert_eq!(
multibase_to_bytes("u").expect("empty base64url"),
Vec::new()
);
}
#[test]
fn ascii_unsupported_prefix_rejected() {
assert!(matches!(
multibase_to_bytes("xdata"),
Err(MultibaseError::UnsupportedPrefix)
));
}
#[test]
fn valid_base64url_prefix_round_trips() {
let decoded = multibase_to_bytes("uaGVsbG8").expect("valid base64url multibase");
assert_eq!(decoded, b"hello");
}