Skip to content

Commit

Permalink
Starts testing with ICU 67.1
Browse files Browse the repository at this point in the history
This is the last step in getting rust_icu tested with ICU 67.1  There
are a few pull requests in flight that preempt this one, such as #75,
but once those are commited, this can go in. (And should pass.)

Fixes #76, #83
  • Loading branch information
filmil committed May 8, 2020
1 parent de07929 commit 0850dd1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
- DOCKER_TEST_ENV=rust_icu_testenv-64
- DOCKER_TEST_ENV=rust_icu_testenv-65
- DOCKER_TEST_ENV=rust_icu_testenv-66
- DOCKER_TEST_ENV=rust_icu_testenv-67

script:
- make docker-test
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ docker-test:
--volume=${CARGO_TARGET_DIR}:/build/cargo \
--volume=${LOGNAME_HOME}/.cargo:/usr/local/cargo \
--env="CARGO_TEST_ARGS=${DOCKER_TEST_CARGO_TEST_ARGS}" \
--env="RUST_BACKTRACE=full" \
${DOCKER_REPO}/${DOCKER_TEST_ENV}:${USED_BUILDENV_VERSION}
.PHONY: docker-test

Expand Down
32 changes: 26 additions & 6 deletions rust_icu_umsg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
//!
//! let fmt = umsg::UMessageFormat::try_from(&msg, &loc)?;
//! let hello = ustring::UChar::try_from("Hello! Добар дан!")?;
//! let _ = message_format!(&fmt);
//! let result = umsg::message_format!(
//! fmt,
//! { 43.4 => Double },
Expand Down Expand Up @@ -279,7 +278,6 @@ impl UMessageFormat {
///
/// let fmt = umsg::UMessageFormat::try_from(&msg, &loc)?;
/// let hello = ustring::UChar::try_from("Hello! Добар дан!")?;
/// let _ = message_format!(&fmt);
/// let result = umsg::message_format!(
/// fmt,
/// { 43.4 => Double },
Expand Down Expand Up @@ -307,9 +305,7 @@ impl UMessageFormat {
#[macro_export]
macro_rules! message_format {
($dest:expr) => {
unsafe {
$crate::format_varargs(&$dest)
}
panic!("you should not format a message without parameters")
};
($dest:expr, $( {$arg:expr => $t:ident}),* ) => {
unsafe {
Expand Down Expand Up @@ -424,6 +420,12 @@ mod tests {
}
}

fn tzsave() -> Result<(), common::Error> {
let _ = TzSave(ucal::get_default_time_zone()?);
ucal::set_default_time_zone("Europe/Amsterdam")?;
Ok(())
}

#[test]
fn basic() -> Result<(), common::Error> {
let _ = TzSave(ucal::get_default_time_zone()?);
Expand All @@ -439,7 +441,6 @@ mod tests {

let fmt = crate::UMessageFormat::try_from(&msg, &loc)?;
let hello = ustring::UChar::try_from("Hello! Добар дан!")?;
let _ = message_format!(&fmt);
let value: i32 = 31337;
let result = message_format!(
fmt,
Expand All @@ -459,6 +460,25 @@ mod tests {
Ok(())
}

#[test]
#[should_panic]
fn empty_args_in_format() {
let _ = TzSave(ucal::get_default_time_zone().unwrap());
ucal::set_default_time_zone("Europe/Amsterdam").unwrap();

let loc = uloc::ULoc::try_from("en-US").unwrap();
let msg = ustring::UChar::try_from(
r"Formatted double: {0,number,##.#},
Formatted integer: {1,number,integer},
Formatted string: {2},
Date: {3,date,full}",
).unwrap();
let fmt = crate::UMessageFormat::try_from(&msg, &loc).unwrap();

// This is not allowed!
let _ = message_format!(&fmt);
}

#[test]
fn clone() -> Result<(), common::Error> {
let loc = uloc::ULoc::try_from("en-US-u-tz-uslax")?;
Expand Down

0 comments on commit 0850dd1

Please sign in to comment.