Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/crates/allen-reflex-kernel/tests/route_card.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / crates / allen-reflex-kernel / tests / route_card.rs` 44 lines ยท 1918 bytes Raw Blame History 1 //! Route card parser (aienos#399): what the image accepts, and that the card cannot carry 2 //! capabilities or expected answers. 3 use allen_reflex_kernel::card::{self, Kind}; 4 5 fn card(lines: &str) -> Vec { 6 format!("AIENALR1 QUALIF-ALLEN-ROUTE\n{lines}").into_bytes() 7 } 8 9 #[test] 10 fn accepts_owner_guest_flags_and_escapes() { 11 let b = card("R1|owner:7|C| what can you do?\nR2|guest:9|-| tell me my notes\nR3|owner:1|PC| approve it%2C please\n"); 12 assert_eq!(card::kind(&b), Some(Kind::Route)); 13 let r = card::parse_route(&b).unwrap(); 14 assert_eq!(r.len(), 3); 15 assert!(r[0].owner && r[0].consent && !r[0].pending && r[0].session == 7); 16 assert!(!r[1].owner && !r[1].consent && !r[1].pending); 17 assert!(r[2].consent && r[2].pending); 18 } 19 20 #[test] 21 fn refuses_malformed_lines() { 22 for bad in [ 23 "R1|admin:1|-| hi\n", // unknown speaker 24 "R1|owner:0|-| hi\n", // session 0 25 "R1|owner:`1234567890`|-| hi\n", // session too long 26 "R1|owner:1|X| hi\n", // unknown flag (e.g. a capability claim) 27 "R1|owner:1|CC| hi\n", // repeated flag 28 "R1|owner:1|| hi\n", // empty flags 29 "R1|owner:1|-|\n", // empty turns 30 "R1|owner:1| hi\n", // missing field 31 "R1|owner:1|-| hi\nR1|guest:1|-| hi\n", // duplicate id 32 ] { 33 assert!(card::parse_route(&card(bad)).is_err(), "accepted: {bad}"); 34 } 35 } 36 37 #[test] 38 fn kinds_do_not_mix() { 39 let exam = b"AIENALX1 QUALIF-ALLEN-EXAM\nX1| hi\n".to_vec(); 40 assert_eq!(card::kind(&exam), Some(Kind::Exam)); 41 assert!(card::parse_route(&exam).is_err()); 42 assert!(card::parse(&card("R1|owner:1|-| hi\n")).is_err()); 43 assert_eq!(card::kind(b"AIENALR1 QUALIF-ALLEN-ROUTEX\n"), None); 44 }