summaryrefslogtreecommitdiffstats
path: root/openpgp/src
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-11-24 17:48:02 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-11-24 18:50:11 +0100
commit693b748d9f84f53dda511cdf7e125252f3e0530c (patch)
tree94e7116a731ffe783685e84e2b0dcdb6f8e0cef4 /openpgp/src
parent16b7bfd59b3293fcb5bca36c35f74db3f16abd0b (diff)
openpgp: Improve tests.
Diffstat (limited to 'openpgp/src')
-rw-r--r--openpgp/src/armor.rs31
1 files changed, 18 insertions, 13 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs
index 1e4aaccc..13c8df4c 100644
--- a/openpgp/src/armor.rs
+++ b/openpgp/src/armor.rs
@@ -1669,6 +1669,8 @@ mod test {
let mut buf = [0; 5];
let e = r.read(&mut buf);
assert!(e.is_ok());
+ assert_eq!(e.unwrap(), 3);
+ assert_eq!(&buf[..3], TEST_BIN[3]);
}
#[test]
@@ -1680,8 +1682,10 @@ mod test {
ReaderMode::VeryTolerant);
let mut buf = [0; 5];
let e = r.read(&mut buf);
- assert!(r.kind() == Some(Kind::File));
+ assert_eq!(r.kind(), Some(Kind::File));
assert!(e.is_ok());
+ assert_eq!(e.unwrap(), 3);
+ assert_eq!(&buf[..3], TEST_BIN[3]);
}
#[test]
@@ -1696,6 +1700,8 @@ mod test {
let e = r.read(&mut buf);
assert_eq!(r.kind(), Some(Kind::File));
assert!(e.is_ok());
+ assert_eq!(e.unwrap(), 3);
+ assert_eq!(&buf[..3], TEST_BIN[3]);
// Again, but this time add a non-whitespace character in the
// line of the header.
@@ -1760,8 +1766,10 @@ mod test {
ReaderMode::VeryTolerant);
let mut buf = [0; 5];
let e = r.read(&mut buf);
- assert!(r.kind() == Some(Kind::File));
+ assert_eq!(r.kind(), Some(Kind::File));
assert!(e.is_ok());
+ assert_eq!(e.unwrap(), 3);
+ assert_eq!(&buf[..3], TEST_BIN[3]);
}
#[test]
@@ -1773,8 +1781,10 @@ mod test {
ReaderMode::VeryTolerant);
let mut buf = [0; 5];
let e = r.read(&mut buf);
- assert!(r.kind() == Some(Kind::File));
+ assert_eq!(r.kind(), Some(Kind::File));
assert!(e.is_ok());
+ assert_eq!(e.unwrap(), 3);
+ assert_eq!(&buf[..3], TEST_BIN[3]);
}
#[test]
@@ -1785,16 +1795,11 @@ mod test {
),
ReaderMode::VeryTolerant);
let mut buf = [0; 5];
- // Loop over the input to ensure we read and verify all the way to the
- // end of the input in order to check the checksum and footer validation
- loop {
- let e = r.read(&mut buf);
- assert!(r.kind() == Some(Kind::File));
- assert!(e.is_ok());
- if e.unwrap() == 0 {
- break;
- }
- }
+ let e = r.read(&mut buf);
+ assert_eq!(r.kind(), Some(Kind::File));
+ assert!(e.is_ok());
+ assert_eq!(e.unwrap(), 3);
+ assert_eq!(&buf[..3], TEST_BIN[3]);
}
#[test]