Crate icu_testdata

Source
👎Deprecated since 1.3.0: this crate has been superseded by ICU4X’s compiled_data feature. Data for new components will not be added, and it will not be updated for ICU4X 2.0.
Expand description

icu_testdata is a unit testing crate for ICU4X.

The crate exposes data providers with stable data useful for unit testing. The data is based on a CLDR tag and a short list of locales that, together, cover a range of scenarios.

The crate exposes three kinds of providers, corresponding to the three types of constructors in ICU:

§Examples

use icu::locid::locale;
use icu_provider::hello_world::HelloWorldFormatter;

// Unstable constructor
HelloWorldFormatter::try_new_unstable(
    &icu_testdata::unstable(),
    &locale!("en-CH").into(),
).unwrap();

// AnyProvider constructor
HelloWorldFormatter::try_new_with_any_provider(
    &icu_testdata::any(),
    &locale!("en-CH").into(),
).unwrap();

// BufferProvider constructor (`icu` with `serde` feature, `icu_testdata` with `buffer` feature)
HelloWorldFormatter::try_new_with_buffer_provider(
    &icu_testdata::buffer(),
    &locale!("en-CH").into(),
).unwrap();

// Without fallback the locale match needs to be exact
HelloWorldFormatter::try_new_unstable(
    &icu_testdata::unstable_no_fallback(),
    &locale!("en-CH").into(),
).is_err();

HelloWorldFormatter::try_new_unstable(
    &icu_testdata::unstable_no_fallback(),
    &locale!("en").into(),
).unwrap();

Modules§

pathsDeprecated
Get paths to the test data directories. Some of these paths do not exist anymore, and data should only be accessed through the functions provided by this crate.
versionsDeprecated
Functions to access version info of the ICU test data.

Functions§

anyDeprecated
An AnyProvider backed by baked data.
any_no_fallbackDeprecated
An AnyProvider backed by baked data.
bufferDeprecated
A BufferProvider backed by a Postcard blob.
buffer_no_fallbackDeprecated
A BufferProvider backed by a Postcard blob.
localesDeprecated
Gets the locales supported by the test data.
unstableDeprecated
A data provider that is compatible with all ICU _unstable constructors.
unstable_no_fallbackDeprecated
A data provider that is compatible with all ICU _unstable constructors.