mirror of
https://github.com/jneug/zeichenmaschine.git
synced 2026-04-14 06:33:34 +02:00
Test für Noise-Klasse
This commit is contained in:
@@ -71,7 +71,7 @@ class ConstantsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void b() {
|
||||
void asBool() {
|
||||
assertTrue(Constants.asBool(true));
|
||||
assertFalse(Constants.asBool(false));
|
||||
assertTrue(Constants.asBool(1));
|
||||
@@ -128,4 +128,45 @@ class ConstantsTest {
|
||||
assertEquals(.8f, Math.abs(t/(t+f)), .01f);
|
||||
}
|
||||
|
||||
@Test
|
||||
void noise() {
|
||||
double lastNoise = -1.0;
|
||||
for( int i = 0; i < 100; i++ ) {
|
||||
double thisNoise = Constants.noise(i * 0.005);
|
||||
|
||||
assertInRange(thisNoise);
|
||||
assertNotEquals(lastNoise, thisNoise);
|
||||
assertEquals(thisNoise, Constants.noise(i * 0.005), 0.0001);
|
||||
|
||||
lastNoise = thisNoise;
|
||||
}
|
||||
|
||||
lastNoise = -1.0;
|
||||
for( int i = 0; i < 100; i++ ) {
|
||||
double thisNoise = Constants.noise(i * 0.005, 0.1);
|
||||
|
||||
assertInRange(thisNoise);
|
||||
assertNotEquals(lastNoise, thisNoise);
|
||||
assertEquals(thisNoise, Constants.noise(i * 0.005, 0.1), 0.0001);
|
||||
|
||||
lastNoise = thisNoise;
|
||||
}
|
||||
|
||||
lastNoise = -1.0;
|
||||
for( int i = 0; i < 100; i++ ) {
|
||||
double thisNoise = Constants.noise(i * 0.005, 5.5, 100.0/(i+1));
|
||||
|
||||
assertInRange(thisNoise);
|
||||
assertNotEquals(lastNoise, thisNoise);
|
||||
assertEquals(thisNoise, Constants.noise(i * 0.005, 5.5, 100.0/(i+1)), 0.0001);
|
||||
|
||||
lastNoise = thisNoise;
|
||||
}
|
||||
}
|
||||
|
||||
private void assertInRange( double d ) {
|
||||
assertFalse(Double.isNaN(d), "Noise value can't be NaN.");
|
||||
assertTrue(0.0 <= d && 1.0 >= d, "Noise should be in Range 0 to 1. Was <" + d + ">.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user