This repository has been archived on 2026-08-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
donglora/vendor/pulldown-cmark/tests/serde.rs
T
swaitsandClaude Opus 4.6 3102fc747a feat: add display UI with splash screen, dashboard, and RSSI sparkline
Implement full SSD1306 OLED display support:
- Splash screen on boot (1.5s) with project name, version, board
- Dashboard showing radio state, config, counters, RSSI/SNR
- RSSI history sparkline (64-sample ring buffer, 2px-wide bars)
- DisplayOn/DisplayOff host commands routed via dedicated channel
- Pure render functions against generic DrawTarget (no hardware coupling)
- Display on/off control bypasses radio task entirely

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 20:42:54 -06:00

87 lines
3.0 KiB
Rust

#[cfg(feature = "serde")]
mod tests {
use std::convert::TryInto;
use pulldown_cmark::CowStr;
#[test]
fn escaped() {
let must_be_escaped = "\"";
let wire = serde_json::to_string(must_be_escaped).unwrap();
let de = serde_json::from_str::<CowStr>(&wire).unwrap();
assert_eq!(&*de, must_be_escaped);
}
#[test]
fn cow_str_to_str_round_trip_bincode() {
for i in &[
CowStr::Borrowed("dssa"),
CowStr::Borrowed(""),
CowStr::Boxed("hello".to_owned().into_boxed_str()),
CowStr::Boxed("".to_owned().into_boxed_str()),
CowStr::Inlined("inline".try_into().unwrap()),
CowStr::Inlined("".try_into().unwrap()),
] {
let encoded = bincode::serialize(i).unwrap();
let decoded1: CowStr = bincode::deserialize(&encoded).unwrap();
let decoded2: String = bincode::deserialize(&encoded).unwrap();
let decoded3: &str = bincode::deserialize(&encoded).unwrap();
assert_eq!(&decoded1, i);
assert_eq!(decoded2, i.as_ref());
assert_eq!(decoded3, i.as_ref());
}
}
#[test]
fn cow_str_to_str_round_trip_json() {
for i in &[
CowStr::Borrowed("dssa"),
CowStr::Borrowed(""),
CowStr::Boxed("hello".to_owned().into_boxed_str()),
CowStr::Boxed("".to_owned().into_boxed_str()),
CowStr::Inlined("inline".try_into().unwrap()),
CowStr::Inlined("".try_into().unwrap()),
] {
let encoded = serde_json::to_string(i).unwrap();
let decoded1: CowStr = serde_json::from_str(&encoded).unwrap();
let decoded2: String = serde_json::from_str(&encoded).unwrap();
let decoded3: &str = serde_json::from_str(&encoded).unwrap();
assert_eq!(&decoded1, i);
assert_eq!(decoded2, i.as_ref());
assert_eq!(decoded3, i.as_ref());
}
}
#[test]
fn str_to_cow_str_json() {
let str = "a borrowed str";
let string = "a owned str".to_owned();
let encoded_str = serde_json::to_string(&str).unwrap();
let encoded_string = serde_json::to_string(&string).unwrap();
let decoded_str: CowStr = serde_json::from_str(&encoded_str).unwrap();
let decoded_string: CowStr = serde_json::from_str(&encoded_string).unwrap();
assert_eq!(decoded_str.as_ref(), str);
assert_eq!(decoded_string.as_ref(), string);
}
#[test]
fn str_to_cow_str_bincode() {
let str = "a borrowed str";
let string = "a owned str".to_owned();
let encoded_str = bincode::serialize(&str).unwrap();
let encoded_string = bincode::serialize(&string).unwrap();
let decoded_str: CowStr = bincode::deserialize(&encoded_str).unwrap();
let decoded_string: CowStr = bincode::deserialize(&encoded_string).unwrap();
assert_eq!(decoded_str.as_ref(), str);
assert_eq!(decoded_string.as_ref(), string);
}
}