icu_testdata crates.io

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: * [unstable], [unstable_no_fallback] * [any], [any_no_fallback] * [buffer], [buffer_no_fallback] (buffer feature)

Additionally, the metadata feature exposes the [metadata] module which contains information such as the CLDR Gitref and the list of included locales.

bin feature

Downloading fresh CLDR data

bash $ cargo run --bin --features=bin icu4x-testdata-download-sources

Regenerating data

bash $ cargo run --bin --features=bin icu4x-testdata-datagen

Examples

```rust use icu::locid::locale; use icuprovider::helloworld::; use icu_provider::prelude::;

let req = DataRequest { locale: &locale!("en").into(), metadata: Default::default(), };

asserteq!( DataProvider::::load( &icutestdata::unstable(), req ) .andthen(DataResponse::takepayload) .unwrap() .get() .message, "Hello World" );

asserteq!( BufferProvider::loadbuffer( &icutestdata::buffer(), HelloWorldV1Marker::KEY, req ) .andthen(DataResponse::take_payload) .unwrap() .get(), &b"\x0bHello World" );

asserteq!( AnyProvider::loadany( &icutestdata::any(), HelloWorldV1Marker::KEY, req ) .andthen(AnyResponse::downcast::) .andthen(DataResponse::takepayload) .unwrap() .get() .message, "Hello World" ); ```

More Information

For more information on development, authorship, contributing etc. please visit ICU4X home page.