summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2020-04-25 12:54:45 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2020-04-25 12:54:45 +0200
commit25b143c76cb87fcd95b15bff3a4ae619b2cbb98b (patch)
treeb97bcb405e83b0dd8c91e964ec30ae340fdf8cfa /src
parente4c45796cf94e8df70d6859d5f891acf8ee38fca (diff)
Improve asserts in src/powermap.cc
Diffstat (limited to 'src')
-rw-r--r--src/powermap.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/powermap.cc b/src/powermap.cc
index db1eafc..52d52ef 100644
--- a/src/powermap.cc
+++ b/src/powermap.cc
@@ -62,22 +62,28 @@ Powermap::Powermap()
Power Powermap::map(Power in)
{
+ assert(in >= 0. && in <= 1.);
+
if (spline_needs_update) {
updateSpline();
}
+ Power out;
if (in < fixed[0].in) {
- return shelf ? fixed[0].out : computeValue(in, {0.,0.}, fixed[0], m[0], m[1]);
+ out = shelf ? fixed[0].out : computeValue(in, {0.,0.}, fixed[0], m[0], m[1]);
}
else if (in < fixed[1].in) {
- return computeValue(in, fixed[0], fixed[1], m[1], m[2]);
+ out = computeValue(in, fixed[0], fixed[1], m[1], m[2]);
}
else if (in < fixed[2].in) {
- return computeValue(in, fixed[1], fixed[2], m[2], m[3]);
+ out = computeValue(in, fixed[1], fixed[2], m[2], m[3]);
}
else { // in >= fixed[2].in
- return shelf ? fixed[2].out : computeValue(in, fixed[2], {1.,1.}, m[3], m[4]);
+ out = shelf ? fixed[2].out : computeValue(in, fixed[2], {1.,1.}, m[3], m[4]);
}
+
+ assert(out >= 0. && out <= 1.);
+ return out;
}
void Powermap::reset()