summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSam Scott <sam.scott89@gmail.com>2017-03-09 19:22:01 -0500
committerSam Scott <sam.scott89@gmail.com>2017-03-09 19:22:01 -0500
commit6aecad1c9a907c0dc567aef3388bb1857f9ed47d (patch)
treed07c5cdb1df9792333d65d1ae28ed153cf392ec1 /tests
parent25ab41ec08a61e1894a500b26dd8e188c1e9015d (diff)
Support serializing sequences.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_serialize.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_serialize.rs b/tests/test_serialize.rs
index c10c3da..ccac101 100644
--- a/tests/test_serialize.rs
+++ b/tests/test_serialize.rs
@@ -9,6 +9,10 @@ struct Bar { x: u8, y: String }
#[derive(Serialize, Deserialize)]
struct Baz { thing: String, other: u8 }
+#[derive(Serialize, Deserialize)]
+struct Complex { x: Vec<u8>, y: Vec<Baz> }
+
+
#[test]
fn serialize_struct() {
let params = Foo {
@@ -24,6 +28,15 @@ fn serialize_struct() {
assert_eq!(qs::to_string(&params),
Ok(urlencode("bar[x]=10&bar[y]=Ten&baz[thing]=Thing&baz[other]=12")));
+
+ let params = Complex {
+ x: vec![0,1,2],
+ y: vec![params.baz],
+ };
+
+
+ assert_eq!(qs::to_string(&params),
+ Ok(urlencode("x[0]=0&x[1]=1&x[2]=2&y[0][thing]=Thing&y[0][other]=12")));
}
fn urlencode(input: &str) -> String {