-
Notifications
You must be signed in to change notification settings - Fork 18
Map serde support #45
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
Changes from all commits
a0ae9c8
a0a2658
cb45eea
ebb363b
2112dfc
62b6f26
ca4e8ec
2e6554a
39a4cb8
b677f79
cdc7813
d1f21ab
784121c
c1b254c
227daee
96d4319
ff80164
761cf3d
19ea90c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,8 @@ pub use self::ser::{to_string, to_vec}; | |
|
|
||
| #[cfg(test)] | ||
| mod test { | ||
| use std::collections::BTreeMap; | ||
|
|
||
| use super::*; | ||
| use serde_derive::{Deserialize, Serialize}; | ||
|
|
||
|
|
@@ -95,6 +97,7 @@ mod test { | |
| published: bool, | ||
| comments: Vec<CommentId>, | ||
| stats: Stats, | ||
| balances: BTreeMap<String, u16>, | ||
| } | ||
|
|
||
| #[test] | ||
|
|
@@ -107,7 +110,10 @@ mod test { | |
| published: false, | ||
| comments: vec![], | ||
| stats: Stats { views: 0, score: 0 }, | ||
| balances: BTreeMap::new(), | ||
| }; | ||
| let mut balances: BTreeMap<String, u16> = BTreeMap::new(); | ||
| balances.insert("chareen".into(), 347); | ||
| let max = Item { | ||
| model: Model::Post { | ||
| category: "fun".to_string(), | ||
|
|
@@ -122,6 +128,7 @@ mod test { | |
| views: std::u64::MAX, | ||
| score: std::i64::MIN, | ||
| }, | ||
| balances, | ||
| }; | ||
|
|
||
| // binary | ||
|
|
@@ -172,6 +179,9 @@ mod test { | |
| author: Address("no-reply@domain.com".to_owned()), | ||
| }); | ||
|
|
||
| let mut balances: BTreeMap<String, u16> = BTreeMap::new(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, so this test will show And does work with Maybe other pieces already work. Can you add test cases for other types? Also, this only works when the map has all the same type of value, right? I guess we need some more work for flatten, but we can leave that for another PR. |
||
| balances.insert("chareen".into(), 347); | ||
|
|
||
| let item = ModelOrItem::Item(Item { | ||
| model: Model::Comment, | ||
| title: "Title".to_owned(), | ||
|
|
@@ -183,6 +193,7 @@ mod test { | |
| views: 110, | ||
| score: 12, | ||
| }, | ||
| balances, | ||
| }); | ||
|
|
||
| assert_eq!( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.