qrcode: Add some more tests

master
Damir Jelić 2021-05-20 14:04:40 +02:00
parent b073323089
commit f49f5f1636
1 changed files with 20 additions and 1 deletions

View File

@ -197,8 +197,27 @@ mod test {
#[test] #[test]
fn decode_short_secret() { fn decode_short_secret() {
let data = b"MATRIX\x02\x02\x00\x07FLOW_IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBSECRET"; let data = b"MATRIX\
\x02\x02\x00\x07\
FLOW_ID\
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\
SECRET";
let result = QrVerification::from_bytes(data); let result = QrVerification::from_bytes(data);
assert!(matches!(result, Err(DecodingError::SharedSecret(_)))) assert!(matches!(result, Err(DecodingError::SharedSecret(_))))
} }
#[test]
fn decode_invalid_room_id() {
let data = b"MATRIX\
\x02\x00\x00\x0f\
test:localhost\
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\
SECRETISLONGENOUGH";
let result = QrVerification::from_bytes(data);
assert!(matches!(result, Err(DecodingError::Identifier(_))))
}
} }