From 09b3c60de001b7cced23fd4a5bb5cd73a6e23540 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Thu, 26 Apr 2018 18:56:06 +0200 Subject: [PATCH] add header creation methods (#2) --- src/lib.rs | 15 +++++++++++++++ tests/fns.rs | 18 ++++++++++++++++++ tests/header.rs | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/fns.rs diff --git a/src/lib.rs b/src/lib.rs index edf0206..7f75cdf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,3 +9,18 @@ extern crate failure; mod header; pub use header::*; + +/// Create a new `Header` in the `Bitfield` configuration. +pub fn create_bitfield() -> Header { + Header::new(FileType::BitField, 3328, HashType::None) +} + +/// Create a new `Header` in the `Signatures` configuration. +pub fn create_signatures() -> Header { + Header::new(FileType::Signatures, 64, HashType::Ed25519) +} + +/// Create a new `Header` in the `Tree` configuration. +pub fn create_tree() -> Header { + Header::new(FileType::Tree, 40, HashType::BLAKE2b) +} diff --git a/tests/fns.rs b/tests/fns.rs new file mode 100644 index 0000000..a9bb59f --- /dev/null +++ b/tests/fns.rs @@ -0,0 +1,18 @@ +extern crate sleep_parser; + +use sleep_parser::*; + +#[test] +fn bitfield() { + assert!(create_bitfield().is_bitfield()); +} + +#[test] +fn signatures() { + assert!(create_signatures().is_signatures()); +} + +#[test] +fn tree() { + assert!(create_tree().is_tree()); +} diff --git a/tests/header.rs b/tests/header.rs index c0f9e14..8100814 100644 --- a/tests/header.rs +++ b/tests/header.rs @@ -1,6 +1,6 @@ extern crate sleep_parser; -use sleep_parser::{FileType, HashType, Header}; +use sleep_parser::*; use std::fs::File; use std::io::{BufRead, BufReader};