• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ngalaiko / hledger-desktop / 11782383692

11 Nov 2024 04:25PM CUT coverage: 68.111%. Remained the same
11782383692

push

github

ngalaiko
hledger-desktop: offload parsing to rayon

0 of 5 new or added lines in 1 file covered. (0.0%)

20 existing lines in 1 file now uncovered.

786 of 1154 relevant lines covered (68.11%)

2.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.0
/crates/hledger-parser/src/directive/include/format.rs
1
use chumsky::prelude::*;
2

3
use crate::state::State;
4

5
#[derive(Clone, Debug, PartialEq)]
6
pub enum Format {
7
    Journal,
8
    Timeclock,
9
    Timedot,
10
    Csv,
11
    Ssv,
12
    Tsv,
13
    Rules,
14
}
15

16
pub fn format<'a>() -> impl Parser<'a, &'a str, Format, extra::Full<Rich<'a, char>, State, ()>> {
1✔
17
    let journal = just("journal").map(|_| Format::Journal);
3✔
18
    let timeclock = just("timeclock").map(|_| Format::Timeclock);
3✔
19
    let timedot = just("timedot").map(|_| Format::Timedot);
3✔
20
    let comma_sv = just("csv").map(|_| Format::Csv);
3✔
21
    let semicolon_sv = just("ssv").map(|_| Format::Ssv);
3✔
22
    let tab_sv = just("tsv").map(|_| Format::Tsv);
3✔
23
    let rules = just("rules").map(|_| Format::Rules);
3✔
24
    journal
1✔
25
        .or(timeclock)
×
26
        .or(timedot)
×
27
        .or(comma_sv)
×
28
        .or(semicolon_sv)
×
29
        .or(tab_sv)
×
30
        .or(rules)
×
31
}
32

33
#[cfg(test)]
34
mod tests {
35
    use super::*;
36

37
    #[test]
38
    fn ok_journal() {
39
        let result = format().then_ignore(end()).parse("journal").into_result();
40
        assert_eq!(result, Ok(Format::Journal));
41
    }
42

43
    #[test]
44
    fn ok_timeclock() {
45
        let result = format().then_ignore(end()).parse("timeclock").into_result();
46
        assert_eq!(result, Ok(Format::Timeclock));
47
    }
48

49
    #[test]
50
    fn ok_timedot() {
51
        let result = format().then_ignore(end()).parse("timedot").into_result();
52
        assert_eq!(result, Ok(Format::Timedot));
53
    }
54

55
    #[test]
56
    fn ok_csv() {
57
        let result = format().then_ignore(end()).parse("csv").into_result();
58
        assert_eq!(result, Ok(Format::Csv));
59
    }
60

61
    #[test]
62
    fn ok_ssv() {
63
        let result = format().then_ignore(end()).parse("ssv").into_result();
64
        assert_eq!(result, Ok(Format::Ssv));
65
    }
66

67
    #[test]
68
    fn ok_tsv() {
69
        let result = format().then_ignore(end()).parse("tsv").into_result();
70
        assert_eq!(result, Ok(Format::Tsv));
71
    }
72

73
    #[test]
74
    fn ok_rules() {
75
        let result = format().then_ignore(end()).parse("rules").into_result();
76
        assert_eq!(result, Ok(Format::Rules));
77
    }
78

79
    #[test]
80
    fn err() {
81
        let result = format().then_ignore(end()).parse("err").into_result();
82
        assert!(result.is_err());
83
    }
84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc