use dynpatch::prelude::*;
use dynpatch_interface::compute_type_hash;
#[test]
fn test_initialization() {
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);
assert_eq!(hash1, hash2);
assert_ne!(hash1, hash3);
assert_ne!(hash1, hash4);
}
#[test]
fn test_no_active_patch_initially() {
assert!(active_patch_info().is_none());
}
#[test]
fn test_empty_history_initially() {
let hist = history();
assert_eq!(hist.len(), 0);
}
#[cfg(feature = "watcher")]
#[test]
fn test_watcher_module_exists() {
use dynpatch::config::HotConfig;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize)]
struct TestCfg {
value: i32,
}
impl HotConfig for TestCfg {}
}