poreader/
note.rs

1use super::Origin;
2
3/// Note from the translator or the developer
4///
5/// It contains the origin and its value
6#[derive(Clone, PartialEq, Eq, Debug)]
7pub struct Note {
8    origin: Origin,
9    value: String,
10}
11
12impl Note {
13    pub fn new(origin: Origin, value: String) -> Note {
14        Note { origin, value }
15    }
16
17    pub fn origin(&self) -> &Origin {
18        &self.origin
19    }
20
21    pub fn value(&self) -> &str {
22        &self.value
23    }
24}
25
26// no-coverage:start
27#[cfg(test)]
28mod tests {
29    use super::*;
30
31    const VALUE: &str = "message";
32
33    fn make_note() -> Note {
34        Note::new(Origin::Translator, String::from(VALUE))
35    }
36
37    #[test]
38    fn test_struct() {
39        let note = make_note();
40
41        assert_eq!(note.clone(), note);
42        assert_eq!(
43            format!("{:?}", note),
44            format!("Note {{ origin: {:?}, value: {:?} }}", note.origin, note.value),
45        );
46    }
47
48    #[test]
49    fn test_func_origin() {
50        let note = make_note();
51
52        assert_eq!(note.origin(), &Origin::Translator);
53    }
54
55    #[test]
56    fn test_func_value() {
57        let note = make_note();
58
59        assert_eq!(note.value(), VALUE);
60    }
61}
62// no-coverage:stop