76 lines
2.3 KiB
Rust
76 lines
2.3 KiB
Rust
//! Validation test for DPM-Solver++ API without full compilation
|
|
//! This allows us to verify the API design is sound even if dependencies have issues
|
|
|
|
use crate::dpm_solver_pp::{DPMSolverConfig, DPMSolverPP, DPMSolverStats, PredictionType};
|
|
|
|
#[cfg(test)]
|
|
mod validation_tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_dpm_solver_config_defaults() {
|
|
let config = DPMSolverConfig::default();
|
|
|
|
assert_eq!(config.order, 2);
|
|
assert!(!config.adaptive_order);
|
|
assert!(!config.corrector);
|
|
assert_eq!(config.atol, 1e-3);
|
|
assert_eq!(config.rtol, 1e-2);
|
|
assert_eq!(config.max_order, 3);
|
|
assert_eq!(config.prediction_type, PredictionType::Noise);
|
|
assert!(config.multistep);
|
|
}
|
|
|
|
#[test]
|
|
fn test_prediction_type_equality() {
|
|
assert_eq!(PredictionType::Noise, PredictionType::Noise);
|
|
assert_eq!(PredictionType::Data, PredictionType::Data);
|
|
assert_ne!(PredictionType::Noise, PredictionType::Data);
|
|
}
|
|
|
|
#[test]
|
|
fn test_stats_default() {
|
|
let stats = DPMSolverStats::default();
|
|
|
|
assert_eq!(stats.nfe, 0);
|
|
assert_eq!(stats.corrector_steps, 0);
|
|
assert_eq!(stats.order_adjustments, 0);
|
|
assert_eq!(stats.avg_error, 0.0);
|
|
assert_eq!(stats.max_error, 0.0);
|
|
}
|
|
|
|
#[test]
|
|
fn test_custom_config_creation() {
|
|
let config = DPMSolverConfig {
|
|
order: 3,
|
|
adaptive_order: true,
|
|
corrector: true,
|
|
atol: 1e-4,
|
|
rtol: 1e-3,
|
|
max_order: 3,
|
|
prediction_type: PredictionType::Data,
|
|
multistep: false,
|
|
};
|
|
|
|
assert_eq!(config.order, 3);
|
|
assert!(config.adaptive_order);
|
|
assert!(config.corrector);
|
|
assert_eq!(config.atol, 1e-4);
|
|
assert_eq!(config.rtol, 1e-3);
|
|
assert_eq!(config.max_order, 3);
|
|
assert_eq!(config.prediction_type, PredictionType::Data);
|
|
assert!(!config.multistep);
|
|
}
|
|
|
|
#[test]
|
|
fn test_config_clone() {
|
|
let config1 = DPMSolverConfig::default();
|
|
let config2 = config1.clone();
|
|
|
|
assert_eq!(config1.order, config2.order);
|
|
assert_eq!(config1.adaptive_order, config2.adaptive_order);
|
|
assert_eq!(config1.corrector, config2.corrector);
|
|
assert_eq!(config1.prediction_type, config2.prediction_type);
|
|
}
|
|
}
|