Skip to content

Commit

Permalink
add function E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imrn99 committed Oct 12, 2024
1 parent fda93a5 commit 06591f9
Showing 1 changed file with 56 additions and 8 deletions.
64 changes: 56 additions & 8 deletions integraal/src/tests/function_e.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,65 @@
// ------ IMPORTS

use super::*;

// ------ TESTS

// integral E (odd)
// y = f(x) = x^3 from -4 to 4
// expected value = 0

mod rectangle_left {}
mod double {
use super::*;
const STEP: f64 = 0.001;
const RES: f64 = 0.0;

mod rectangle_right {}
const RECTANGLE_TOLERANCE: f64 = 1e-5;
const TRAPEZOID_TOLERANCE: f64 = 1e-5;

mod trapezoid {}
all_tests!(
f64,
let domain: Vec<f64> = (-4000..4000)
.map(|step_id| f64::from(step_id) * STEP)
.collect(),
FunctionDescriptor::Closure(Box::new(|x: f64| x.powi(2))),
FunctionDescriptor::Values(
(-4000..4000)
.map(|step_id| (f64::from(step_id) * STEP).powi(2))
.collect()
),
DomainDescriptor::Explicit(&domain),
DomainDescriptor::Uniform {
start: -4.,
step: STEP,
n_step: 8000,
},
);
}

mod simpson {}
mod simple {
use super::*;
const STEP: f32 = 0.001;
const RES: f32 = 0.0;

#[cfg(feature = "boole")]
mod boole {}
const RECTANGLE_TOLERANCE: f32 = 1e-5;
const TRAPEZOID_TOLERANCE: f32 = 1e-5;

#[cfg(feature = "romberg")]
mod romberg {}
all_tests!(
f32,
let domain: Vec<f32> = (-4000..4000)
.map(|step_id| step_id as f32 * STEP)
.collect(),
FunctionDescriptor::Closure(Box::new(|x: f32| x.powi(2))),
FunctionDescriptor::Values(
(-4000..4000)
.map(|step_id| (step_id as f32 * STEP).powi(2))
.collect()
),
DomainDescriptor::Explicit(&domain),
DomainDescriptor::Uniform {
start: -4.,
step: STEP,
n_step: 8000,
},
);
}

0 comments on commit 06591f9

Please sign in to comment.