|
1 | | -use crate::char_struct::{CharType, KoreanChar}; |
| 1 | +use crate::char_struct::{CharType, KoreanChar}; |
2 | 2 | use crate::english_logic; |
3 | 3 | use crate::fraction; |
4 | 4 | use crate::rules::context::{EncoderState, RuleContext}; |
@@ -2128,3 +2128,47 @@ mod tests { |
2128 | 2128 | ); |
2129 | 2129 | } |
2130 | 2130 | } |
| 2131 | + |
| 2132 | +#[cfg(test)] |
| 2133 | +mod spaced_colon_coverage { |
| 2134 | + use super::*; |
| 2135 | + use crate::rules::token::{SpaceKind, WordMeta}; |
| 2136 | + |
| 2137 | + fn word(text: &str) -> Token<'static> { |
| 2138 | + let chars: Vec<char> = text.chars().collect(); |
| 2139 | + Token::Word(WordToken { |
| 2140 | + text: std::borrow::Cow::Owned(text.to_string()), |
| 2141 | + meta: WordMeta::from_chars(&chars), |
| 2142 | + chars, |
| 2143 | + }) |
| 2144 | + } |
| 2145 | + |
| 2146 | + /// 제29항·제32항·제35항: a standalone colon joins two Roman items only when |
| 2147 | + /// the item after it is proved Roman. |
| 2148 | + #[test] |
| 2149 | + fn a_roman_item_after_the_colon_connects_the_section() { |
| 2150 | + let tokens = [word(":"), Token::Space(SpaceKind::Regular), word("Beta")]; |
| 2151 | + assert!(spaced_colon_connects_roman_items(&tokens, 0)); |
| 2152 | + } |
| 2153 | + |
| 2154 | + #[test] |
| 2155 | + fn a_korean_item_after_the_colon_breaks_the_section() { |
| 2156 | + let tokens = [word(":"), Token::Space(SpaceKind::Regular), word("베타")]; |
| 2157 | + assert!(!spaced_colon_connects_roman_items(&tokens, 0)); |
| 2158 | + } |
| 2159 | + |
| 2160 | + #[test] |
| 2161 | + fn a_pre_encoded_item_after_the_colon_breaks_the_section() { |
| 2162 | + let tokens = [word(":"), Token::PreEncoded(vec![1])]; |
| 2163 | + assert!(!spaced_colon_connects_roman_items(&tokens, 0)); |
| 2164 | + } |
| 2165 | + |
| 2166 | + #[test] |
| 2167 | + fn a_token_that_is_not_a_lone_colon_never_connects() { |
| 2168 | + assert!(!spaced_colon_connects_roman_items(&[word("::")], 0)); |
| 2169 | + assert!(!spaced_colon_connects_roman_items( |
| 2170 | + &[Token::PreEncoded(vec![1])], |
| 2171 | + 0 |
| 2172 | + )); |
| 2173 | + } |
| 2174 | +} |
0 commit comments