use compact_str::CompactString;
use facet::Facet;
use facet_json::{from_str, to_string};
use facet_testhelpers::test;
#[derive(Debug, PartialEq, Facet)]
#[facet(cow)]
#[repr(u8)]
pub enum Stem<'a> {
Borrowed(&'a str),
Owned(CompactString),
}
#[test]
fn test_issue_1900_serialize_transparent() {
let s = Stem::Owned("hello".into());
let json = to_string(&s).expect("should serialize");
assert_eq!(json, r#""hello""#);
}
#[test]
fn test_issue_1900_deserialize_transparent() {
let json = r#""hello""#;
let result: Stem<'static> = from_str(json).expect("should deserialize");
assert_eq!(result, Stem::Owned("hello".into()));
}
#[test]
fn test_issue_1900_roundtrip() {
let original = Stem::Owned("test value".into());
let json = to_string(&original).expect("should serialize");
assert_eq!(json, r#""test value""#);
let parsed: Stem<'static> = from_str(&json).expect("should deserialize");
assert_eq!(parsed, original);
}