diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2025-06-22 12:06:15 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-09-04 11:03:52 +0200 |
| commit | db328d2a861f5aedec900e44fbe1fd542b307afb (patch) | |
| tree | 2997dcaad33d99b9cd79b6681ca0c679f2c34a1b /samples/tests/lines.cpp | |
| parent | 0199cfcb86b384e888ddf01642b63f4a32e15894 (diff) | |
unified samples app in c++, unit testing wip
Diffstat (limited to 'samples/tests/lines.cpp')
| -rw-r--r-- | samples/tests/lines.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/samples/tests/lines.cpp b/samples/tests/lines.cpp new file mode 100644 index 0000000..624b290 --- /dev/null +++ b/samples/tests/lines.cpp @@ -0,0 +1,103 @@ +#include "VkvgTest.hpp" + +TEST(lines_horizontal) { + float w = (float)test->app->width; + float h = (float)test->app->height; + + VkvgContext ctx = vkvg_create(test->surf); + vkvg_clear(ctx); + + for (uint32_t i = 0; i < test->app->testSize; i++) { + randomize_color(ctx); + float x1 = w * rndf(); + float y1 = h * rndf(); + float v = 500.f * rndf(); + + vkvg_move_to(ctx, x1, y1); + vkvg_line_to(ctx, x1 + v, y1); + vkvg_stroke(ctx); + } + vkvg_destroy(ctx); +} +TEST(lines_vertical) { + float w = (float)test->app->width; + float h = (float)test->app->height; + + VkvgContext ctx = vkvg_create(test->surf); + vkvg_clear(ctx); + + for (uint32_t i = 0; i < test->app->testSize; i++) { + randomize_color(ctx); + float x1 = w * rndf(); + float y1 = h * rndf(); + float v = 500.f * rndf(); + + vkvg_move_to(ctx, x1, y1); + vkvg_line_to(ctx, x1, y1 + v); + vkvg_stroke(ctx); + } + vkvg_destroy(ctx); +} +TEST(lines_horzAndVert) { + float w = (float)test->app->width; + float h = (float)test->app->height; + + VkvgContext ctx = vkvg_create(test->surf); + vkvg_clear(ctx); + + for (uint32_t i = 0; i < test->app->testSize; i++) { + randomize_color(ctx); + + float x1 = w * rndf(); + float y1 = h * rndf(); + float x2 = (w * rndf()) + 1; + float y2 = (h * rndf()) + 1; + + vkvg_move_to(ctx, x1, y1); + vkvg_line_to(ctx, x2, y2); + vkvg_stroke(ctx); + } + vkvg_destroy(ctx); +} +TEST(lines_multilines) { + float w = (float)test->app->width; + float h = (float)test->app->height; + + VkvgContext ctx = vkvg_create(test->surf); + vkvg_clear(ctx); + + randomize_color(ctx); + + for (uint32_t i = 0; i < test->app->testSize; i++) { + + float x1 = w * rndf(); + float y1 = h * rndf(); + float x2 = (w * rndf()) + 1; + float y2 = (h * rndf()) + 1; + + vkvg_move_to(ctx, x1, y1); + vkvg_line_to(ctx, x2, y2); + } + vkvg_stroke(ctx); + vkvg_destroy(ctx); +} +TEST(lines_multi_segments) { + float w = (float)test->app->width; + float h = (float)test->app->height; + + VkvgContext ctx = vkvg_create(test->surf); + vkvg_clear(ctx); + + randomize_color(ctx); + float x1 = w * rndf(); + float y1 = h * rndf(); + vkvg_move_to(ctx, x1, y1); + + for (uint32_t i = 0; i < test->app->testSize; i++) { + x1 = w * rndf(); + y1 = h * rndf(); + vkvg_line_to(ctx, x1, y1); + } + vkvg_stroke(ctx); + vkvg_destroy(ctx); +} |