Skip to content

Commit

Permalink
Invert logic when E5/G5 (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
femshima authored Mar 2, 2024
1 parent 4fd0faa commit 4293422
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions crates/jlabel-question/src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,11 @@ impl Position for BooleanPosition {

fn range(&self, ranges: &[&str]) -> Result<Self::Range, ParseError> {
let first = ranges.first().ok_or(ParseError::Empty)?;
// E5/G5's logics are inverted
let field_false = matches!(self, Self::E5 | Self::G5);
match *first {
"0" => Ok(false),
"1" => Ok(true),
"0" => Ok(field_false),
"1" => Ok(!field_false),
_ => Err(ParseError::InvalidBoolean(first.to_string())),
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/jlabel-question/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use jlabel::{
AccentPhraseCurrent, AccentPhrasePrevNext, BreathGroupCurrent, BreathGroupPrevNext, Label,
Mora, Phoneme, Utterance, Word,
AccentPhraseCurrent, AccentPhrasePrevNext, BreathGroupCurrent, BreathGroupPrevNext, Mora,
Phoneme, Utterance, Word,
};

#[test]
Expand Down

0 comments on commit 4293422

Please sign in to comment.