Files
mtgodot-poc/extension/tests/water_depth_test.cpp
T

18 lines
746 B
C++

#include "water_depth.h"
#include <cassert>
#include <cstdio>
#include <limits>
#include <initializer_list>
int main() {
for (double scale : {0.25, 0.5, 1.0, 2.0}) {
assert(mtgodot::water_depth_alpha(-1, scale) == 0);
assert(mtgodot::water_depth_alpha(0, scale) == 0);
assert(std::abs(mtgodot::water_depth_alpha(100 * scale, scale) - 0.25) < 1e-6);
assert(std::abs(mtgodot::water_depth_alpha(320 * scale, scale) - 0.8) < 1e-6);
assert(std::abs(mtgodot::water_depth_alpha(1000 * scale, scale) - 0.8) < 1e-6);
}
assert(mtgodot::water_depth_alpha(100, 0) == 0);
assert(mtgodot::water_depth_alpha(std::numeric_limits<double>::quiet_NaN(), 1) == 0);
std::puts("PASS: water depth reference (raw depth, shoreline, cap, height scale)");
}