use std::collections::HashMap;
use std::sync::Arc;
use compact_str::CompactString;
use facet_json::to_string;
use facet_testhelpers::test;
#[test]
fn box_str_map_key() {
let map = HashMap::from([(Box::<str>::from("key"), true)]);
let json = to_string(&map).unwrap();
assert_eq!(json, r#"{"key":true}"#);
}
#[test]
fn arc_str_map_key() {
let map = HashMap::from([(Arc::<str>::from("key"), true)]);
let json = to_string(&map).unwrap();
assert_eq!(json, r#"{"key":true}"#);
}
#[test]
fn compact_string_map_key() {
let map = HashMap::from([(CompactString::from("key"), true)]);
let json = to_string(&map).unwrap();
assert_eq!(json, r#"{"key":true}"#);
}
#[test]
fn box_str_multiple_keys() {
let map = HashMap::from([
(Box::<str>::from("alpha"), 1),
(Box::<str>::from("beta"), 2),
]);
let json = to_string(&map).unwrap();
assert!(
json == r#"{"alpha":1,"beta":2}"# || json == r#"{"beta":2,"alpha":1}"#,
"unexpected json: {json}"
);
}