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

use core::ops::Deref;
use osom_lib_arc::std::StdCArc;
use rstest::rstest;

#[rstest]
#[case(0, "0")]
#[case(1, "1")]
#[case(-1, "-1")]
#[case(5123, "5123")]
fn test_serialization(#[case] value: i32, #[case] expected: &str) {
    let arc = StdCArc::new(value).unwrap();
    let result = serde_json::to_string(&arc).unwrap();
    assert_eq!(result, expected);
}

#[rstest]
#[case("0", 0)]
#[case("1", 1)]
#[case("-1", -1)]
#[case("5123", 5123)]
fn test_deserialization(#[case] value: &str, #[case] expected: i32) {
    let result: StdCArc<i32> = serde_json::from_str(value).unwrap();
    assert_eq!(result.deref(), &expected);
}
