Skip to content

Commit

Permalink
Clean up extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
omarmhaimdat committed Jan 5, 2024
1 parent 086243c commit f6b38d7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use whatlang::{detect, detect_lang, detect_script};

use crate::utils::{colorize, get_progress_bar, lang_to_iso639_1, TermColor};

mod extensions;
mod tests;
mod utils;

Expand Down
24 changes: 0 additions & 24 deletions src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#[cfg(test)]
mod tests {
use crate::extensions::detect_multiple_languages;
use serde_json::to_string_pretty;
use whatlang::{detect, Lang, Script};
#[test]
fn test_detect() {
Expand All @@ -23,26 +21,4 @@ mod tests {
let info = detect(text).unwrap();
assert_eq!(info.is_reliable(), false);
}

#[test]
fn test_detect_multiple_languages() {
let text = "Parlez-vous français? Ich spreche Französisch nur ein bisschen. A little bit is better than nothing.";
let languages = detect_multiple_languages(text).unwrap();
// println!("{:?}", languages);
let langs = languages.iter().map(|l| l.to_hashmap()).collect::<Vec<_>>();
// Save languages to a json file
println!("{:?}", langs);
let json = to_string_pretty(&langs).unwrap();
std::fs::write("languages.json", json).unwrap();
assert_eq!(languages.len(), 3);
assert_eq!(languages[0].text, "Parlez-vous français?");
assert_eq!(languages[0].languages[0], Lang::Fra);
assert_eq!(
languages[1].text,
"Ich spreche Französisch nur ein bisschen."
);
assert_eq!(languages[1].languages[0], Lang::Deu);
assert_eq!(languages[2].text, "A little bit is better than nothing.");
assert_eq!(languages[2].languages[0], Lang::Eng);
}
}

0 comments on commit f6b38d7

Please sign in to comment.