From 01c2437f245f1e544a9786d14af394b043e1c0cf Mon Sep 17 00:00:00 2001 From: Terry Raimondo Date: Wed, 9 Oct 2019 03:20:39 +0200 Subject: [PATCH] Config Travis --- .travis.yml | 20 +++++++++++++++++++- src/lib.rs | 22 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cd53568..a037667 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: rust +sudo: required +cache: cargo rust: - stable - beta @@ -16,4 +18,20 @@ matrix: allow_failures: - rust: nightly fast_finish: true -cache: cargo +addons: + apt: + packages: + - libcurl4-openssl-dev + - libelf-dev + - libdw-dev + - binutils-dev + - cmake + sources: + - kalakris-cmake + +cache: + directories: + - /home/travis/.cargo + +before_cache: + - rm -rf /home/travis/.cargo/registry diff --git a/src/lib.rs b/src/lib.rs index ba290e0..4385b23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,6 +44,19 @@ //! assert_eq!("You are not allowed to do this", res); //! } //! ``` +//! +//! If the key is missing, your code will not compile + +//! ```rust,compile_fail +//! use internationalization::t; +//! +//! fn main() { +//! let lang = "en"; +//! let res = t!("missing key", lang); + +//! // Code will not compile +//! } +//! ``` //! ## Installation @@ -80,6 +93,15 @@ mod tests { #[test] fn it_translates() { assert_eq!(t!("key.test", "en"), "This is a test"); + assert_eq!(t!("key.test", "fr"), "C'est un test"); + assert_eq!( + t!("err.not_allowed", "fr"), + "Vous n'êtes pas autorisé à faire cela" + ); + assert_eq!( + t!("err.not_allowed", "en"), + "You are not allowed to do this" + ); } #[test] #[should_panic]