diff --git a/.gitignore b/.gitignore index 95fecc0..3c06acb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ *.sh *-e *.txt +*.svg +*.dot diff --git a/src/domain/view/owned.rs b/src/domain/view/owned.rs index 54136db..a3d281b 100644 --- a/src/domain/view/owned.rs +++ b/src/domain/view/owned.rs @@ -41,3 +41,31 @@ impl DomainView self.buffer[index] } } + +#[cfg(test)] +mod unit_tests { + use super::*; + + fn mock_solver< + const GRID_DIMENSION: usize, + DomainType: DomainView, + >( + input: &mut DomainType, + output: &mut DomainType, + ) { + std::mem::swap(input, output); + } + + #[test] + fn swap_test() { + let mut a = OwnedDomain::new(AABB::new(matrix![0, 1])); + let mut b = OwnedDomain::new(AABB::new(matrix![0, 1])); + let a_ptr = a.buffer().as_ptr(); + let b_ptr = b.buffer().as_ptr(); + mock_solver(&mut a, &mut b); + let sa_ptr = a.buffer().as_ptr(); + let sb_ptr = b.buffer().as_ptr(); + assert_eq!(a_ptr, sb_ptr); + assert_eq!(b_ptr, sa_ptr); + } +}