mirror of
https://github.com/sasjs/core.git
synced 2026-01-03 15:40:05 +00:00
feat: new (generic) mp_assert macro, and new feature (type filter) for mf_getvarlist. Added/updated tests for mp_filtercheck and mp_validatecol and mf_getvarlist.
This commit is contained in:
60
tests/base/mf_getvarlist.test.sas
Normal file
60
tests/base/mf_getvarlist.test.sas
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
@file
|
||||
@brief Testing mf_getvarlist macro
|
||||
|
||||
<h4> SAS Macros </h4>
|
||||
@li mf_getvarlist.sas
|
||||
|
||||
**/
|
||||
|
||||
|
||||
%let test1=%mf_getvarlist(sashelp.class);
|
||||
%let test2=%mf_getvarlist(sashelp.class,dlm=X);
|
||||
%let test3=%mf_getvarlist(sashelp.class,dlm=%str(,),quote=double);
|
||||
%let test4=%mf_getvarlist(sashelp.class,typefilter=N);
|
||||
%let test5=%mf_getvarlist(sashelp.class,typefilter=C);
|
||||
|
||||
data work.test_results;
|
||||
length test_description $256 test_result $4 test_comments base result $256;
|
||||
test_description="Basic test";
|
||||
base=symget('test1');
|
||||
result='Name Sex Age Height Weight';
|
||||
if base=result then test_result='PASS';
|
||||
else test_result='FAIL';
|
||||
test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
|
||||
output;
|
||||
|
||||
test_description="DLM test";
|
||||
base=symget('test2');
|
||||
result='NameXSexXAgeXHeightXWeight';
|
||||
if base=result then test_result='PASS';
|
||||
else test_result='FAIL';
|
||||
test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
|
||||
output;
|
||||
|
||||
test_description="DLM + quote test";
|
||||
base=symget('test3');
|
||||
result='"Name","Sex","Age","Height","Weight"';
|
||||
if base=result then test_result='PASS';
|
||||
else test_result='FAIL';
|
||||
test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
|
||||
output;
|
||||
|
||||
test_description="Numeric Filter";
|
||||
base=symget('test4');
|
||||
result='Age Height Weight';
|
||||
if base=result then test_result='PASS';
|
||||
else test_result='FAIL';
|
||||
test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
|
||||
output;
|
||||
|
||||
test_description="Char Filter";
|
||||
base=symget('test5');
|
||||
result='Name Sex';
|
||||
if base=result then test_result='PASS';
|
||||
else test_result='FAIL';
|
||||
test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
|
||||
output;
|
||||
|
||||
drop base result;
|
||||
run;
|
||||
@@ -5,6 +5,7 @@
|
||||
<h4> SAS Macros </h4>
|
||||
@li mp_filtercheck.sas
|
||||
@li mp_assertdsobs.sas
|
||||
@li mp_assert.sas
|
||||
|
||||
**/
|
||||
|
||||
@@ -125,3 +126,23 @@ run;
|
||||
outds=work.test_results
|
||||
)
|
||||
|
||||
/* Supply variables with incorrect types */
|
||||
data work.inds;
|
||||
infile datalines4 dsd;
|
||||
input GROUP_LOGIC:$3. SUBGROUP_LOGIC:$3. SUBGROUP_ID:8. VARIABLE_NM:$32.
|
||||
OPERATOR_NM:$10. RAW_VALUE:8;
|
||||
datalines4;
|
||||
AND,AND,1,age,=,0
|
||||
;;;;
|
||||
run;
|
||||
%let syscc=0;
|
||||
%mp_filtercheck(work.inds,
|
||||
targetds=sashelp.class,
|
||||
outds=work.badrecords,
|
||||
abort=NO
|
||||
)
|
||||
%mp_assert(iftrue=(&syscc=42),
|
||||
desc=Throw error if RAW_VALUE is incorrect,
|
||||
outds=work.test_results
|
||||
)
|
||||
%let syscc=0;
|
||||
|
||||
@@ -17,7 +17,7 @@ data test1;
|
||||
input;
|
||||
libds=_infile_;
|
||||
%mp_validatecol(libds,LIBDS,is_libds)
|
||||
if libds=1;
|
||||
if is_libds=1;
|
||||
datalines4;
|
||||
some.libname
|
||||
!lib.blah
|
||||
|
||||
Reference in New Issue
Block a user