From dee3c81c676a24115413b2563fc9c39a289c876f Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Sat, 30 Jul 2022 20:25:09 -0500 Subject: [PATCH] fuzzing updated --- tests/fuzz_image_draw.nim | 20 ++++++++------------ tests/fuzz_image_draw_smooth.nim | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 tests/fuzz_image_draw_smooth.nim diff --git a/tests/fuzz_image_draw.nim b/tests/fuzz_image_draw.nim index 0a80cd8..d8d43b8 100644 --- a/tests/fuzz_image_draw.nim +++ b/tests/fuzz_image_draw.nim @@ -2,30 +2,26 @@ import pixie, random randomize() -for i in 0 ..< 25: +for i in 0 ..< 250: let a = newImage(rand(1 .. 20), rand(1 .. 20)) for j in 0 ..< 25: let b = newImage(rand(1 .. 20), rand(1 .. 20)) - let - translation = vec2(rand(25.0), rand(25.0)) - vec2(5, 5) - rotation = rand(2 * PI).float32 + let translation = vec2(rand(-25..25).float32, rand(-25..25).float32) - echo a, " ", b, " ", translation, " ", rotation + echo a, " ", b, " ", translation a.draw(b, translate(vec2(translation.x.trunc, translation.y.trunc))) - a.draw(b, translate(translation) * rotate(rotation)) + a.draw(b, translate(translation)) -for i in 0 ..< 25: +for i in 0 ..< 250: let a = newImage(rand(1 .. 2000), rand(1 .. 2000)) for j in 0 ..< 25: let b = newImage(rand(1 .. 1000), rand(1 .. 1000)) - let - translation = vec2(rand(2500.0), rand(2500.0)) - vec2(500, 500) - rotation = rand(2 * PI).float32 + let translation = vec2(rand(-2500..2500).float32, rand(-2500..2500).float32) - echo a, " ", b, " ", translation, " ", rotation + echo a, " ", b, " ", translation a.draw(b, translate(vec2(translation.x.trunc, translation.y.trunc))) - a.draw(b, translate(translation) * rotate(rotation)) + a.draw(b, translate(translation)) diff --git a/tests/fuzz_image_draw_smooth.nim b/tests/fuzz_image_draw_smooth.nim new file mode 100644 index 0000000..0a80cd8 --- /dev/null +++ b/tests/fuzz_image_draw_smooth.nim @@ -0,0 +1,31 @@ +import pixie, random + +randomize() + +for i in 0 ..< 25: + let a = newImage(rand(1 .. 20), rand(1 .. 20)) + for j in 0 ..< 25: + let b = newImage(rand(1 .. 20), rand(1 .. 20)) + + let + translation = vec2(rand(25.0), rand(25.0)) - vec2(5, 5) + rotation = rand(2 * PI).float32 + + echo a, " ", b, " ", translation, " ", rotation + + a.draw(b, translate(vec2(translation.x.trunc, translation.y.trunc))) + a.draw(b, translate(translation) * rotate(rotation)) + +for i in 0 ..< 25: + let a = newImage(rand(1 .. 2000), rand(1 .. 2000)) + for j in 0 ..< 25: + let b = newImage(rand(1 .. 1000), rand(1 .. 1000)) + + let + translation = vec2(rand(2500.0), rand(2500.0)) - vec2(500, 500) + rotation = rand(2 * PI).float32 + + echo a, " ", b, " ", translation, " ", rotation + + a.draw(b, translate(vec2(translation.x.trunc, translation.y.trunc))) + a.draw(b, translate(translation) * rotate(rotation))