Skip to content

Commit 684da0e

Browse files
committed
Add more ToString test cases
1 parent 1be0ee7 commit 684da0e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,25 +255,23 @@ mod tests {
255255
fn test_simple() {
256256
let qs = QueryString::new()
257257
.with_value("q", "apple???")
258-
.with_value("category", "fruits and vegetables");
258+
.with_value("category", "fruits and vegetables")
259+
.with_value("tasty", true)
260+
.with_value("weight", 99.9);
259261
assert_eq!(
260262
qs.to_string(),
261-
"?q=apple???&category=fruits%20and%20vegetables"
263+
"?q=apple???&category=fruits%20and%20vegetables&tasty=true&weight=99.9"
262264
);
263-
assert_eq!(qs.len(), 2);
265+
assert_eq!(qs.len(), 4);
264266
assert!(!qs.is_empty());
265267
}
266268

267269
#[test]
268270
fn test_encoding() {
269271
let qs = QueryString::new()
270272
.with_value("q", "Grünkohl")
271-
.with_value("category", "Gemüse")
272-
.with_value("answer", 42);
273-
assert_eq!(
274-
qs.to_string(),
275-
"?q=Gr%C3%BCnkohl&category=Gem%C3%BCse&answer=42"
276-
);
273+
.with_value("category", "Gemüse");
274+
assert_eq!(qs.to_string(), "?q=Gr%C3%BCnkohl&category=Gem%C3%BCse");
277275
}
278276

279277
#[test]
@@ -292,12 +290,14 @@ mod tests {
292290
let qs = QueryString::new()
293291
.with_value("q", "celery")
294292
.with_opt_value("taste", None::<String>)
295-
.with_opt_value("category", Some("fruits and vegetables"));
293+
.with_opt_value("category", Some("fruits and vegetables"))
294+
.with_opt_value("tasty", Some(true))
295+
.with_opt_value("weight", Some(99.9));
296296
assert_eq!(
297297
qs.to_string(),
298-
"?q=celery&category=fruits%20and%20vegetables"
298+
"?q=celery&category=fruits%20and%20vegetables&tasty=true&weight=99.9"
299299
);
300-
assert_eq!(qs.len(), 2); // not three!
300+
assert_eq!(qs.len(), 4); // not five!
301301
}
302302

303303
#[test]

0 commit comments

Comments
 (0)