1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use super::Origin;

/// Note from the translator or the developer
///
/// It contains the origin and its value
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct Note {
    origin: Origin,
    value: String,
}

impl Note {
    pub fn new(origin: Origin, value: String) -> Note {
        Note { origin, value }
    }

    pub fn origin(&self) -> &Origin {
        &self.origin
    }

    pub fn value(&self) -> &str {
        &self.value
    }
}

// no-coverage:start
#[cfg(test)]
mod tests {
    use super::*;

    const VALUE: &str = "message";

    fn make_note() -> Note {
        Note::new(Origin::Translator, String::from(VALUE))
    }

    #[test]
    fn test_struct() {
        let note = make_note();

        assert_eq!(note.clone(), note);
        assert_eq!(
            format!("{:?}", note),
            format!("Note {{ origin: {:?}, value: {:?} }}", note.origin, note.value),
        );
    }

    #[test]
    fn test_func_origin() {
        let note = make_note();

        assert_eq!(note.origin(), &Origin::Translator);
    }

    #[test]
    fn test_func_value() {
        let note = make_note();

        assert_eq!(note.value(), VALUE);
    }
}
// no-coverage:stop