Skip to content

Commit

Permalink
attempt to fix an ASAN error. exercise smolscale usage in more test
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbutuseless committed Jun 23, 2024
1 parent 9f75fe9 commit 2090162
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/smolscale-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

/* --------------- *
Expand Down
34 changes: 34 additions & 0 deletions tests/testthat/test-smolscale.R
Original file line number Diff line number Diff line change
@@ -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)
})
}
}
}
}
})

0 comments on commit 2090162

Please sign in to comment.