use ferrotype::Ferrotype;
#[derive(Debug, Clone)]
#[allow(unused)]
struct TestData {
name: String,
count: u32,
items: Vec<String>,
}
#[test]
fn test_complete_workflow() {
let mut snapshot = Ferrotype::new();
snapshot
.set_filter_memory_addresses(true)
.set_expect_errors(false);
snapshot.add("Description", "Integration test for ferrotype".to_string());
let test_data = TestData {
name: "integration_test".to_string(),
count: 42,
items: vec![
"first".to_string(),
"second".to_string(),
"third".to_string(),
],
};
snapshot.add_debug("Test Data", &test_data);
snapshot.add(
"Summary",
"This test verifies the complete workflow".to_string(),
);
let content = snapshot.as_string();
assert!(content.contains("Description: >"));
assert!(content.contains("Integration test for ferrotype"));
assert!(content.contains("Test Data: >"));
assert!(content.contains("name: \"integration_test\""));
assert!(content.contains("count: 42"));
assert!(content.contains("Summary: >"));
assert!(content.contains("complete workflow"));
assert!(content.contains(" Integration test for ferrotype"));
assert!(content.contains(" TestData {"));
assert!(content.contains(" name: \"integration_test\","));
snapshot.print();
snapshot.print_stdout();
snapshot.print_stderr();
let display_output = format!("{snapshot}");
assert_eq!(display_output, content);
ferrotype::assert!(snapshot);
}
#[test]
fn test_feature_integration() {
let mut snapshot = Ferrotype::new();
snapshot.add("Basic", "Hello, world!".to_string());
let debug_data = vec![1, 2, 3, 4, 5];
snapshot.add_debug("Numbers", &debug_data);
#[cfg(feature = "hex")]
{
let binary_data = b"Test data for hex dump";
snapshot.add_hex("Binary", binary_data);
}
#[cfg(feature = "tokenstream")]
{
let tokens: proc_macro2::TokenStream =
"fn test() { println!(\"Hello from token stream!\"); }"
.parse()
.unwrap();
snapshot.add_token_stream("Code", &tokens);
}
#[cfg(feature = "anstream")]
{
let colored_text = "\x1b[31mRed\x1b[0m and \x1b[32mGreen\x1b[0m";
snapshot.add_strip_str("Colors", colored_text.to_string());
}
let content = snapshot.as_string();
assert!(content.contains("Basic: >"));
assert!(content.contains("Hello, world!"));
assert!(content.contains("Numbers: >"));
assert!(content.contains("["));
assert!(content.contains("1"));
#[cfg(feature = "hex")]
assert!(content.contains("Binary: >"));
#[cfg(feature = "tokenstream")]
{
assert!(content.contains("Code: >"));
assert!(content.contains("fn test()"));
}
#[cfg(feature = "anstream")]
{
assert!(content.contains("Colors: >"));
assert!(content.contains("Red and Green"));
assert!(!content.contains("\x1b[31m")); }
ferrotype::assert!(snapshot);
}
#[test]
fn test_title_formatting_integration() {
let mut snapshot = Ferrotype::new();
snapshot.add("simple_title", "content1".to_string());
snapshot.add("complex_snake_case_title", "content2".to_string());
snapshot.add("UPPER_CASE_TITLE", "content3".to_string());
snapshot.add("mixedCase_Title", "content4".to_string());
let content = snapshot.as_string();
assert!(content.contains("SimpleTitle: >"));
assert!(content.contains("ComplexSnakeCaseTitle: >"));
assert!(content.contains("UpperCaseTitle: >"));
assert!(content.contains("MixedCaseTitle: >"));
assert!(content.contains(" content1"));
assert!(content.contains(" content2"));
assert!(content.contains(" content3"));
assert!(content.contains(" content4"));
ferrotype::assert!(snapshot);
}
#[test]
fn test_empty_and_edge_cases() {
let empty_snapshot = Ferrotype::new();
assert_eq!(empty_snapshot.as_string(), "");
let mut snapshot = Ferrotype::new();
snapshot.add("Empty", "".to_string());
let content = snapshot.as_string();
assert!(content.contains("Empty: >"));
let mut multiline_snapshot = Ferrotype::new();
multiline_snapshot.add("Multiline", "Line 1\nLine 2\nLine 3".to_string());
let multiline_content = multiline_snapshot.as_string();
assert!(multiline_content.contains(" Line 1"));
assert!(multiline_content.contains(" Line 2"));
assert!(multiline_content.contains(" Line 3"));
let mut special_snapshot = Ferrotype::new();
special_snapshot
.add("Special", "Content with\ttabs and\nnewlines".to_string());
let special_content = special_snapshot.as_string();
assert!(special_content.contains("Special: >"));
assert!(special_content.contains("tabs and"));
}
#[test]
fn test_method_chaining() {
let mut snapshot = Ferrotype::new();
snapshot
.set_expect_errors(true)
.set_filter_memory_addresses(false);
assert!(snapshot.expects_errors());
assert!(!snapshot.filter_memory_addresses());
let mut snapshot2 = Ferrotype::new();
snapshot2
.set_filter_memory_addresses(true)
.set_expect_errors(false);
assert!(!snapshot2.expects_errors());
assert!(snapshot2.filter_memory_addresses());
}
#[test]
fn test_clone_and_equality() {
let mut original = Ferrotype::new();
original.add("Test", "content".to_string());
original.set_expect_errors(true);
original.set_filter_memory_addresses(false);
let mut cloned = original.clone();
assert_eq!(cloned.expects_errors(), original.expects_errors());
assert_eq!(
cloned.filter_memory_addresses(),
original.filter_memory_addresses()
);
assert_eq!(cloned.as_string(), original.as_string());
cloned.add("Additional", "new content".to_string());
assert_ne!(cloned.as_string(), original.as_string());
}