Skip to content

Commit

Permalink
Fix typo and add a new test
Browse files Browse the repository at this point in the history
  • Loading branch information
crlf0710 committed Jun 24, 2020
1 parent da19f75 commit c2f0cf6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/mixed_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,13 @@ impl fmt::Display for AugmentedScriptSet {
write!(f, "All")?;
} else {
let mut first_entry = true;
let hanb = if self.hanb { Some("Han with Bopomofo") } else { None };
let hanb = if self.hanb {
Some("Han with Bopomofo")
} else {
None
};
let jpan = if self.jpan { Some("Japanese") } else { None };
let kore = if self.kore { Some("Krorean") } else { None };
let kore = if self.kore { Some("Korean") } else { None };
for writing_system in None
.into_iter()
.chain(hanb)
Expand Down
39 changes: 38 additions & 1 deletion src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn test_potential_mixed_script_detection() {
}

#[test]
fn test_augmented_script_set() {
fn test_augmented_script_set_fmt_debug() {
use crate::mixed_script::AugmentedScriptSet;
let augmented_script_sets = vec![
AugmentedScriptSet::default(),
Expand Down Expand Up @@ -114,3 +114,40 @@ fn test_augmented_script_set() {
assert_eq!(format!("{:?}", ss), output);
}
}

#[test]
fn test_augmented_script_set_fmt_display() {
use crate::mixed_script::AugmentedScriptSet;
let augmented_script_sets = vec![
AugmentedScriptSet::default(),
AugmentedScriptSet::from('0'),
AugmentedScriptSet::from('a'),
AugmentedScriptSet::from('μ'),
AugmentedScriptSet::from('汉'),
AugmentedScriptSet::from('ひ'),
AugmentedScriptSet::from('カ'),
AugmentedScriptSet::from('한'),
AugmentedScriptSet::from("汉ひ"),
AugmentedScriptSet::from("汉a"),
AugmentedScriptSet::from("汉μ"),
AugmentedScriptSet::from("〆切"),
];
let debug_output = vec![
"All",
"All",
"Latin",
"Greek",
"Han with Bopomofo, Japanese, Korean, Han",
"Japanese, Hiragana",
"Japanese, Katakana",
"Korean, Hangul",
"Japanese",
"Empty",
"Empty",
"Han with Bopomofo, Japanese, Korean, Han",
];

for (ss, output) in augmented_script_sets.into_iter().zip(debug_output) {
assert_eq!(format!("{}", ss), output);
}
}

0 comments on commit c2f0cf6

Please sign in to comment.