Skip to content

Commit

Permalink
Fix WASM integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pemistahl committed Oct 27, 2023
1 parent 5928d06 commit 4f23ff0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
19 changes: 14 additions & 5 deletions tests/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,20 +318,28 @@ fn test_compute_language_confidence_values() {
)
.unwrap();

let rounded_confidence_values = confidence_values
.iter()
.map(|value| ConfidenceValue {
language: value.language.clone(),
confidence: (value.confidence * 100000.0).round() / 100000.0,
})
.collect::<Vec<_>>();

assert_eq!(
confidence_values,
rounded_confidence_values,
vec![
ConfidenceValue {
language: Language::German.to_string(),
confidence: 0.9697974735292365
confidence: 0.9698
},
ConfidenceValue {
language: Language::French.to_string(),
confidence: 0.015343577281546793
confidence: 0.01534
},
ConfidenceValue {
language: Language::English.to_string(),
confidence: 0.014858949189216833
confidence: 0.01486
}
]
);
Expand All @@ -350,7 +358,8 @@ fn test_compute_language_confidence() {
let confidence = detector
.computeLanguageConfidence("mein Haus ist groß", &Language::German.to_string())
.unwrap();
assert_eq!(confidence, 0.9697974735292365);
let rounded_confidence = (confidence * 100000.0).round() / 100000.0;
assert_eq!(rounded_confidence, 0.9698);

let result = detector.computeLanguageConfidence("mein Haus ist groß", "Sorbian");
assert_eq!(
Expand Down
19 changes: 14 additions & 5 deletions tests/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,20 +320,28 @@ fn test_compute_language_confidence_values() {
)
.unwrap();

let rounded_confidence_values = confidence_values
.iter()
.map(|value| ConfidenceValue {
language: value.language.clone(),
confidence: (value.confidence * 100000.0).round() / 100000.0,
})
.collect::<Vec<_>>();

assert_eq!(
confidence_values,
rounded_confidence_values,
vec![
ConfidenceValue {
language: Language::German.to_string(),
confidence: 0.9697974735292365
confidence: 0.9698
},
ConfidenceValue {
language: Language::French.to_string(),
confidence: 0.015343577281546793
confidence: 0.01534
},
ConfidenceValue {
language: Language::English.to_string(),
confidence: 0.014858949189216833
confidence: 0.01486
}
]
);
Expand All @@ -352,7 +360,8 @@ fn test_compute_language_confidence() {
let confidence = detector
.computeLanguageConfidence("mein Haus ist groß", &Language::German.to_string())
.unwrap();
assert_eq!(confidence, 0.9697974735292365);
let rounded_confidence = (confidence * 100000.0).round() / 100000.0;
assert_eq!(rounded_confidence, 0.9698);

let result = detector.computeLanguageConfidence("mein Haus ist groß", "Sorbian");
assert_eq!(
Expand Down

0 comments on commit 4f23ff0

Please sign in to comment.