quantrs2_tytan/testing_framework/
mod.rs

1//! Automated testing framework for quantum optimization.
2//!
3//! This module provides comprehensive testing tools for QUBO problems,
4//! including test case generation, validation, and benchmarking.
5
6#![allow(dead_code)]
7
8mod config;
9mod framework;
10mod generators;
11mod reports;
12mod results;
13mod types;
14mod validators;
15
16// Re-export all public types
17pub use config::*;
18pub use framework::*;
19pub use generators::*;
20pub use reports::*;
21pub use results::*;
22pub use types::*;
23pub use validators::*;
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28    use crate::sampler::SASampler;
29    use std::collections::HashMap;
30    use std::time::Duration;
31
32    #[test]
33    #[ignore]
34    fn test_testing_framework() {
35        let config = TestConfig {
36            seed: Some(42),
37            cases_per_category: 5,
38            problem_sizes: vec![5, 10],
39            samplers: vec![SamplerConfig {
40                name: "SA".to_string(),
41                num_samples: 100,
42                parameters: HashMap::new(),
43            }],
44            timeout: Duration::from_secs(10),
45            validation: ValidationConfig {
46                check_constraints: true,
47                check_objective: true,
48                statistical_tests: false,
49                tolerance: 1e-6,
50                min_quality: 0.0,
51            },
52            output: OutputConfig {
53                generate_report: true,
54                format: ReportFormat::Text,
55                output_dir: "/tmp".to_string(),
56                verbosity: VerbosityLevel::Info,
57            },
58        };
59
60        let mut framework = TestingFramework::new(config);
61
62        // Add test categories
63        framework.add_category(TestCategory {
64            name: "Graph Problems".to_string(),
65            description: "Graph-based optimization problems".to_string(),
66            problem_types: vec![ProblemType::MaxCut, ProblemType::GraphColoring],
67            difficulties: vec![Difficulty::Easy, Difficulty::Medium],
68            tags: vec!["graph".to_string()],
69        });
70
71        // Generate test suite
72        let result = framework.generate_suite();
73        assert!(result.is_ok());
74        assert!(!framework.suite.test_cases.is_empty());
75
76        // Run tests
77        let sampler = SASampler::new(Some(42));
78        let result = framework.run_suite(&sampler);
79        assert!(result.is_ok());
80
81        // Check results
82        assert!(framework.results.summary.total_tests > 0);
83        assert!(framework.results.summary.success_rate >= 0.0);
84
85        // Generate report
86        let report = framework.generate_report();
87        assert!(report.is_ok());
88    }
89}