codex-mobile-bridge 0.2.5

Remote bridge and service manager for codex-mobile.
Documentation
use super::super::helpers::{OptionalTextUpdate, normalize_name, resolve_optional_text_update};

#[test]
fn resolve_optional_text_update_distinguishes_unchanged_set_and_clear() {
    assert_eq!(
        resolve_optional_text_update(Some("当前名称"), None),
        OptionalTextUpdate::Unchanged,
    );
    assert_eq!(
        resolve_optional_text_update(Some("当前名称"), Some("  当前名称  ")),
        OptionalTextUpdate::Unchanged,
    );
    assert_eq!(
        resolve_optional_text_update(Some("当前名称"), Some("新名称")),
        OptionalTextUpdate::Set("新名称".to_string()),
    );
    assert_eq!(
        resolve_optional_text_update(Some("当前名称"), Some("   ")),
        OptionalTextUpdate::Clear,
    );
    assert_eq!(
        resolve_optional_text_update(None, Some("   ")),
        OptionalTextUpdate::Unchanged,
    );
}

#[test]
fn normalize_name_clears_blank_titles() {
    assert_eq!(normalize_name(Some("".to_string())), None);
    assert_eq!(normalize_name(Some("   ".to_string())), None);
    assert_eq!(
        normalize_name(Some("  新线程  ".to_string())),
        Some("新线程".to_string())
    );
}