Files
Entropyk/crates/entropyk/tests/multi_circuit_builder.rs
Sepehr ab5dc7e568 chore: remove BMAD framework files and IDE configuration artifacts
Clean up unused BMAD workflow, agent, and command files across all IDE
configurations (.agent, .clinerules, .cursor, .gemini, .github, .kilocode,
.opencode) and internal module files (_bmad/bmb, _bmad/bmm).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-25 15:01:09 +02:00

65 lines
1.8 KiB
Rust

//! Integration tests for SystemBuilder multi-circuit API (Story 13-1).
//!
//! Verifies that a minimal two-circuit system can be built via the builder,
//! finalized, and exposes the expected circuit topology.
use entropyk::{CircuitId, SystemBuilder};
use entropyk_components::{
Component, ComponentError, JacobianBuilder, ResidualVector,
};
struct MockComponent {
n_eqs: usize,
}
impl Component for MockComponent {
fn compute_residuals(
&self,
_state: &[f64],
_residuals: &mut ResidualVector,
) -> Result<(), ComponentError> {
Ok(())
}
fn jacobian_entries(
&self,
_state: &[f64],
_jacobian: &mut JacobianBuilder,
) -> Result<(), ComponentError> {
Ok(())
}
fn n_equations(&self) -> usize {
self.n_eqs
}
fn get_ports(&self) -> &[entropyk_components::ConnectedPort] {
&[]
}
}
#[test]
fn test_builder_two_circuits_build_and_finalize() {
let system = SystemBuilder::new()
.component_in_circuit("a", Box::new(MockComponent { n_eqs: 1 }), CircuitId::ZERO)
.unwrap()
.component_in_circuit("b", Box::new(MockComponent { n_eqs: 1 }), CircuitId::ZERO)
.unwrap()
.component_in_circuit("c", Box::new(MockComponent { n_eqs: 1 }), CircuitId(1))
.unwrap()
.component_in_circuit("d", Box::new(MockComponent { n_eqs: 1 }), CircuitId(1))
.unwrap()
.edge("a", "b")
.unwrap()
.edge("c", "d")
.unwrap()
.build()
.expect("build should succeed");
assert_eq!(system.circuit_count(), 2);
assert_eq!(system.circuit_nodes(CircuitId::ZERO).count(), 2);
assert_eq!(system.circuit_nodes(CircuitId(1)).count(), 2);
assert_eq!(system.node_count(), 4);
assert_eq!(system.edge_count(), 2);
}