Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Aug 17, 2024
1 parent 5aa89f5 commit f83b414
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ impl Pdf {
}
}

/// Set the binary marker of the PDF.
/// Set the binary marker in the header of the PDF.
///
/// This can be useful if you want to ensure that your PDF consists of only
/// ASCII characters, as this is not the case by default.
///
/// _Default value_: \x80\x80\x80\x80
pub fn set_binary_marker(&mut self, marker: &[u8; 4]) {
self.chunk.buf[10..14].copy_from_slice(marker);
}
Expand Down Expand Up @@ -490,4 +495,17 @@ mod tests {
w.indirect(Ref::new(6)).primitive(2);
w.finish();
}

#[test]
fn test_binary_marker() {
let mut w = Pdf::new();
w.set_binary_marker(&[b'A', b'B', b'C', b'D']);
test!(
w.finish(),
b"%PDF-1.7\n%ABCD\n",
b"xref\n0 1\n0000000000 65535 f\r",
b"trailer\n<<\n /Size 1\n>>",
b"startxref\n16\n%%EOF",
);
}
}

0 comments on commit f83b414

Please sign in to comment.