|
| 1 | +require_relative 'test_helper' |
| 2 | + |
| 3 | +Java::Monkstone::JRLibrary.new.load(JRuby.runtime, false) |
| 4 | +# method tests |
| 5 | +class NoiseTest < Minitest::Test |
| 6 | + include FastNoise |
| 7 | + |
| 8 | + VALS = [0.4, 0.5, 4, 5].freeze |
| 9 | + |
| 10 | + def test_noise1d |
| 11 | + assert self.respond_to? :noise |
| 12 | + result = VALS.map { |x| noise(x) } |
| 13 | + assert result.all? { |x| (-1.0..1.0).include?(x) } |
| 14 | + assert VALS.length == result.uniq.length |
| 15 | + end |
| 16 | + |
| 17 | + def test_noise2d |
| 18 | + result = VALS.map { |x| noise(x, Math.sin(x)) } |
| 19 | + assert result.all? { |x| (-1.0..1.0).include?(x) } |
| 20 | + assert VALS.length == result.uniq.length |
| 21 | + end |
| 22 | + |
| 23 | + def test_noise3d |
| 24 | + result = VALS.map { |x| noise(x, Math.sin(x), Math.cos(x)) } |
| 25 | + assert result.all? { |x| (-1.0..1.0).include?(x) } |
| 26 | + assert VALS.length == result.uniq.length |
| 27 | + end |
| 28 | + |
| 29 | + def test_noise4d |
| 30 | + result = VALS.map { |x| noise(x, rand, Math.sin(x), Math.cos(x)) } |
| 31 | + assert result.all? { |x| (-1.0..1.0).include?(x) } |
| 32 | + assert VALS.length == result.uniq.length |
| 33 | + end |
| 34 | + |
| 35 | + def test_tnoise2d |
| 36 | + result = VALS.map { |x| tnoise(x, Math.sin(x)) } |
| 37 | + assert result.all? { |x| (-1.0..1.0).include?(x) } |
| 38 | + assert VALS.length == result.uniq.length |
| 39 | + end |
| 40 | + |
| 41 | + def test_tnoise3d |
| 42 | + result = VALS.map { |x| tnoise(x, Math.sin(x), Math.cos(x)) } |
| 43 | + assert result.all? { |x| (-1.0..1.0).include?(x) } |
| 44 | + assert VALS.length == result.uniq.length |
| 45 | + end |
| 46 | + |
| 47 | + def test_tnoise4d |
| 48 | + result = VALS.map { |x| tnoise(x, rand, Math.sin(x), Math.cos(x)) } |
| 49 | + assert result.all? { |x| (-1.0..1.0).include?(x) } |
| 50 | + assert VALS.length == result.uniq.length |
| 51 | + end |
| 52 | +end |
0 commit comments