use crate::from_buffer;
use crate::l3d::Luminaire;
const TEST_L3D_PATH: &str = "tests/data/minimal.l3d";
#[test]
fn test_l3d_load_and_json_roundtrip() {
let loaded = Luminaire::load_l3d(TEST_L3D_PATH).expect("Failed to load L3D file");
let json_data = loaded.to_json().expect("Failed to serialize to JSON");
let luminaire_from_json: Luminaire =
Luminaire::from_json(&json_data).expect("Failed to deserialize from JSON");
let json_data_roundtrip = luminaire_from_json
.to_json()
.expect("Failed to serialize to JSON");
assert_eq!(json_data, json_data_roundtrip, "JSON roundtrip failed");
}
#[test]
fn test_from_buffer_parses_model() {
let l3d_bytes = std::fs::read(TEST_L3D_PATH).expect("Failed to read L3D file");
let l3d = from_buffer(&l3d_bytes);
assert!(
!l3d.file.structure.is_empty(),
"structure.xml should not be empty"
);
assert!(
!l3d.model.parts.is_empty(),
"Model should have at least one part"
);
let first_part = &l3d.model.parts[0];
assert!(!first_part.path.is_empty(), "Part should have a path");
assert!(
first_part.path.ends_with(".obj"),
"Part path should end with .obj"
);
assert!(!l3d.file.assets.is_empty(), "Should have asset files");
}