Skip to content

Commit

Permalink
Add From<String> tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdyer committed Aug 15, 2024
1 parent ae346f3 commit aabb38d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/common/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,32 @@ fn models_to_string(models: &[Model]) -> String {
.join(":")
}

#[cfg(test)]
mod from_string_tests {
use super::{Language, Model, Redact};

#[test]
fn model_from_string() {
assert_eq!(Model::from("nova-2".to_string()), Model::Nova2);
assert_eq!(Model::from("custom".to_string()), Model::CustomId("custom".to_string()));
assert_eq!(Model::from("".to_string()), Model::CustomId("".to_string()));
}

#[test]
fn language_from_string() {
assert_eq!(Language::from("zh-Hant".to_string()), Language::zh_Hant);
assert_eq!(Language::from("custom".to_string()), Language::Other("custom".to_string()));
assert_eq!(Language::from("".to_string()), Language::Other("".to_string()));
}

#[test]
fn redact_from_string() {
assert_eq!(Redact::from("pci".to_string()), Redact::Pci);
assert_eq!(Redact::from("custom".to_string()), Redact::Other("custom".to_string()));
assert_eq!(Redact::from("".to_string()), Redact::Other("".to_string()));
}

}
#[cfg(test)]
mod models_to_string_tests {
use super::*;
Expand Down

0 comments on commit aabb38d

Please sign in to comment.