paysages3d/src/tests/NoiseFunctionSimplex_Test.cpp
Michaël Lemaire 959f0ddf8f Updated NoiseNode to use FractalNoise instead of NoiseGenerator
Also fixed the range returned by NoiseFunctionSimplex (when
used by FractalNoise), and added a test to validate it.
2016-01-03 20:22:06 +01:00

24 lines
713 B
C++

#include "BaseTestCase.h"
#include "NoiseFunctionSimplex.h"
#include "RandomGenerator.h"
TEST(NoiseFunctionSimplex, range) {
NoiseFunctionSimplex noise;
RandomGenerator random(17124);
for (int i = 0; i < 100000; i++) {
double x = random.genDouble() - 0.5;
double y = random.genDouble() - 0.5;
double z = random.genDouble() - 0.5;
double scale = random.genDouble() * 5.0 + 0.1;
// TODO Test repartition and filling
double val2 = noise.get2d(1.0, x * scale, y * scale);
EXPECT_DOUBLE_IN_RANGE(val2, -0.5, 0.5);
double val3 = noise.get3d(1.0, x * scale, y * scale, z * scale);
EXPECT_DOUBLE_IN_RANGE(val3, -0.5, 0.5);
}
}