use crate::{EditorDocument, EventBuilder, StyleBuilder};
#[test]
fn test_edit_event_simple() {
let content = r#"[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:05.00,0:00:10.00,Default,John,0,0,0,,Hello, world!"#;
let mut doc = EditorDocument::from_content(content).unwrap();
let _result = doc.edit_event_text("Hello, world!", "New text");
}
#[test]
fn test_add_event_macro() {
let content = r#"[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"#;
let _doc = EditorDocument::from_content(content).unwrap();
let event = EventBuilder::dialogue()
.start_time("0:00:05.00")
.end_time("0:00:10.00")
.speaker("John")
.text("Hello world!")
.build()
.unwrap();
assert!(event.contains("Dialogue:"));
assert!(event.contains("Hello world!"));
}
#[test]
fn test_style_builder_macro() {
let style = StyleBuilder::new()
.name("TestStyle")
.font("Arial")
.size(24)
.bold(true)
.build()
.unwrap();
assert!(style.contains("TestStyle"));
assert!(style.contains("Arial"));
assert!(style.contains("24"));
}
#[test]
fn test_script_info_operations() {
let content = r#"[Script Info]
Title: Test"#;
let mut doc = EditorDocument::from_content(content).unwrap();
doc.set_script_info_field("Author", "Test Author").unwrap();
let _author = doc.get_script_info_field("Author").unwrap();
}
#[test]
fn test_position_operations() {
let mut doc = EditorDocument::from_content("Hello World").unwrap();
doc.at(crate::Position::new(6))
.insert_text("Beautiful ")
.unwrap();
assert!(doc.text().contains("Beautiful"));
}