diff --git a/components/datetime/Cargo.toml b/components/datetime/Cargo.toml index bdaa31352e1..de3d32122e9 100644 --- a/components/datetime/Cargo.toml +++ b/components/datetime/Cargo.toml @@ -21,7 +21,7 @@ icu-data-provider = { path = "../data-provider" } [dev-dependencies] criterion = "0.3" icu-data-provider = { path = "../data-provider", features = ["invariant"] } -icu-fs-data-provider = { path = "../fs-data-provider" } +icu-testdata = { path = "../../resources/testdata" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/components/datetime/benches/datetime.rs b/components/datetime/benches/datetime.rs index f006d92293b..1915035cec7 100644 --- a/components/datetime/benches/datetime.rs +++ b/components/datetime/benches/datetime.rs @@ -5,13 +5,11 @@ use std::fmt::Write; use icu_datetime::DateTimeFormat; use icu_datetime::MockDateTime; -use icu_fs_data_provider::FsDataProvider; fn datetime_benches(c: &mut Criterion) { let fxs = fixtures::get_fixture("styles").unwrap(); - let provider = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); { let mut group = c.benchmark_group("datetime"); diff --git a/components/datetime/examples/work_log.rs b/components/datetime/examples/work_log.rs index 45f75c4ff0a..4e81314ba54 100644 --- a/components/datetime/examples/work_log.rs +++ b/components/datetime/examples/work_log.rs @@ -2,7 +2,6 @@ // from a work log into human readable dates and times. use icu_datetime::date::MockDateTime; use icu_datetime::{options::style, DateTimeFormat}; -use icu_fs_data_provider::FsDataProvider; use icu_locale::LanguageIdentifier; const DATES_ISO: &[&str] = &[ @@ -30,8 +29,7 @@ fn print(_input: &str, _value: Option) { fn main() { let langid: LanguageIdentifier = "en".parse().expect("Failed to parse Language Identifier."); - let provider = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); let dates = DATES_ISO .iter() diff --git a/components/datetime/tests/datetime.rs b/components/datetime/tests/datetime.rs index 75888a953ab..0725e1c055b 100644 --- a/components/datetime/tests/datetime.rs +++ b/components/datetime/tests/datetime.rs @@ -2,13 +2,11 @@ mod fixtures; use icu_datetime::DateTimeFormat; use icu_datetime::MockDateTime; -use icu_fs_data_provider::FsDataProvider; use std::fmt::Write; #[test] fn test_fixtures() { - let provider = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); for fx in fixtures::get_fixture("styles").unwrap().0 { let langid = fx.input.locale.parse().unwrap(); diff --git a/components/pluralrules/Cargo.toml b/components/pluralrules/Cargo.toml index 54d9479a613..93e22ae8501 100644 --- a/components/pluralrules/Cargo.toml +++ b/components/pluralrules/Cargo.toml @@ -25,7 +25,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = {version = "1.0" } icu-locale = { path = "../locale", features = ["serde"] } icu-data-provider = { path = "../data-provider", features = ["invariant"] } -icu-fs-data-provider = { path = "../fs-data-provider" } +icu-testdata = { path = "../../resources/testdata" } [features] default = [] diff --git a/components/pluralrules/benches/fixtures/plurals.json b/components/pluralrules/benches/fixtures/plurals.json index 1386332f6b3..3673f4283fe 100644 --- a/components/pluralrules/benches/fixtures/plurals.json +++ b/components/pluralrules/benches/fixtures/plurals.json @@ -1,3 +1,3 @@ { - "langs": ["be", "bn", "en", "fa", "fr", "und", "zh"] + "langs": ["ar", "be", "bn", "en", "es", "fr", "ja", "sr", "th", "tr"] } diff --git a/components/pluralrules/benches/parser.rs b/components/pluralrules/benches/parser.rs index 6225cde8f9c..0ed9a02e949 100644 --- a/components/pluralrules/benches/parser.rs +++ b/components/pluralrules/benches/parser.rs @@ -4,7 +4,6 @@ mod helpers; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use icu_data_provider::{icu_data_key, structs, DataEntry, DataProvider, DataRequest}; -use icu_fs_data_provider::FsDataProvider; use std::borrow::Cow; fn parser(c: &mut Criterion) { @@ -12,8 +11,7 @@ fn parser(c: &mut Criterion) { let plurals_data = helpers::get_plurals_data(); - let provider = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); let mut rules = vec![]; diff --git a/components/pluralrules/benches/pluralrules.rs b/components/pluralrules/benches/pluralrules.rs index dbc14e9e3c6..e85ed2b790f 100644 --- a/components/pluralrules/benches/pluralrules.rs +++ b/components/pluralrules/benches/pluralrules.rs @@ -3,15 +3,13 @@ mod helpers; use criterion::{criterion_group, criterion_main, Criterion}; -use icu_fs_data_provider::FsDataProvider; use icu_pluralrules::{PluralRuleType, PluralRules}; fn pluralrules(c: &mut Criterion) { let plurals_data = helpers::get_plurals_data(); let numbers_data = helpers::get_numbers_data(); - let provider = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); c.bench_function("pluralrules/overview", |b| { b.iter(|| { diff --git a/components/pluralrules/examples/elevator_floors.rs b/components/pluralrules/examples/elevator_floors.rs index 4ce5a91bcb2..a9cf340a4ca 100644 --- a/components/pluralrules/examples/elevator_floors.rs +++ b/components/pluralrules/examples/elevator_floors.rs @@ -1,6 +1,5 @@ // An example application which uses icu_pluralrules to construct a correct // sentence for English based on the numerical value in Ordinal category. -use icu_fs_data_provider::FsDataProvider; use icu_locale::LanguageIdentifier; use icu_pluralrules::{PluralCategory, PluralRuleType, PluralRules}; @@ -17,12 +16,12 @@ fn print(_input: &str, _value: Option) { fn main() { let langid: LanguageIdentifier = "en".parse().expect("Failed to parse Language Identifier."); - let dtp = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + + let provider = icu_testdata::get_provider(); { print("\n====== Elevator Floor (en) example ============", None); - let pr = PluralRules::try_new(langid, &dtp, PluralRuleType::Ordinal) + let pr = PluralRules::try_new(langid, &provider, PluralRuleType::Ordinal) .expect("Failed to create a PluralRules instance."); for value in VALUES { diff --git a/components/pluralrules/examples/unread_emails.rs b/components/pluralrules/examples/unread_emails.rs index 42cb6724a92..e048aab4a27 100644 --- a/components/pluralrules/examples/unread_emails.rs +++ b/components/pluralrules/examples/unread_emails.rs @@ -1,6 +1,5 @@ // An example application which uses icu_pluralrules to construct a correct // sentence for English based on the numerical value in Cardinal category. -use icu_fs_data_provider::FsDataProvider; use icu_locale::LanguageIdentifier; use icu_pluralrules::{PluralCategory, PluralRuleType, PluralRules}; @@ -17,12 +16,11 @@ fn print(_input: &str, _value: Option) { fn main() { let langid: LanguageIdentifier = "en".parse().expect("Failed to parse Language Identifier."); - let dtp = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); { print("\n====== Unread Emails (en) example ============", None); - let pr = PluralRules::try_new(langid, &dtp, PluralRuleType::Cardinal) + let pr = PluralRules::try_new(langid, &provider, PluralRuleType::Cardinal) .expect("Failed to create a PluralRules instance."); for value in VALUES { diff --git a/components/pluralrules/tests/plurals.rs b/components/pluralrules/tests/plurals.rs index 750dc4b8f1d..4be5ad0f424 100644 --- a/components/pluralrules/tests/plurals.rs +++ b/components/pluralrules/tests/plurals.rs @@ -1,27 +1,24 @@ -use icu_fs_data_provider::FsDataProvider; use icu_locale::LanguageIdentifier; use icu_pluralrules::{PluralCategory, PluralRuleType, PluralRules}; #[test] fn test_plural_rules() { - let dp = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); let lang: LanguageIdentifier = "en".parse().unwrap(); - let pr = PluralRules::try_new(lang, &dp, PluralRuleType::Cardinal).unwrap(); + let pr = PluralRules::try_new(lang, &provider, PluralRuleType::Cardinal).unwrap(); assert_eq!(pr.select(5_usize), PluralCategory::Other); } #[test] fn test_plural_rules_missing() { - let dp = FsDataProvider::try_new("../../resources/testdata/data/json") - .expect("Loading file from testdata directory"); + let provider = icu_testdata::get_provider(); let lang: LanguageIdentifier = "xx".parse().unwrap(); - let pr = PluralRules::try_new(lang, &dp, PluralRuleType::Cardinal); + let pr = PluralRules::try_new(lang, &provider, PluralRuleType::Cardinal); assert!(pr.is_err()); }