summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKenaniah Cerny <kenaniah@users.noreply.github.com>2021-06-09 12:20:57 -0700
committerGitHub <noreply@github.com>2021-06-09 15:20:57 -0400
commit5bfaa7aa9f38806436e15928917cbd841a61e0f2 (patch)
tree6cb78303dd92e131ce163a6d25c0525f741e34d4 /tests
parent17069910eaa1a22b3ea6c180a148e85b265bec95 (diff)
fixes #45 - encoding not working correctly on maps (#47)
Diffstat (limited to 'tests')
-rw-r--r--tests/test_serialize.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_serialize.rs b/tests/test_serialize.rs
index cc4492c..94a8de8 100644
--- a/tests/test_serialize.rs
+++ b/tests/test_serialize.rs
@@ -178,3 +178,24 @@ fn serialize_bytes() {
let s = qs::to_string(&Query { bytes }).unwrap();
assert_eq!(s, "bytes=hello%2C+world%21");
}
+
+#[test]
+fn serialize_hashmap_keys() {
+ // Issue: https://github.com/samscott89/serde_qs/issues/45
+
+ #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
+ struct HashParams {
+ attrs: std::collections::HashMap<String, String>,
+ }
+
+ let data = HashParams {
+ attrs: vec![
+ ("key 1!".to_owned(), "val 1".to_owned()),
+ ("key 2!".to_owned(), "val 2".to_owned()),
+ ]
+ .into_iter()
+ .collect(),
+ };
+ let s = qs::to_string(&data).unwrap();
+ assert!(s == "attrs[key+1%21]=val+1&attrs[key+2%21]=val+2" || s == "attrs[key+2%21]=val+2&attrs[key+1%21]=val+1");
+}