Skip to content

Commit

Permalink
test(lib): add tests for parsing implementations for DnoteBook & Dnot…
Browse files Browse the repository at this point in the history
…ePage
  • Loading branch information
deepanchal committed Jul 8, 2023
1 parent 554f602 commit c578273
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/dnote_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,24 @@ impl FromStr for DnotePage {
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn should_parse_dnotebook_from_string() {
let s = String::from("my notebook");
let book: DnoteBook = s.parse().unwrap();
assert_eq!(book.name, "my notebook")
}

#[test]
fn should_parse_dnotepage_from_string() {
let input1 = "(21) # Issues [---More---]";
let input2 = " (27) # Missed [---More---]";
let page1: DnotePage = input1.parse().unwrap();
let page2: DnotePage = input2.parse().unwrap();
assert_eq!(page1.id, 21);
assert_eq!(page2.id, 27);
}
}

0 comments on commit c578273

Please sign in to comment.