Skip to content

Commit

Permalink
Update --keys-for-bin test (#3718)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian authored Jul 21, 2023
1 parent 50b95d7 commit 5f40b1d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
1 change: 0 additions & 1 deletion docs/tutorials/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 7 additions & 9 deletions docs/tutorials/crates/buffer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
//! This is a demo project using blob data.
//!
//! This project requires a postcard data file. To generate it, please run:
//!
//!
//! ```sh
//! $ cargo build --release
//! $ make
//! ```
//!
//! For more information, see the tutorial [cargo.md](../../cargo.md).

use icu::calendar::DateTime;
use icu::datetime::DateTimeFormatter;
use icu::calendar::{DateTime, Gregorian};
use icu::datetime::TypedDateTimeFormatter;
use icu::locid::locale;
use icu_provider_blob::BlobDataProvider;

Expand All @@ -25,19 +25,17 @@ fn main() {
let provider = BlobDataProvider::try_new_from_blob(blob.into_boxed_slice())
.expect("Deserialization should succeed");

let formatter = DateTimeFormatter::try_new_with_buffer_provider(
let formatter = TypedDateTimeFormatter::<Gregorian>::try_new_with_buffer_provider(
&provider,
&locale!("my").into(),
Default::default(),
)
.expect("Locale 'my' should be present in testdata");

let datetime = DateTime::try_new_iso_datetime(2022, 12, 23, 12, 54, 29)
.expect("Valid constant ISO datetime");
let datetime = DateTime::try_new_gregorian_datetime(2022, 12, 23, 12, 54, 29)
.expect("Valid constant datetime");

let result = formatter
.format_to_string(&datetime.to_any())
.expect("Calendar matches formatter");
let result = formatter.format_to_string(&datetime);

assert_eq!(result, "၂၀၂၂၊ ဒီ ၂၃ ၁၂:၅၄:၂၉");
println!("{}", result);
Expand Down
9 changes: 4 additions & 5 deletions provider/datagen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ fn test_keys_from_file() {
assert_eq!(
keys_from_file(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/data/work_log+keys.txt"
"/tests/data/tutorial_buffer+keys.txt"
))
.unwrap(),
vec![
Expand All @@ -689,13 +689,12 @@ fn test_keys_from_file() {

#[test]
fn test_keys_from_bin() {
// File obtained by changing work_log.rs to use `try_new_with_buffer_provider` & `icu_testdata::small_buffer`
// and running `cargo +nightly-2022-04-18 wasm-build-release --examples -p icu_datetime --features serde \
// && cp target/wasm32-unknown-unknown/release-opt-size/examples/work_log.wasm provider/datagen/tests/data/`
// File obtained by running
// cargo +nightly --config docs/tutorials/testing/patch.toml build -p tutorial_buffer --target wasm32-unknown-unknown --release -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --manifest-path docs/tutorials/crates/buffer/Cargo.toml && cp docs/tutorials/target/wasm32-unknown-unknown/release/tutorial_buffer.wasm provider/datagen/tests/data/
assert_eq!(
keys_from_bin(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/data/work_log.wasm"
"/tests/data/tutorial_buffer.wasm"
))
.unwrap(),
vec![
Expand Down
Binary file added provider/datagen/tests/data/tutorial_buffer.wasm
Binary file not shown.
Binary file removed provider/datagen/tests/data/work_log.wasm
Binary file not shown.

0 comments on commit 5f40b1d

Please sign in to comment.