#![cfg(all(feature = "std", feature = "serde"))]

use osom_lib_strings::immutable::std::StdImmutableString;
use rstest::rstest;

#[rstest]
#[case("", "\"\"")]
#[case("aBc", "\"aBc\"")]
#[case("a. x ya", "\"a. x ya\"")]
#[case("A \" B", "\"A \\\" B\"")]
fn test_serialization(#[case] input: &str, #[case] expected: &str) {
    let imm = StdImmutableString::from_str_slice(input).unwrap();
    let result = serde_json::to_string(&imm).unwrap();
    assert_eq!(&result, expected);
}

#[rstest]
#[case("\"\"", "")]
#[case("\"aBc\"", "aBc")]
#[case("\"a. x ya\"", "a. x ya")]
#[case("\"A \\\" B\"", "A \" B")]
fn test_deserialization(#[case] input: &str, #[case] expected: &str) {
    let result: StdImmutableString = serde_json::from_str(input).unwrap();
    assert_eq!(result.as_str(), expected);
}
