summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2023-07-04 18:33:24 +0200
committerJustus Winter <justus@sequoia-pgp.org>2023-07-04 18:36:22 +0200
commit9525ad1ac6945dbd4a1174decb5d717a698da676 (patch)
treecfc83c1c6f9f20292414bd8b832f2508f9c57332
parentc7adc7a5b3929956c1960493dfc1c7c5c624af9b (diff)
openpgp: Improve tests.
-rw-r--r--openpgp/src/parse/map.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/openpgp/src/parse/map.rs b/openpgp/src/parse/map.rs
index a1a1c2e1..996f1c09 100644
--- a/openpgp/src/parse/map.rs
+++ b/openpgp/src/parse/map.rs
@@ -177,6 +177,10 @@ impl<'a> Field<'a> {
/// assert_eq!(map.iter().nth(0).unwrap().name(), "CTB");
/// assert_eq!(map.iter().nth(1).unwrap().name(), "length");
/// assert_eq!(map.iter().nth(2).unwrap().name(), "format");
+ /// assert_eq!(map.iter().nth(3).unwrap().name(), "filename_len");
+ /// assert_eq!(map.iter().nth(4).unwrap().name(), "date");
+ /// assert_eq!(map.iter().nth(5).unwrap().name(), "body");
+ /// assert!(map.iter().nth(6).is_none());
/// # Ok(()) }
/// ```
pub fn name(&self) -> &'a str {
@@ -202,6 +206,10 @@ impl<'a> Field<'a> {
/// assert_eq!(map.iter().nth(0).unwrap().offset(), 0);
/// assert_eq!(map.iter().nth(1).unwrap().offset(), 1);
/// assert_eq!(map.iter().nth(2).unwrap().offset(), 2);
+ /// assert_eq!(map.iter().nth(3).unwrap().offset(), 3);
+ /// assert_eq!(map.iter().nth(4).unwrap().offset(), 4);
+ /// assert_eq!(map.iter().nth(5).unwrap().offset(), 8);
+ /// assert!(map.iter().nth(6).is_none());
/// # Ok(()) }
/// ```
pub fn offset(&self) -> usize {
@@ -227,6 +235,12 @@ impl<'a> Field<'a> {
/// assert_eq!(map.iter().nth(0).unwrap().as_bytes(), &[0xcb]);
/// assert_eq!(map.iter().nth(1).unwrap().as_bytes(), &[0x12]);
/// assert_eq!(map.iter().nth(2).unwrap().as_bytes(), "t".as_bytes());
+ /// assert_eq!(map.iter().nth(3).unwrap().as_bytes(), &[0x00]);
+ /// assert_eq!(map.iter().nth(4).unwrap().as_bytes(),
+ /// &[0x00, 0x00, 0x00, 0x00]);
+ /// assert_eq!(map.iter().nth(5).unwrap().as_bytes(),
+ /// "Hello world.".as_bytes());
+ /// assert!(map.iter().nth(6).is_none());
/// # Ok(()) }
/// ```
pub fn as_bytes(&self) -> &'a [u8] {