1use crate::parse;
4
5#[derive(Debug, Default, PartialEq, Clone)]
6pub struct Note {
7 pub note: Option<String>,
9}
10
11impl Note {
12 pub fn parse(mut buffer: &str) -> (&str, Option<Note>) {
13 let mut note = Note { note: None };
14
15 note.note = parse::get_tag_value(&mut buffer).unwrap();
16
17 (buffer, Some(note))
18 }
19}
20
21#[cfg(test)]
22mod tests {
23 use super::Note;
24
25 #[test]
26 fn parse_note() {
27 let data = vec![
35 "1 NOTE This is the first line of a note.",
36 "2 CONT This is the second line of a note.",
37 "2 CONC This is also on the second line.",
38 "2 CONT This line should be the last line.",
39 ];
40
41 let (_, note) = Note::parse(data.join("\n").as_str());
42 let n = note.unwrap().note.unwrap();
43
44 assert!(n.starts_with("This is the first line of a note.\n"));
45 assert!(n.ends_with("the last line."));
46 assert!(n == "This is the first line of a note.\nThis is the second line of a note. This is also on the second line.\nThis line should be the last line.");
47 }
48}