Skip to content

Commit

Permalink
Moved tests into separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzuchun committed Nov 27, 2024
1 parent 6d1f09f commit b355c90
Show file tree
Hide file tree
Showing 16 changed files with 312 additions and 294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,5 @@ where
}
}

crate::test_model_derivative!(
Constant::<f64>,
Constant { c: 5.0 },
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);
#[cfg(test)]
mod tests;
12 changes: 12 additions & 0 deletions nacfahi/src/models/basic/constant/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
crate::test_model_derivative!(
Constant::<f64>,
Constant { c: 5.0 },
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,5 @@ where
}
}

crate::test_model_derivative!(
Exponent::<f64>,
Exponent { a: -2.0, b: -10.0 },
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);
#[cfg(test)]
mod tests;
12 changes: 12 additions & 0 deletions nacfahi/src/models/basic/exponent/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
crate::test_model_derivative!(
Exponent::<f64>,
Exponent { a: -2.0, b: -10.0 },
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,5 @@ where
}
}

crate::test_model_derivative!(
Linear::<f64>,
Linear { a: 5.0, b: -4.0 },
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);
#[cfg(test)]
mod tests;
12 changes: 12 additions & 0 deletions nacfahi/src/models/basic/linear/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
crate::test_model_derivative!(
Linear::<f64>,
Linear { a: 5.0, b: -4.0 },
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,5 @@ where
}
}

crate::test_model_derivative!(
Polynomial::<5, f64>,
Polynomial {
params: [-4.0, -15.0, -2.0, 0.7, -0.01]
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);
#[cfg(test)]
mod tests;
14 changes: 14 additions & 0 deletions nacfahi/src/models/basic/polynomial/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
crate::test_model_derivative!(
Polynomial::<5, f64>,
Polynomial {
params: [-4.0, -15.0, -2.0, 0.7, -0.01]
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);
Original file line number Diff line number Diff line change
Expand Up @@ -105,123 +105,5 @@ impl<Inner: FitModel> CompositionExt for Inner {
}
}

crate::test_model_derivative!(
exponent_gaussian,
Composition::<Exponent<f64>, Gaussian<f64>>,
Composition {
inner: Exponent { a: 5.0, b: -0.1 },
outer: Gaussian::<_> {
a: -2.0,
sigma: 0.4,
x_c: 3.0,
}
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);

crate::test_model_derivative!(
gaussian_exponent,
Composition::<Gaussian<f64>, Exponent<f64>>,
Composition {
inner: Gaussian::<_> {
a: -2.0,
sigma: 0.4,
x_c: 3.0,
},
outer: Exponent { a: 5.0, b: -0.1 },
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);

crate::test_model_derivative!(
exponent_constant,
Composition::<Exponent<f64>, Constant<f64>>,
Composition {
inner: Exponent { a: 5.0, b: -0.1 },
outer: Constant { c: -4.0 },
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);

crate::test_model_derivative!(
exponent_linear,
Composition::<Exponent<f64>, Linear<f64>>,
Composition {
inner: Exponent { a: -5.0, b: -3.11 },
outer: Linear { a: 5.0, b: -0.1 },
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);

crate::test_model_derivative!(
constant_gassian,
Composition::<Constant<f64>, Gaussian<f64>>,
Composition {
inner: Constant { c: 4.0 },
outer: Gaussian::<_> {
a: -5.0,
sigma: 3.4,
x_c: -2.1213
},
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);

crate::test_model_derivative!(
gaussian_linear,
Composition::<Gaussian<f64>, Linear<f64>>,
Composition {
inner: Gaussian::<_> {
a: -5.0,
sigma: 3.4,
x_c: -2.1213
},
outer: Linear {
a: -0.2421,
b: 4.321
},
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);
#[cfg(test)]
mod tests;
120 changes: 120 additions & 0 deletions nacfahi/src/models/utility/composition/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
crate::test_model_derivative!(
exponent_gaussian,
Composition::<Exponent<f64>, Gaussian<f64>>,
Composition {
inner: Exponent { a: 5.0, b: -0.1 },
outer: Gaussian::<_> {
a: -2.0,
sigma: 0.4,
x_c: 3.0,
}
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);

crate::test_model_derivative!(
gaussian_exponent,
Composition::<Gaussian<f64>, Exponent<f64>>,
Composition {
inner: Gaussian::<_> {
a: -2.0,
sigma: 0.4,
x_c: 3.0,
},
outer: Exponent { a: 5.0, b: -0.1 },
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);

crate::test_model_derivative!(
exponent_constant,
Composition::<Exponent<f64>, Constant<f64>>,
Composition {
inner: Exponent { a: 5.0, b: -0.1 },
outer: Constant { c: -4.0 },
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);

crate::test_model_derivative!(
exponent_linear,
Composition::<Exponent<f64>, Linear<f64>>,
Composition {
inner: Exponent { a: -5.0, b: -3.11 },
outer: Linear { a: 5.0, b: -0.1 },
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);

crate::test_model_derivative!(
constant_gassian,
Composition::<Constant<f64>, Gaussian<f64>>,
Composition {
inner: Constant { c: 4.0 },
outer: Gaussian::<_> {
a: -5.0,
sigma: 3.4,
x_c: -2.1213
},
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);

crate::test_model_derivative!(
gaussian_linear,
Composition::<Gaussian<f64>, Linear<f64>>,
Composition {
inner: Gaussian::<_> {
a: -5.0,
sigma: 3.4,
x_c: -2.1213
},
outer: Linear {
a: -0.2421,
b: 4.321
},
},
[
(0.0, -1.0),
(1.0, -4.0),
(2.0, -5.0),
(3.0, 6.0),
(4.0, 2.0),
(5.0, 2.5)
]
);
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ where
) -> Self::OwnedModel {
}
}

#[cfg(test)]
mod tests;
1 change: 1 addition & 0 deletions nacfahi/src/models/utility/fixed/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading

0 comments on commit b355c90

Please sign in to comment.