diff --git a/src/smolscale-generic.c b/src/smolscale-generic.c index bc66456..8505dd3 100644 --- a/src/smolscale-generic.c +++ b/src/smolscale-generic.c @@ -1635,8 +1635,8 @@ scale_horizontal (const SmolScaleCtx *scale_ctx, row_in = (const char *) vertical_ctx->in_aligned; } - scale_ctx->unpack_row_func ((const uint32_t *) row_in, - unpacked_in, + scale_ctx->unpack_row_func ((const void *) row_in, + (void *)unpacked_in, scale_ctx->width_in); scale_ctx->hfilter_func (scale_ctx, unpacked_in, @@ -2316,7 +2316,7 @@ scale_outrow_copy (const SmolScaleCtx *scale_ctx, inrow_ofs_to_pointer (scale_ctx, row_index), vertical_ctx->parts_row [0]); - scale_ctx->pack_row_func (vertical_ctx->parts_row [0], row_out, scale_ctx->width_out); + scale_ctx->pack_row_func ((const void *)(vertical_ctx->parts_row [0]), (void *)row_out, scale_ctx->width_out); } /* --------------- * diff --git a/tests/testthat/test-smolscale.R b/tests/testthat/test-smolscale.R new file mode 100644 index 0000000..83b82b4 --- /dev/null +++ b/tests/testthat/test-smolscale.R @@ -0,0 +1,34 @@ + +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Exercise the library toensure there are no memory errors when +# used with R. +# Any such errors will hopefully be picked up the test builds for: +# clang-asan, rchk, valgrind +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +test_that("smolscale works", { + + nr <- nr_duplicate(deer_sprites[[1]]) + for (w in c(10, 100, 400, 1000)) { + expect_no_error({ + nr_resize(nr, w, w) + }) + } + + + orders <- c('RGBA', 'BGRA', 'ARGB', 'ABGR') + + + for (src_order in orders) { + for (target_order in orders) { + for (src_pm_alpha in c(TRUE, FALSE)) { + for (target_pm_alpha in c(TRUE, FALSE)) { + expect_no_error({ + nr <- nr_duplicate(deer_sprites[[1]]) + nr_swizzle(nr, order = src_order, pm_alpha = src_pm_alpha, + target_order = target_order, target_pm_alpha = target_pm_alpha) + }) + } + } + } + } +})