whaleprep/tests/form_decode.rs
dev d3001612b2 PYQ clone: builder, CBT exam screen, grading, analytics dashboard
Axum + SQLite full-stack copy of the ZenithPrep PYQ practice app.
Paper builder with unseen-question exclusion, timed CBT screen with
palette and autosave, +4/-1 grading with numerical tolerance, per-question
analysis, history, dashboard with weak-subtopic tracking and coach notes.
2026-10-11 20:06:26 +05:30

23 lines
No EOL
643 B
Rust

use serde::Deserialize;
#[derive(Deserialize, Debug)]
struct Repeated {
chapters: Vec<String>,
}
#[test]
fn repeated_keys_do_not_decode_into_vec() {
// Documents the behaviour that forced comma-separated ids on the build form.
let out = serde_urlencoded::from_str::<Repeated>("chapters=1&chapters=4");
assert!(out.is_err(), "serde_urlencoded keeps the last repeated key only");
}
#[test]
fn comma_separated_ids_decode() {
#[derive(Deserialize, Debug)]
struct Cs {
chapters: String,
}
let v = serde_urlencoded::from_str::<Cs>("chapters=1,4,7").expect("decodes");
assert_eq!(v.chapters, "1,4,7");
}