Skip to content

Commit 451986d

Browse files
author
Zibi Braniecki
committed
Fix tests
1 parent 8b4efcf commit 451986d

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ coveralls = { repository = "projectfluent/fluent-locale-rs", branch = "master",
1919
maintenance = { status = "actively-developed" }
2020

2121
[dependencies]
22-
unic-locale = { path = "../unic-locale" }
22+
unic-locale = { path = "../../unic-locale/unic-locale" }
2323

2424
[dev-dependencies]
2525
serde = "1.0"

tests/lib.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::collections::BTreeMap;
1+
use std::collections::HashMap;
22
use std::error::Error;
33
use std::fs;
44
use std::fs::File;
55
use std::path::Path;
66

7-
use unic_locale::Locale;
7+
use unic_locale::{Locale, ExtensionType};
88
use fluent_locale::negotiate::negotiate_languages;
99
use fluent_locale::negotiate::NegotiationStrategy;
1010
use fluent_locale::parse_accepted_languages;
@@ -15,7 +15,7 @@ extern crate serde_derive;
1515
#[derive(Serialize, Deserialize)]
1616
struct LocaleTestInputData {
1717
string: String,
18-
options: Option<BTreeMap<String, String>>,
18+
options: Option<HashMap<String, String>>,
1919
}
2020

2121
#[derive(Serialize, Deserialize, Debug)]
@@ -24,7 +24,7 @@ struct LocaleTestOutputObject {
2424
script: Option<String>,
2525
region: Option<String>,
2626
variants: Option<Vec<String>>,
27-
extensions: Option<BTreeMap<String, BTreeMap<String, String>>>,
27+
extensions: Option<HashMap<String, HashMap<String, String>>>,
2828
}
2929

3030
#[derive(Serialize, Deserialize, Debug)]
@@ -80,7 +80,7 @@ fn test_locale_fixtures(path: &str) {
8080

8181
let loc;
8282
if let Some(opts) = test.input.options {
83-
let borrowed: BTreeMap<&str, &str> =
83+
let borrowed: HashMap<&str, &str> =
8484
opts.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();
8585
loc = Locale::from_str_with_options(&s, borrowed).unwrap();
8686
} else {
@@ -101,12 +101,16 @@ fn test_locale_fixtures(path: &str) {
101101
}
102102
if let Some(variants) = o.variants {
103103
ref_locale.set_variants(
104-
&variants.iter().map(String::as_str).collect::<Vec<&str>>());
104+
&variants.iter().map(String::as_str).collect::<Vec<&str>>()).unwrap();
105105
}
106106
if let Some(extensions) = o.extensions {
107107
for (ext_name, values) in extensions {
108+
let ext = match ext_name.as_str() {
109+
"unicode" => ExtensionType::Unicode,
110+
_ => unimplemented!()
111+
};
108112
for (key, val) in values {
109-
ref_locale.set_extension(&ext_name, &key, &val);
113+
ref_locale.set_extension(ext, &key, &val).unwrap();
110114
}
111115
}
112116
}
@@ -231,6 +235,6 @@ fn test_locale_parsing_error() {
231235
assert_eq!(loc.is_err(), true);
232236

233237
if let Err(err) = loc {
234-
assert_eq!(format!("{}", err), "The given language subtag is invalid");
238+
assert_eq!(format!("{}", err), "Language Identifier Parser Error");
235239
}
236240
}

0 commit comments

Comments
 (0)