summaryrefslogtreecommitdiff
path: root/src/value-map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/value-map.cpp')
-rw-r--r--src/value-map.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/value-map.cpp b/src/value-map.cpp
index 8a547c4..2627ed3 100644
--- a/src/value-map.cpp
+++ b/src/value-map.cpp
@@ -5,9 +5,16 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
#include "value-map.hpp"
+#include <cmath>
ValueMap::ValueMap(double lower, double upper, const std::string& unit) : lower_(lower), upper_(upper), unit_(unit)
{
+ if (std::isnan(lower) || std::isnan(upper) || std::isinf(lower) || std::isinf(upper)) {
+ throw std::runtime_error("bounds cannot be nan or inf");
+ }
+ if (lower > upper) {
+ throw std::runtime_error("lower bound cannot exceed upper bound");
+ }
}
std::string
@@ -71,4 +78,5 @@ RealWindow DecibelValueMap::Map(const RealWindow &input)
std::string DecibelValueMap::GetUnit() const
{
return "dB" + unit_;
-} \ No newline at end of file
+}
+