From 66847ff825e046511afe3e7955a7d809e49f8e69 Mon Sep 17 00:00:00 2001 From: "Nicholas R. Jankowski" Date: Fri, 5 Jul 2024 12:07:39 -0400 Subject: [PATCH] movslice: Add BISTs for base functionality. movslice.m: Add tests for all outputs for basic movslice function. Verify output class for slice index and center outputs. remove FIXME note requesting tests for functionality. --- scripts/signal/movslice.m | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/scripts/signal/movslice.m b/scripts/signal/movslice.m index 48ebb18a1d..190956989a 100644 --- a/scripts/signal/movslice.m +++ b/scripts/signal/movslice.m @@ -129,8 +129,36 @@ endfunction +%!assert (double (movslice (10, 2)), [1:9; 2:10]) +%!assert (double (movslice (10, 9)), [1:9; 2:10].') -## FIXME: Need functional BIST tests +%!test +%! [sl, c, cpre, cpost, win] = movslice (10, 4); +%! assert (double (sl), [1:7; 2:8; 3:9; 4:10]); +%! assert (double (c), 3:9); +%! assert (cpre, 1:2); +%! assert (cpost, 10); +%! assert (win, [-2:1:1].'); + +%!test +%! [sl, c, cpre, cpost, win] = movslice (10, 10); +%! assert (double (sl), [1:10].'); +%! assert (double (c), 6); +%! assert (cpre, 1:5); +%! assert (cpost, 7:10); +%! assert (win, [-5:1:4].'); + +## Verify uint output. Don't test uint64 due to excessive memory usage. +%!test +%! [sl, c] = movslice (10, 10); +%! assert (class (sl), "uint8"); +%! assert (class (c), "uint8"); +%! [sl, c] = movslice (1000, 1000); +%! assert (class (sl), "uint16"); +%! assert (class (c), "uint16"); +%! [sl, c] = movslice (100000, 100000); +%! assert (class (sl), "uint32"); +%! assert (class (c), "uint32"); ## Test input validation %!error movslice ()