From 4293422a79c2eb85b980d7109354f842b83346ce Mon Sep 17 00:00:00 2001 From: phenylshima <49227365+femshima@users.noreply.github.com> Date: Sat, 2 Mar 2024 12:40:35 +0900 Subject: [PATCH] Invert logic when E5/G5 (#26) --- crates/jlabel-question/src/position.rs | 6 ++++-- crates/jlabel-question/src/tests.rs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/jlabel-question/src/position.rs b/crates/jlabel-question/src/position.rs index 330d7dc..0042fd3 100644 --- a/crates/jlabel-question/src/position.rs +++ b/crates/jlabel-question/src/position.rs @@ -273,9 +273,11 @@ impl Position for BooleanPosition { fn range(&self, ranges: &[&str]) -> Result { 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())), } } diff --git a/crates/jlabel-question/src/tests.rs b/crates/jlabel-question/src/tests.rs index 64bc712..1dd382c 100644 --- a/crates/jlabel-question/src/tests.rs +++ b/crates/jlabel-question/src/tests.rs @@ -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]