mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-06-16 09:28:03 +00:00
style(milli): linting
This commit is contained in:
parent
ab3d92d163
commit
263300b3a3
@ -386,51 +386,56 @@ mod tests {
|
|||||||
let temp_index = temp_index_with_documents();
|
let temp_index = temp_index_with_documents();
|
||||||
let rtxn = temp_index.read_txn()?;
|
let rtxn = temp_index.read_txn()?;
|
||||||
let ctx = SearchContext::new(&temp_index, &rtxn)?;
|
let ctx = SearchContext::new(&temp_index, &rtxn)?;
|
||||||
|
|
||||||
let nbr_typos = number_of_typos_allowed(&ctx)?;
|
let nbr_typos = number_of_typos_allowed(&ctx)?;
|
||||||
|
|
||||||
// ASCII word "doggy" (5 chars, 5 bytes)
|
// ASCII word "doggy" (5 chars, 5 bytes)
|
||||||
let ascii_word = "doggy";
|
let ascii_word = "doggy";
|
||||||
let ascii_typos = nbr_typos(ascii_word);
|
let ascii_typos = nbr_typos(ascii_word);
|
||||||
|
|
||||||
// Cyrillic word "собак" (5 chars, 10 bytes)
|
// Cyrillic word "собак" (5 chars, 10 bytes)
|
||||||
let cyrillic_word = "собак";
|
let cyrillic_word = "собак";
|
||||||
let cyrillic_typos = nbr_typos(cyrillic_word);
|
let cyrillic_typos = nbr_typos(cyrillic_word);
|
||||||
|
|
||||||
// Both words have 5 characters, so they should have the same typo tolerance
|
// Both words have 5 characters, so they should have the same typo tolerance
|
||||||
assert_eq!(ascii_typos, cyrillic_typos,
|
assert_eq!(
|
||||||
"Words with same character count should get same typo tolerance");
|
ascii_typos, cyrillic_typos,
|
||||||
|
"Words with same character count should get same typo tolerance"
|
||||||
|
);
|
||||||
|
|
||||||
// With default settings (oneTypo=5, twoTypos=9), 5-char words should get 1 typo
|
// With default settings (oneTypo=5, twoTypos=9), 5-char words should get 1 typo
|
||||||
assert_eq!(ascii_typos, 1, "5-character word should get 1 typo tolerance");
|
assert_eq!(ascii_typos, 1, "5-character word should get 1 typo tolerance");
|
||||||
assert_eq!(cyrillic_typos, 1, "5-character word should get 1 typo tolerance");
|
assert_eq!(cyrillic_typos, 1, "5-character word should get 1 typo tolerance");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_various_unicode_scripts() -> Result<()> {
|
fn test_various_unicode_scripts() -> Result<()> {
|
||||||
let temp_index = temp_index_with_documents();
|
let temp_index = temp_index_with_documents();
|
||||||
let rtxn = temp_index.read_txn()?;
|
let rtxn = temp_index.read_txn()?;
|
||||||
let ctx = SearchContext::new(&temp_index, &rtxn)?;
|
let ctx = SearchContext::new(&temp_index, &rtxn)?;
|
||||||
|
|
||||||
let nbr_typos = number_of_typos_allowed(&ctx)?;
|
let nbr_typos = number_of_typos_allowed(&ctx)?;
|
||||||
|
|
||||||
// Let's use 5-character words for consistent testing
|
// Let's use 5-character words for consistent testing
|
||||||
let five_char_words = vec![
|
let five_char_words = vec![
|
||||||
("doggy", "ASCII"), // 5 chars, 5 bytes
|
("doggy", "ASCII"), // 5 chars, 5 bytes
|
||||||
("café!", "Accented"), // 5 chars, 7 bytes
|
("café!", "Accented"), // 5 chars, 7 bytes
|
||||||
("собак", "Cyrillic"), // 5 chars, 10 bytes
|
("собак", "Cyrillic"), // 5 chars, 10 bytes
|
||||||
];
|
];
|
||||||
|
|
||||||
let expected_typos = 1; // With default settings, 5-char words get 1 typo
|
let expected_typos = 1; // With default settings, 5-char words get 1 typo
|
||||||
|
|
||||||
for (word, script) in five_char_words {
|
for (word, script) in five_char_words {
|
||||||
let typos = nbr_typos(word);
|
let typos = nbr_typos(word);
|
||||||
assert_eq!(typos, expected_typos,
|
assert_eq!(
|
||||||
"{} word '{}' should get {} typo(s)", script, word, expected_typos);
|
typos, expected_typos,
|
||||||
|
"{} word '{}' should get {} typo(s)",
|
||||||
|
script, word, expected_typos
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user