Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch serde test to fnv to avoid 32bit issues #214

Merged
merged 2 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-all
lazy_static = "1.2"
rand = { version = "0.7.3", features = ["small_rng"] }
rayon = "1.0"
rustc-hash = "=1.0"
fnv = "1.0.7"
serde_test = "1.0"
doc-comment = "0.3.1"

Expand Down
1 change: 1 addition & 0 deletions src/raw/sse2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl Group {
/// value for an empty hash table.
///
/// This is guaranteed to be aligned to the group size.
#[allow(clippy::items_after_statements)]
pub const fn static_empty() -> &'static [u8; Group::WIDTH] {
#[repr(C)]
struct AlignedBytes {
Expand Down
22 changes: 11 additions & 11 deletions tests/serde.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#![cfg(feature = "serde")]

use core::hash::BuildHasherDefault;
use fnv::FnvHasher;
use hashbrown::{HashMap, HashSet};
use rustc_hash::FxHasher;
use serde_test::{assert_tokens, Token};

// We use FxHash for this test because we rely on the ordering
type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
type FxHashSet<T> = HashSet<T, BuildHasherDefault<FxHasher>>;
// We use FnvHash for this test because we rely on the ordering
type FnvHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FnvHasher>>;
type FnvHashSet<T> = HashSet<T, BuildHasherDefault<FnvHasher>>;

#[test]
fn map_serde_tokens_empty() {
let map = FxHashMap::<char, u32>::default();
let map = FnvHashMap::<char, u32>::default();

assert_tokens(&map, &[Token::Map { len: Some(0) }, Token::MapEnd]);
}

#[test]
fn map_serde_tokens() {
let mut map = FxHashMap::default();
let mut map = FnvHashMap::default();
map.insert('b', 20);
map.insert('a', 10);
map.insert('c', 30);
Expand All @@ -29,25 +29,25 @@ fn map_serde_tokens() {
Token::Map { len: Some(3) },
Token::Char('a'),
Token::I32(10),
Token::Char('b'),
Token::I32(20),
Token::Char('c'),
Token::I32(30),
Token::Char('b'),
Token::I32(20),
Token::MapEnd,
],
);
}

#[test]
fn set_serde_tokens_empty() {
let set = FxHashSet::<u32>::default();
let set = FnvHashSet::<u32>::default();

assert_tokens(&set, &[Token::Seq { len: Some(0) }, Token::SeqEnd]);
}

#[test]
fn set_serde_tokens() {
let mut set = FxHashSet::default();
let mut set = FnvHashSet::default();
set.insert(20);
set.insert(10);
set.insert(30);
Expand All @@ -56,9 +56,9 @@ fn set_serde_tokens() {
&set,
&[
Token::Seq { len: Some(3) },
Token::I32(30),
Token::I32(20),
Token::I32(10),
Token::I32(30),
Token::SeqEnd,
],
);
Expand Down