Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_text/tests/base64_random.rs

472 bytes, 1 run

created by r657228385:78352, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1use oxedyne_fe2o3_text::base64;
2
3
4#[test]
5fn random_url_is_unpadded_url_safe_and_fresh() {
6 let (a, b) = (base64::random_url(16), base64::random_url(16));
7 assert_eq!(a.len(), base64::encoded_url_len(16));
8 assert!(a.bytes().all(|c| c.is_ascii_alphanumeric() || c == b'-' || c == b'_'), "{}", a);
9 assert_ne!(a, b, "two draws of 128 bits alike");
10 assert_eq!(base64::decode_url(&a).expect("decodes").len(), 16);
11 assert_eq!(base64::random_url(0), "");
12}