dynpatch 0.1.0

Safe live code reloading for Rust - hot patch functions, services, and configs at runtime
Documentation
//! Integration tests for dynpatch

use dynpatch::prelude::*;
use dynpatch_interface::compute_type_hash;

#[test]
fn test_initialization() {
    // Should not panic
    init();
}

#[test]
fn test_version_operations() {
    let v1 = Version::new(1, 0, 0);
    let v2 = Version::new(1, 1, 0);
    let v3 = Version::new(2, 0, 0);
    
    assert!(v1.is_compatible(&v2));
    assert!(!v1.is_compatible(&v3));
    
    assert_eq!(v1.to_string(), "1.0.0");
    assert_eq!(v2.to_string(), "1.1.0");
}

#[test]
fn test_type_hash_consistency() {
    let hash1 = compute_type_hash("MyType", 8, 8);
    let hash2 = compute_type_hash("MyType", 8, 8);
    let hash3 = compute_type_hash("MyType", 16, 8);
    let hash4 = compute_type_hash("OtherType", 8, 8);
    
    // Same type and layout should produce same hash
    assert_eq!(hash1, hash2);
    
    // Different size should produce different hash
    assert_ne!(hash1, hash3);
    
    // Different name should produce different hash
    assert_ne!(hash1, hash4);
}

#[test]
fn test_no_active_patch_initially() {
    // After init, no patch should be active
    assert!(active_patch_info().is_none());
}

#[test]
fn test_empty_history_initially() {
    // Initially, history should be empty
    let hist = history();
    assert_eq!(hist.len(), 0);
}

#[cfg(feature = "watcher")]
#[test]
fn test_watcher_module_exists() {
    // Test that watcher module is accessible
    use dynpatch::config::HotConfig;
    use serde::{Deserialize, Serialize};
    
    #[derive(Debug, Clone, Deserialize, Serialize)]
    struct TestCfg {
        value: i32,
    }
    
    impl HotConfig for TestCfg {}
    
    // If this compiles, the module is properly exported
}