//! TOML `bookmarks` with sixteen 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_sixteen_bookmarks() {
    let s = format!(
        r#"
{BASE}
bookmarks = ["/h0", "/h1", "/h2", "/h3", "/h4", "/h5", "/h6", "/h7", "/h8", "/h9", "/h10", "/h11", "/h12", "/h13", "/h14", "/h15"]
"#
    );
    let p: Prefs = toml::from_str(&s).unwrap();
    assert_eq!(p.bookmarks.len(), 16);
    assert_eq!(p.bookmarks[0], "/h0");
    assert_eq!(p.bookmarks[15], "/h15");
}

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