From 7525094b9f7944b86887db3b7276f997be415844 Mon Sep 17 00:00:00 2001 From: Kornel Date: Fri, 15 Sep 2023 10:53:09 +0100 Subject: [PATCH 1/2] Fix tests that require features --- fake/src/lib.rs | 2 ++ fake/tests/always-true.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/fake/src/lib.rs b/fake/src/lib.rs index fcf65eb..7416c40 100644 --- a/fake/src/lib.rs +++ b/fake/src/lib.rs @@ -71,12 +71,14 @@ //! println!("value from fixed seed {}", v); //! } //! +//! # #[cfg(feture = "always-true-rng")] { //! // Use an always true RNG so that optional types are always `Some` values. (Requires //! // always-true-rng feature). //! use fake::utils::AlwaysTrueRng; //! let mut rng = AlwaysTrueRng::default(); //! let result: Option = Faker.fake_with_rng(&mut rng); //! println!("Always Some: {}", result.unwrap()); +//! # } //! ``` #[doc(hidden)] pub use rand::Rng; diff --git a/fake/tests/always-true.rs b/fake/tests/always-true.rs index 0dc3a07..dfc0506 100644 --- a/fake/tests/always-true.rs +++ b/fake/tests/always-true.rs @@ -108,6 +108,7 @@ mod always_true_tests { assert_ne!(result.len(), 0); } + #[cfg(feature = "maybe-non-empty-collections")] #[test] fn test_vec_never_empty() { // Arrange From 9c42b35c5a8d63be331e654a7e674fb76d800fbc Mon Sep 17 00:00:00 2001 From: Kornel Date: Fri, 15 Sep 2023 10:55:06 +0100 Subject: [PATCH 2/2] Replace unmaintained unidecode --- Cargo.lock | 14 +++++++------- fake/Cargo.toml | 2 +- fake/src/faker/impls/internet.rs | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89d8e1a..e67b6fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -217,6 +217,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929" +[[package]] +name = "deunicode" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "890d779e1bc371e4fa7727ef6d29a9346be20ddfe40cd8c744cd083ce0640b15" + [[package]] name = "digest" version = "0.10.7" @@ -265,6 +271,7 @@ dependencies = [ "bigdecimal", "chrono", "chrono-tz", + "deunicode", "dummy", "fake", "geo-types", @@ -280,7 +287,6 @@ dependencies = [ "semver", "serde_json", "time", - "unidecode", "url-escape", "uuid", "zerocopy", @@ -880,12 +886,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" -[[package]] -name = "unidecode" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402bb19d8e03f1d1a7450e2bd613980869438e0666331be3e073089124aa1adc" - [[package]] name = "url-escape" version = "0.1.1" diff --git a/fake/Cargo.toml b/fake/Cargo.toml index f0430b4..0fdf655 100644 --- a/fake/Cargo.toml +++ b/fake/Cargo.toml @@ -18,7 +18,7 @@ all-features = true dummy = { version = "0.6", path = "../dummy_derive", optional = true } rand = "0.8" random_color = { version = "0.6", optional = true } -unidecode = "0.3" +deunicode = "1.4" chrono = { version = "0.4", features = [ "std", ], default-features = false, optional = true } diff --git a/fake/src/faker/impls/internet.rs b/fake/src/faker/impls/internet.rs index 188c2d6..424854a 100644 --- a/fake/src/faker/impls/internet.rs +++ b/fake/src/faker/impls/internet.rs @@ -7,7 +7,7 @@ use rand::distributions::{Distribution, Uniform}; use rand::seq::SliceRandom; use rand::Rng; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; -use unidecode::unidecode; +use deunicode::AsciiChars; impl Dummy> for String { fn dummy_with_rng(_: &FreeEmailProvider, rng: &mut R) -> Self { @@ -39,7 +39,7 @@ impl Dummy> for String { fn dummy_with_rng(c: &FreeEmail, rng: &mut R) -> Self { let username: String = Username(c.0).fake_with_rng(rng); let provider: String = FreeEmailProvider(c.0).fake_with_rng(rng); - format!("{}@{}", unidecode(&username), provider) + format!("{}@{}", username.ascii_chars(), provider) } }