Skip to content

Commit c2f0cf6

Browse files
committed
Fix typo and add a new test
1 parent da19f75 commit c2f0cf6

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

src/mixed_script.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,13 @@ impl fmt::Display for AugmentedScriptSet {
113113
write!(f, "All")?;
114114
} else {
115115
let mut first_entry = true;
116-
let hanb = if self.hanb { Some("Han with Bopomofo") } else { None };
116+
let hanb = if self.hanb {
117+
Some("Han with Bopomofo")
118+
} else {
119+
None
120+
};
117121
let jpan = if self.jpan { Some("Japanese") } else { None };
118-
let kore = if self.kore { Some("Krorean") } else { None };
122+
let kore = if self.kore { Some("Korean") } else { None };
119123
for writing_system in None
120124
.into_iter()
121125
.chain(hanb)

src/tests.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn test_potential_mixed_script_detection() {
7979
}
8080

8181
#[test]
82-
fn test_augmented_script_set() {
82+
fn test_augmented_script_set_fmt_debug() {
8383
use crate::mixed_script::AugmentedScriptSet;
8484
let augmented_script_sets = vec![
8585
AugmentedScriptSet::default(),
@@ -114,3 +114,40 @@ fn test_augmented_script_set() {
114114
assert_eq!(format!("{:?}", ss), output);
115115
}
116116
}
117+
118+
#[test]
119+
fn test_augmented_script_set_fmt_display() {
120+
use crate::mixed_script::AugmentedScriptSet;
121+
let augmented_script_sets = vec![
122+
AugmentedScriptSet::default(),
123+
AugmentedScriptSet::from('0'),
124+
AugmentedScriptSet::from('a'),
125+
AugmentedScriptSet::from('μ'),
126+
AugmentedScriptSet::from('汉'),
127+
AugmentedScriptSet::from('ひ'),
128+
AugmentedScriptSet::from('カ'),
129+
AugmentedScriptSet::from('한'),
130+
AugmentedScriptSet::from("汉ひ"),
131+
AugmentedScriptSet::from("汉a"),
132+
AugmentedScriptSet::from("汉μ"),
133+
AugmentedScriptSet::from("〆切"),
134+
];
135+
let debug_output = vec![
136+
"All",
137+
"All",
138+
"Latin",
139+
"Greek",
140+
"Han with Bopomofo, Japanese, Korean, Han",
141+
"Japanese, Hiragana",
142+
"Japanese, Katakana",
143+
"Korean, Hangul",
144+
"Japanese",
145+
"Empty",
146+
"Empty",
147+
"Han with Bopomofo, Japanese, Korean, Han",
148+
];
149+
150+
for (ss, output) in augmented_script_sets.into_iter().zip(debug_output) {
151+
assert_eq!(format!("{}", ss), output);
152+
}
153+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy