//! TOML `bookmarks` with forty-six paths.

#![allow(clippy::field_reassign_with_default)]

use storageshower::prefs::Prefs;

const BASE: &str = r#"
sort_mode = "Name"
sort_rev = false
show_local = false
refresh_rate = 1
bar_style = "Gradient"
color_mode = "Default"
thresh_warn = 70
thresh_crit = 90
show_bars = true
show_border = true
show_header = true
compact = false
show_used = true
full_mount = false
"#;

#[test]
fn deserialize_forty_six_bookmarks() {
    let s = format!(
        r#"
{BASE}
bookmarks = ["/w0", "/w1", "/w2", "/w3", "/w4", "/w5", "/w6", "/w7", "/w8", "/w9", "/w10", "/w11", "/w12", "/w13", "/w14", "/w15", "/w16", "/w17", "/w18", "/w19", "/w20", "/w21", "/w22", "/w23", "/w24", "/w25", "/w26", "/w27", "/w28", "/w29", "/w30", "/w31", "/w32", "/w33", "/w34", "/w35", "/w36", "/w37", "/w38", "/w39", "/w40", "/w41", "/w42", "/w43", "/w44", "/w45"]
"#
    );
    let p: Prefs = toml::from_str(&s).unwrap();
    assert_eq!(p.bookmarks.len(), 46);
    assert_eq!(p.bookmarks[0], "/w0");
    assert_eq!(p.bookmarks[45], "/w45");
}

#[test]
fn roundtrip_forty_six_bookmarks() {
    let mut p = Prefs::default();
    p.bookmarks = (0..46).map(|i| format!("/bm{i}")).collect();
    let out = toml::to_string_pretty(&p).unwrap();
    let q: Prefs = toml::from_str(&out).unwrap();
    assert_eq!(q.bookmarks, p.bookmarks);
}
