Skip to content

Commit

Permalink
Add back some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SallySoul committed Dec 29, 2024
1 parent 649d171 commit 8a20fd9
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/domain/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,49 @@ fn par_modify_access_impl<'a, const GRID_DIMENSION: usize>(
DomainChunk::new(offset, aabb, buffer_chunk)
})
}

#[cfg(test)]
mod unit_tests {
use super::*;

#[test]
fn par_set_subdomain_test() {
{
let chunk_size = 1;
let bounds = AABB::new(matrix![0, 9; 0, 9;]);
let mut domain = OwnedDomain::new(bounds);

let i_bounds = AABB::new(matrix![3, 7; 3, 7]);
let mut i_domain = OwnedDomain::new(i_bounds);
i_domain.par_set_values(|_| 1.0, chunk_size);

domain.par_set_subdomain(&i_domain, 2);

for c in domain.aabb().coord_iter() {
if i_bounds.contains(&c) {
assert_eq!(domain.view(&c), 1.0);
} else {
assert_eq!(domain.view(&c), 0.0);
}
}
}
}

#[test]
fn par_from_superset_test() {
{
let chunk_size = 1;
let bounds = AABB::new(matrix![0, 9; 0, 9;]);
let domain = OwnedDomain::new(bounds);

let i_bounds = AABB::new(matrix![3, 7; 3, 7]);
let mut i_domain = OwnedDomain::new(i_bounds);
i_domain.par_set_values(|_| 1.0, chunk_size);

i_domain.par_from_superset(&domain, 3);
for c in i_domain.aabb().coord_iter() {
assert_eq!(domain.view(&c), 0.0);
}
}
}
}

0 comments on commit 8a20fd9

Please sign in to comment.