-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathperlin_test.go
59 lines (52 loc) · 1.11 KB
/
perlin_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package perlin
import (
"testing"
)
const (
seed = 123
)
func Test_PerlinNoise1D(t *testing.T) {
expected := 0.0
p := NewPerlin(2, 2, 3, seed)
noise := p.Noise1D(10)
if noise != expected {
t.Fail()
t.Logf("Wrong node result: given: %f, expected: %f", noise, expected)
}
}
func Test_PerlinNoise2D(t *testing.T) {
expected := 0.0
p := NewPerlin(2, 2, 3, seed)
noise := p.Noise2D(10, 10)
if noise != expected {
t.Fail()
t.Logf("Wrong node result: given: %f, expected: %f", noise, expected)
}
}
func Test_PerlinNoise3D(t *testing.T) {
expected := 0.0
p := NewPerlin(2, 2, 3, seed)
noise := p.Noise3D(10, 10, 10)
if noise != expected {
t.Fail()
t.Logf("Wrong node result: given: %f, expected: %f", noise, expected)
}
}
func Benchmark_PerlinNoise1D(b *testing.B) {
p := NewPerlin(2, 2, 3, seed)
for n := 0; n < b.N; n++ {
p.Noise1D(10)
}
}
func Benchmark_PerlinNoise2D(b *testing.B) {
p := NewPerlin(2, 2, 3, seed)
for n := 0; n < b.N; n++ {
p.Noise2D(10, 10)
}
}
func Benchmark_PerlinNoise3D(b *testing.B) {
p := NewPerlin(2, 2, 3, seed)
for n := 0; n < b.N; n++ {
p.Noise3D(10, 10, 10)
}
}