use ferrotype::Ferrotype;
#[test]
fn test_macro_compiles_and_runs() {
let mut snapshot = Ferrotype::new();
snapshot.add("Test", "Hello from macro test".to_string());
ferrotype::assert!(snapshot);
}
#[test]
fn test_macro_with_expect_errors() {
let mut snapshot = Ferrotype::new();
snapshot.set_expect_errors(true);
snapshot.add("Error Test", "This test expects errors".to_string());
ferrotype::assert!(snapshot);
}
#[test]
fn test_macro_with_memory_filtering() {
let mut snapshot = Ferrotype::new();
snapshot.set_filter_memory_addresses(true);
snapshot.add(
"Memory Test",
"Test with 0x7fff5fbff710 address".to_string(),
);
ferrotype::assert!(snapshot);
}
#[test]
fn test_macro_without_memory_filtering() {
let mut snapshot = Ferrotype::new();
snapshot.set_filter_memory_addresses(false);
snapshot.add(
"No Filter Test",
"Test with 0x7fff5fbff710 address".to_string(),
);
ferrotype::assert!(snapshot);
}
#[test]
fn test_macro_with_custom_folder() {
let mut snapshot = Ferrotype::new();
snapshot.add("Custom Folder", "Test with custom folder".to_string());
ferrotype::assert!(snapshot);
}
#[test]
fn test_macro_with_multiple_sections() {
let mut snapshot = Ferrotype::new();
snapshot.add("Section 1", "First section content".to_string());
snapshot.add("Section 2", "Second section content".to_string());
snapshot.add_debug("Debug Section", vec![1, 2, 3]);
ferrotype::assert!(snapshot);
}
#[test]
fn test_macro_function_name_detection() {
let mut snapshot = Ferrotype::new();
snapshot.add(
"Function Name Test",
"Testing automatic function name detection".to_string(),
);
ferrotype::assert!(snapshot);
}
#[test]
fn test_macro_with_empty_snapshot() {
let snapshot = Ferrotype::new();
ferrotype::assert!(snapshot);
}
#[test]
fn test_macro_with_special_characters() {
let mut snapshot = Ferrotype::new();
snapshot.add(
"Special Characters",
"Content with\nnewlines\tand\ttabs".to_string(),
);
ferrotype::assert!(snapshot);
}
mod submodule {
use super::*;
#[test]
fn test_macro_in_submodule() {
let mut snapshot = Ferrotype::new();
snapshot.add("Submodule Test", "Testing from submodule".to_string());
ferrotype::assert!(snapshot);
}
}
#[cfg(feature = "hex")]
#[test]
fn test_macro_with_hex_feature() {
let mut snapshot = Ferrotype::new();
snapshot.add_hex("Hex Data", b"Binary data for hex test");
ferrotype::assert!(snapshot);
}
#[cfg(feature = "bluegum")]
#[test]
fn test_macro_with_bluegum_feature() {
#[derive(Debug)]
struct TestTree {
name: String,
}
impl bluegum::Bluegum for TestTree {
fn node(&self, builder: &mut bluegum::Builder) {
builder.name(&self.name);
}
}
impl bluegum::BluegumWithState<()> for TestTree {}
let mut snapshot = Ferrotype::new();
let tree = TestTree {
name: "Test Tree".to_string(),
};
snapshot.add_bluegum("Tree", &tree);
ferrotype::assert!(snapshot);
}
#[cfg(feature = "tokenstream")]
#[test]
fn test_macro_with_tokenstream_feature() {
let mut snapshot = Ferrotype::new();
let tokens: proc_macro2::TokenStream = "fn test() {}".parse().unwrap();
snapshot.add_token_stream("Tokens", &tokens);
ferrotype::assert!(snapshot);
}
#[test]
fn test_get_output_dir_function() {
let dir = ferrotype::get_output_dir();
#[cfg(feature = "dot_snapshots")]
assert_eq!(dir, ".snapshots");
#[cfg(not(feature = "dot_snapshots"))]
assert_eq!(dir, "snapshots");
}
#[test]
fn test_typical_workflow() {
let mut snapshot = Ferrotype::new();
snapshot.set_filter_memory_addresses(true);
snapshot.add("Input", "Hello, world!".to_string());
snapshot.add_debug("Data Structure", vec!["item1", "item2", "item3"]);
#[cfg(feature = "hex")]
snapshot.add_hex("Binary", b"Hello");
ferrotype::assert!(snapshot);
}