mirror of
https://github.com/sasjs/core.git
synced 2026-01-03 15:40:05 +00:00
feat: enabling leading blanks in mp_ds2csv. Also tests for mp_ds2csv and mp_testervice.sas, and strict mode fixes elsewhere
This commit is contained in:
96
tests/crossplatform/mp_ds2csv.test.sas
Normal file
96
tests/crossplatform/mp_ds2csv.test.sas
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
@file
|
||||
@brief Testing mp_ds2csv.sas macro
|
||||
|
||||
<h4> SAS Macros </h4>
|
||||
@li mp_ds2csv.sas
|
||||
@li mp_assert.sas
|
||||
@li mp_assertscope.sas
|
||||
|
||||
**/
|
||||
|
||||
data work.somedata;
|
||||
x=1;
|
||||
y=' t"w"o';
|
||||
z=.z;
|
||||
label x='x factor';
|
||||
run;
|
||||
|
||||
/**
|
||||
* Test 1 - default CSV
|
||||
*/
|
||||
%mp_assertscope(SNAPSHOT)
|
||||
%mp_ds2csv(work.somedata,outfile="&sasjswork/test1.csv")
|
||||
%mp_assertscope(COMPARE)
|
||||
|
||||
%let test1b=FAIL;
|
||||
data _null_;
|
||||
infile "&sasjswork/test1.csv";
|
||||
input;
|
||||
list;
|
||||
if _n_=1 then call symputx('test1a',_infile_);
|
||||
else if _infile_='1,"t""w""o",Z' then call symputx('test1b','PASS');
|
||||
run;
|
||||
|
||||
%mp_assert(
|
||||
iftrue=("&test1a"="x factor,Y,Z"),
|
||||
desc=Checking header row Test 1,
|
||||
outds=work.test_results
|
||||
)
|
||||
%mp_assert(
|
||||
iftrue=("&test1b"="PASS"),
|
||||
desc=Checking data row Test 1,
|
||||
outds=work.test_results
|
||||
)
|
||||
|
||||
/**
|
||||
* Test 2 - NAME header with fileref and semicolons
|
||||
*/
|
||||
filename test2 "&sasjswork/test2.csv";
|
||||
%mp_ds2csv(work.somedata,outref=test2,dlm=SEMICOLON,headerformat=NAME)
|
||||
|
||||
%let test2b=FAIL;
|
||||
data _null_;
|
||||
infile test2;
|
||||
input;
|
||||
list;
|
||||
if _n_=1 then call symputx('test2a',_infile_);
|
||||
else if _infile_='1;"t""w""o";Z' then call symputx('test2b','PASS');
|
||||
run;
|
||||
|
||||
%mp_assert(
|
||||
iftrue=("&test2a"="X;Y;Z"),
|
||||
desc=Checking header row Test 2,
|
||||
outds=work.test_results
|
||||
)
|
||||
%mp_assert(
|
||||
iftrue=("&test2b"="PASS"),
|
||||
desc=Checking data row Test 2,
|
||||
outds=work.test_results
|
||||
)
|
||||
|
||||
/**
|
||||
* Test 3 - SASjs format
|
||||
*/
|
||||
filename test3 "&sasjswork/test3.csv";
|
||||
%mp_ds2csv(work.somedata,outref=test3,headerformat=SASJS)
|
||||
|
||||
%let test3b=FAIL;
|
||||
data _null_;
|
||||
infile test3;
|
||||
input;
|
||||
list;
|
||||
if _n_=1 then call symputx('test3a',_infile_);
|
||||
else if _infile_='1;"t""w""o";Z' then call symputx('test3b','PASS');
|
||||
run;
|
||||
|
||||
%mp_assert(
|
||||
iftrue=("&test3a"="X:best. Y:$char7. Z:best."),
|
||||
desc=Checking header row Test 3,
|
||||
outds=work.test_results
|
||||
)
|
||||
%mp_assert(
|
||||
iftrue=("&test3b"="PASS"),
|
||||
desc=Checking data row Test 3,
|
||||
outds=work.test_results
|
||||
)
|
||||
97
tests/crossplatform/mp_testservice.test.sas
Normal file
97
tests/crossplatform/mp_testservice.test.sas
Normal file
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
@file
|
||||
@brief Testing mp_testservice.sas macro
|
||||
|
||||
Be sure to run <code>%let mcTestAppLoc=/Public/temp/macrocore;</code> when
|
||||
runnin in Studio
|
||||
|
||||
<h4> SAS Macros </h4>
|
||||
@li mp_createwebservice.sas
|
||||
@li mp_testservice.sas
|
||||
@li mp_assert.sas
|
||||
|
||||
**/
|
||||
|
||||
|
||||
filename ft15f001 temp;
|
||||
parmcards4;
|
||||
%webout(FETCH)
|
||||
%webout(OPEN)
|
||||
%macro x();
|
||||
%do i=1 %to &_webin_file_count;
|
||||
%webout(OBJ,&&_webin_name&i,missing=STRING)
|
||||
%end;
|
||||
%mend x; %x()
|
||||
%webout(CLOSE)
|
||||
;;;;
|
||||
%mp_createwebservice(path=&mcTestAppLoc/services,name=sendObj)
|
||||
|
||||
%mp_assert(
|
||||
iftrue=(&syscc=0),
|
||||
desc=No errors after service creation,
|
||||
outds=work.test_results
|
||||
)
|
||||
|
||||
/**
|
||||
* Test 1 - send a dataset
|
||||
*/
|
||||
data work.somedata1 work.somedata2;
|
||||
x=1;
|
||||
y=' t"w"o';
|
||||
z=.z;
|
||||
label x='x factor';
|
||||
output;
|
||||
run;
|
||||
|
||||
%mp_testservice(&mcTestAppLoc/services/sendObj,
|
||||
inputdatasets=work.somedata1 work.somedata2,
|
||||
debug=log,
|
||||
mdebug=1,
|
||||
outlib=testlib1,
|
||||
outref=test1
|
||||
)
|
||||
|
||||
%global test1a test1b test1c test1d;
|
||||
data _null_;
|
||||
infile test1;
|
||||
input;
|
||||
if _n_=3 then do;
|
||||
if _infile_=', "somedata1":' then call symputx('test1a','PASS');
|
||||
else putlog _n_= _infile_=;
|
||||
end;
|
||||
else if _n_=5 then do;
|
||||
if _infile_='{"X":1 ,"Y":" t\"w\"o" ,"Z":"Z" }' then
|
||||
call symputx('test1b','PASS');
|
||||
else putlog _n_= _infile_=;
|
||||
end;
|
||||
else if _n_=6 then do;
|
||||
if _infile_='], "somedata2":' then call symputx('test1c','PASS');
|
||||
else putlog _n_= _infile_=;
|
||||
end;
|
||||
else if _n_=8 then do;
|
||||
if _infile_='{"X":1 ,"Y":" t\"w\"o" ,"Z":"Z" }' then
|
||||
call symputx('test1d','PASS');
|
||||
else putlog _n_= _infile_=;
|
||||
end;
|
||||
run;
|
||||
|
||||
%mp_assert(
|
||||
iftrue=(&test1a=PASS),
|
||||
desc=Test 1 table 1 name,
|
||||
outds=work.test_results
|
||||
)
|
||||
%mp_assert(
|
||||
iftrue=(&test1b=PASS),
|
||||
desc=Test 1 table 1 values,
|
||||
outds=work.test_results
|
||||
)
|
||||
%mp_assert(
|
||||
iftrue=(&test1c=PASS),
|
||||
desc=Test 1 table 2 name,
|
||||
outds=work.test_results
|
||||
)
|
||||
%mp_assert(
|
||||
iftrue=(&test1d=PASS),
|
||||
desc=Test 1 table 2 values,
|
||||
outds=work.test_results
|
||||
)
|
||||
Reference in New Issue
Block a user