use xberg::core::config::ExtractionConfig;
#[test]
fn test_extraction_config_minimal_serialization() {
let config = ExtractionConfig::default();
let json = serde_json::to_value(&config).expect("Failed to serialize config");
assert!(json.get("use_cache").is_some(), "Missing use_cache field");
assert!(
json.get("enable_quality_processing").is_some(),
"Missing enable_quality_processing field"
);
assert!(json.get("force_ocr").is_some(), "Missing force_ocr field");
}
#[test]
fn test_extraction_config_serialization_round_trip() {
let original = ExtractionConfig {
use_cache: true,
enable_quality_processing: false,
force_ocr: true,
..Default::default()
};
let json = serde_json::to_value(&original).expect("Failed to serialize");
let restored: ExtractionConfig = serde_json::from_value(json).expect("Failed to deserialize");
assert_eq!(original.use_cache, restored.use_cache, "use_cache field not preserved");
assert_eq!(
original.enable_quality_processing, restored.enable_quality_processing,
"enable_quality_processing field not preserved"
);
assert_eq!(original.force_ocr, restored.force_ocr, "force_ocr field not preserved");
}
#[test]
fn test_extraction_config_nested_serialization() {
let config = ExtractionConfig {
use_cache: true,
enable_quality_processing: true,
force_ocr: false,
..Default::default()
};
let json = serde_json::to_value(&config).expect("Failed to serialize");
assert!(json.is_object(), "Serialized output should be a JSON object");
assert!(json.get("use_cache").is_some());
assert!(json.get("enable_quality_processing").is_some());
assert!(json.get("force_ocr").is_some());
}
#[test]
fn test_extraction_config_json_format() {
let config = ExtractionConfig::default();
let json_string = serde_json::to_string(&config).expect("Failed to serialize to string");
let parsed: serde_json::Value = serde_json::from_str(&json_string).expect("Invalid JSON output");
assert!(parsed.is_object(), "JSON should be an object");
}
#[test]
fn test_extraction_config_pretty_print() {
let config = ExtractionConfig::default();
let pretty_json = serde_json::to_string_pretty(&config).expect("Failed to serialize");
let _parsed: serde_json::Value = serde_json::from_str(&pretty_json).expect("Invalid pretty-printed JSON");
assert!(pretty_json.contains('\n'), "Pretty JSON should have newlines");
}
#[test]
fn test_extraction_config_field_consistency() {
let configs = vec![
ExtractionConfig::default(),
ExtractionConfig {
use_cache: true,
..Default::default()
},
ExtractionConfig {
enable_quality_processing: false,
..Default::default()
},
];
for config in configs {
let json = serde_json::to_value(&config).expect("Failed to serialize");
assert!(json.get("use_cache").is_some());
assert!(json.get("enable_quality_processing").is_some());
assert!(json.get("force_ocr").is_some());
}
}