mirror of
https://github.com/sasjs/core.git
synced 2026-01-06 17:10:05 +00:00
fix: adding test and updating documentation
This commit is contained in:
65
tests/crossplatform/mp_replace.test.sas
Normal file
65
tests/crossplatform/mp_replace.test.sas
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
@file
|
||||
@brief Testing mp_replace.sas macro
|
||||
|
||||
<h4> SAS Macros </h4>
|
||||
@li mp_replace.sas
|
||||
@li mp_assert.sas
|
||||
@li mp_assertscope.sas
|
||||
|
||||
**/
|
||||
|
||||
|
||||
%let test1="&sasjswork/file.txt";
|
||||
%let str=replace/me;
|
||||
%let rep=with/this;
|
||||
data _null_;
|
||||
file &test1;
|
||||
put 'blahblah';
|
||||
put "blahblah&str.blah";
|
||||
put 'blahblahblah';
|
||||
run;
|
||||
%mp_assertscope(SNAPSHOT)
|
||||
%mp_replace(&test1, findvar=str, replacevar=rep)
|
||||
%mp_assertscope(COMPARE)
|
||||
data _null_;
|
||||
infile &test1;
|
||||
input;
|
||||
if _n_=2 then call symputx('test1result',_infile_);
|
||||
run;
|
||||
|
||||
%mp_assert(
|
||||
iftrue=("&test1result" = "blahblah&rep.blah"),
|
||||
desc=Checking first replace,
|
||||
outds=work.test_results
|
||||
)
|
||||
|
||||
|
||||
%let test2="&sasjswork/file2.txt";
|
||||
%let str=%str(replacewith trailing spaces );
|
||||
%let rep=%str( with more spaces );
|
||||
data _null_;
|
||||
file &test2;
|
||||
put 'blahblah';
|
||||
put "blahblah&str.blah&str. replace &str.X";
|
||||
put "blahbreplacewith&str.spacesahblah";
|
||||
run;
|
||||
%mp_replace(&test2, findvar=str, replacevar=rep)
|
||||
|
||||
data _null_;
|
||||
infile &test2;
|
||||
input;
|
||||
if _n_=2 then call symputx('test2resulta',_infile_);
|
||||
if _n_=3 then call symputx('test2resultb',_infile_);
|
||||
run;
|
||||
|
||||
%mp_assert(
|
||||
iftrue=("&test2resulta" = "blahblah&rep.blah&rep. replace &rep.X"),
|
||||
desc=Checking second replace 2nd row,
|
||||
outds=work.test_results
|
||||
)
|
||||
%mp_assert(
|
||||
iftrue=("&test2resultb" = "blahbreplacewith&rep.spacesahblah"),
|
||||
desc=Checking second replace 3rd row,
|
||||
outds=work.test_results
|
||||
)
|
||||
Reference in New Issue
Block a user