From 81d99b9440e005121b4304a159e6b8266a67b384 Mon Sep 17 00:00:00 2001 From: coulais Date: Thu, 28 Nov 2024 10:48:28 +0100 Subject: [PATCH] initial import of basic tests for ROT() (issue 1909) --- testsuite/LIST | 1 + testsuite/test_rot.pro | 80 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 testsuite/test_rot.pro diff --git a/testsuite/LIST b/testsuite/LIST index 10a2e04b8..9ca6cce53 100644 --- a/testsuite/LIST +++ b/testsuite/LIST @@ -166,6 +166,7 @@ test_qromo.pro test_readf_with_crlf.pro test_reads.pro test_rebin.pro +test_rot.pro test_routine_dir.pro test_routine_filepath.pro test_routine_name.pro diff --git a/testsuite/test_rot.pro b/testsuite/test_rot.pro new file mode 100644 index 000000000..e68393fdd --- /dev/null +++ b/testsuite/test_rot.pro @@ -0,0 +1,80 @@ +; +; Alain C., ADASS, 13 Nov 2024 +; +; Assuming ROTATE() works fine ! +; +; Bug +; +; ------------------------------ +; +pro TEST_ROT_ROTATE, angle, cumul_errors, offset=offset, help=help +; +if (N_PARAMS() LT 1) then begin + MESSAGE, /cont, 'Missing ANGLE as input' + return +end +errors=0 +; +direction=-1 +if (angle EQ 0) then direction=0 +if (angle EQ 90) then direction=3 +if (angle EQ 180) then direction=2 +if (angle EQ 270) then direction=1 +if (direction LT 0) then begin + MESSAGE, /cont, 'inadequate ANGLE, please check' + return +endif +; +if ~KEYWORD_SET(offset) then offset=0 +; +GIVE_LIST_NUMERIC, list_numeric_types, list_numeric_names +; +for jj=0, N_ELEMENTS(list_numeric_types)-1 do begin + for ii=3,7 do begin + input=INDGEN(ii,ii+offset, type=list_numeric_types[jj]) + res=ROT(input,angle)-ROTATE(input,direction) + if (TOTAL(ABS(res)) GT 1e-7) then begin + txt=' & type '+ list_numeric_names[jj] + ERRORS_ADD, errors, 'sym with size '+STRING(ii)+txt + endif + endfor +endfor +; +; -------------- +; +BANNER_FOR_TESTSUITE, "TEST_ROT_ROTATE", errors, /short, verb=verbose +ERRORS_CUMUL, cumul_errors, errors +if KEYWORD_SET(test) then STOP +; +end +; +; ------------------------------ +; +pro test_rot +; +cumul_errors=0 +; +angle=90. +print, 'Testing for angle =', angle +TEST_ROT_ROTATE, angle, cumul_errors +; +angle=180. +print, 'Testing for angle =', angle +TEST_ROT_ROTATE, angle, cumul_errors +TEST_ROT_ROTATE, angle, cumul_errors, offset=1 +TEST_ROT_ROTATE, angle, cumul_errors, offset=2 +TEST_ROT_ROTATE, angle, cumul_errors, offset=3 +; +angle=270. +print, 'Testing for angle =', angle +TEST_ROT_ROTATE, angle, cumul_errors +; +; ----------------- final message ---------- +; +BANNER_FOR_TESTSUITE, 'TEST_ROT', cumul_errors +; +if (cumul_errors GT 0) AND ~KEYWORD_SET(no_exit) then EXIT, status=1 +; +if KEYWORD_SET(test) then STOP +; +end