Skip to content

Commit

Permalink
Test hashbrown/indexmap extract conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhly committed Oct 16, 2023
1 parent 16df9bf commit f66c610
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/conversions/hashbrown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,19 @@ mod tests {
let mut map = hashbrown::HashMap::<i32, i32>::new();
map.insert(1, 1);

let mappingproxy = map.into_py_mappingproxy(py).unwrap();
let mappingproxy = map.clone().into_py_mappingproxy(py).unwrap();

assert_eq!(mappingproxy.len().unwrap(), 1);
assert_eq!(
mappingproxy.get_item(1).unwrap().extract::<i32>().unwrap(),
1
);
assert_eq!(
map,
mappingproxy
.extract::<hashbrown::HashMap::<i32, i32>>()
.unwrap()
);
});
}
}
8 changes: 7 additions & 1 deletion src/conversions/indexmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,19 @@ mod test_indexmap {
let mut map = indexmap::IndexMap::<i32, i32>::new();
map.insert(1, 1);

let mappingproxy = map.into_py_mappingproxy(py).unwrap();
let mappingproxy = map.clone().into_py_mappingproxy(py).unwrap();

assert_eq!(mappingproxy.len().unwrap(), 1);
assert_eq!(
mappingproxy.get_item(1).unwrap().extract::<i32>().unwrap(),
1
);
assert_eq!(
map,
mappingproxy
.extract::<indexmap::IndexMap<i32, i32>>()
.unwrap()
);
});
}
}

0 comments on commit f66c610

Please sign in to comment.