diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-06-14 11:45:20 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-06-14 12:08:28 +0200 |
commit | ccc1f1c9e2f7539f9b27bc7161ad21e7d259c339 (patch) | |
tree | b95029f92fa51cb3145f1371e85524f33200af1f /openpgp/src/keyid.rs | |
parent | 0070d3e7e6fe1a448b1b5357ffd5af71a6c993a4 (diff) |
openpgp: Add test.
Diffstat (limited to 'openpgp/src/keyid.rs')
-rw-r--r-- | openpgp/src/keyid.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/openpgp/src/keyid.rs b/openpgp/src/keyid.rs index 936729a5..abc26426 100644 --- a/openpgp/src/keyid.rs +++ b/openpgp/src/keyid.rs @@ -188,4 +188,23 @@ mod test { KeyID::new(id).as_u64().unwrap() == id } } + + #[test] + fn from_hex() { + KeyID::from_hex("FB3751F1587DAEF1").unwrap(); + KeyID::from_hex("39D100AB67D5BD8C04010205FB3751F1587DAEF1") + .unwrap(); + KeyID::from_hex("0xFB3751F1587DAEF1").unwrap(); + KeyID::from_hex("0x39D100AB67D5BD8C04010205FB3751F1587DAEF1") + .unwrap(); + KeyID::from_hex("FB37 51F1 587D AEF1").unwrap(); + KeyID::from_hex("39D1 00AB 67D5 BD8C 0401 0205 FB37 51F1 587D AEF1") + .unwrap(); + KeyID::from_hex("GB3751F1587DAEF1").unwrap_err(); + KeyID::from_hex("EFB3751F1587DAEF1").unwrap_err(); + KeyID::from_hex("%FB3751F1587DAEF1").unwrap_err(); + assert_match!(KeyID::Invalid(_) = KeyID::from_hex("587DAEF1").unwrap()); + assert_match!(KeyID::Invalid(_) = + KeyID::from_hex("0x587DAEF1").unwrap()); + } } |