Skip to content

Commit

Permalink
Switch out fnv in favor of foldhash in test
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Nov 16, 2024
1 parent 0307f60 commit 72cd0a4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion test_suite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ serde = { path = "../serde" }

[dev-dependencies]
automod = "1.0.1"
fnv = "1.0"
foldhash = "0.1"
rustversion = "1.0"
serde = { path = "../serde", features = ["rc"] }
serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] }
Expand Down
10 changes: 4 additions & 6 deletions test_suite/tests/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ macro_rules! hashset {
$(set.insert($value);)+
set
}};
($hasher:ident @ $($value:expr),+) => {{
use std::hash::BuildHasherDefault;
let mut set = HashSet::with_hasher(BuildHasherDefault::<$hasher>::default());
($hasher:ty; $($value:expr),+) => {{
let mut set = HashSet::<_, $hasher>::default();
$(set.insert($value);)+
set
}};
Expand All @@ -51,9 +50,8 @@ macro_rules! hashmap {
$(map.insert($key, $value);)+
map
}};
($hasher:ident @ $($key:expr => $value:expr),+) => {{
use std::hash::BuildHasherDefault;
let mut map = HashMap::with_hasher(BuildHasherDefault::<$hasher>::default());
($hasher:ty; $($key:expr => $value:expr),+) => {{
let mut map = HashMap::<_, _, $hasher>::default();
$(map.insert($key, $value);)+
map
}};
Expand Down
5 changes: 2 additions & 3 deletions test_suite/tests/test_de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
)]
#![cfg_attr(feature = "unstable", feature(never_type))]

use fnv::FnvHasher;
use serde::de::value::{F32Deserializer, F64Deserializer};
use serde::de::{Deserialize, DeserializeOwned, Deserializer, IntoDeserializer};
use serde_derive::Deserialize;
Expand Down Expand Up @@ -1040,7 +1039,7 @@ fn test_hashset() {
],
);
test(
hashset![FnvHasher @ 1, 2, 3],
hashset![foldhash::fast::FixedState; 1, 2, 3],
&[
Token::Seq { len: Some(3) },
Token::I32(1),
Expand Down Expand Up @@ -1275,7 +1274,7 @@ fn test_hashmap() {
],
);
test(
hashmap![FnvHasher @ 1 => 2, 3 => 4],
hashmap![foldhash::fast::FixedState; 1 => 2, 3 => 4],
&[
Token::Map { len: Some(2) },
Token::I32(1),
Expand Down
5 changes: 2 additions & 3 deletions test_suite/tests/test_ser.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![allow(clippy::derive_partial_eq_without_eq, clippy::unreadable_literal)]
#![cfg_attr(feature = "unstable", feature(never_type))]

use fnv::FnvHasher;
use serde_derive::Serialize;
use serde_test::{assert_ser_tokens, assert_ser_tokens_error, Configure, Token};
use std::cell::RefCell;
Expand Down Expand Up @@ -220,7 +219,7 @@ fn test_hashset() {
&[Token::Seq { len: Some(1) }, Token::I32(1), Token::SeqEnd],
);
assert_ser_tokens(
&hashset![FnvHasher @ 1],
&hashset![foldhash::fast::FixedState; 1],
&[Token::Seq { len: Some(1) }, Token::I32(1), Token::SeqEnd],
);
}
Expand Down Expand Up @@ -300,7 +299,7 @@ fn test_hashmap() {
],
);
assert_ser_tokens(
&hashmap![FnvHasher @ 1 => 2],
&hashmap![foldhash::fast::FixedState; 1 => 2],
&[
Token::Map { len: Some(1) },
Token::I32(1),
Expand Down

0 comments on commit 72cd0a4

Please sign in to comment.