diff --git a/screenshot-tests/test-curves.cpp b/screenshot-tests/test-curves.cpp index beaa236..baf3e17 100644 --- a/screenshot-tests/test-curves.cpp +++ b/screenshot-tests/test-curves.cpp @@ -6,49 +6,51 @@ using namespace Pyro; TEST_CASE("Test curvepoint", "[shapes]") { - std::filesystem::path filename = "curve_curvepoints.png"; - -size(400,400); - -nofill(); -curve(20, 104, 20, 104, 292, 96, 292, 244); -curve(20, 104, 292, 96, 292, 244, 60, 260); - -fill(255); -ellipsemode(CENTER); -int steps = 6; -for (int i = 0; i <= steps; i++) { - float t = i / float(steps); - float x = curvepoint(20.f, 20.f, 292.f, 292.f, t); - float y = curvepoint(104.f, 104.f, 96.f, 244.f, t); - ellipse(x, y, 10, 10); - x = curvepoint(20, 292, 292, 60, t); - y = curvepoint(104, 96, 244, 260, t); - ellipse(x, y, 10, 10); + std::filesystem::path filename = "curve_curvepoints.png"; + + size(400, 400); + + nofill(); + curve(20, 104, 20, 104, 292, 96, 292, 244); + curve(20, 104, 292, 96, 292, 244, 60, 260); + + fill(255); + ellipsemode(CENTER); + int steps = 6; + for (int i = 0; i <= steps; i++) + { + float t = i / float(steps); + float x = curvepoint(20.f, 20.f, 292.f, 292.f, t); + float y = curvepoint(104.f, 104.f, 96.f, 244.f, t); + ellipse(x, y, 10, 10); + x = curvepoint(20, 292, 292, 60, t); + y = curvepoint(104, 96, 244, 260, t); + ellipse(x, y, 10, 10); + } + + save(current_folder / filename); + + CHECK_THAT(current_folder / filename, LooksLike(actual_folder / filename)); } - save(current_folder / filename); - - CHECK_THAT(current_folder / filename, LooksLike(actual_folder / filename)); - -} - -TEST_CASE("Test beierpoint", "[sahpes]") { - std::filesystem::path filename = "curve_bezierpoint.png"; - - size(400,400); -nofill(); -bezier(340, 80, 40, 40, 360, 360, 60, 320); -fill(255); -ellipsemode(CENTER); -int steps = 10; -for (int i = 0; i <= steps; i++) { - float t = i / float(steps); - float x = bezierpoint(340, 40, 360, 60, t); - float y = bezierpoint(80, 40, 360, 320, t); - ellipse(x, y, 10, 10); +TEST_CASE("Test beierpoint", "[shapes]") +{ + std::filesystem::path filename = "curve_bezierpoint.png"; + + size(400, 400); + nofill(); + bezier(340, 80, 40, 40, 360, 360, 60, 320); + fill(255); + ellipsemode(CENTER); + int steps = 10; + for (int i = 0; i <= steps; i++) + { + float t = i / float(steps); + float x = bezierpoint(340, 40, 360, 60, t); + float y = bezierpoint(80, 40, 360, 320, t); + ellipse(x, y, 10, 10); + } + save(current_folder / filename); + + CHECK_THAT(current_folder / filename, LooksLike(actual_folder / filename)); } - save(current_folder / filename); - - CHECK_THAT(current_folder / filename, LooksLike(actual_folder / filename)); -} \ No newline at end of file diff --git a/tests/meson.build b/tests/meson.build index 7feca23..37b60f1 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -7,6 +7,7 @@ test_sources = [ 'test-noise.cpp', 'test-pyro.cpp', 'test-vector.cpp', + 'test-runner.cpp', 'test-string.cpp', 'test-transformer2d.cpp', 'test-shape.cpp'] diff --git a/tests/test-runner.cpp b/tests/test-runner.cpp new file mode 100644 index 0000000..6b23b49 --- /dev/null +++ b/tests/test-runner.cpp @@ -0,0 +1,26 @@ + +#include + +#include "pyro/pyro.h" +#include "pyro/runner.h" +#include + +using namespace Pyro; + +int test_setup_result{0}; + +void test_setup_setup() +{ + test_setup_result = 1; +} + +void test_setup_draw() +{ + quit(); +} + +TEST_CASE("Test the realtime runner", "[runner]") +{ + run(test_setup_setup, test_setup_draw, true); + REQUIRE(test_setup_result == 1); +}