1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-04 08:00:05 +00:00

chore: adding test for mp_chop()

This commit is contained in:
Allan Bowe
2022-04-26 15:13:18 +00:00
parent f71e53af8d
commit a90a6f00cf

View File

@@ -0,0 +1,70 @@
/**
@file
@brief Testing mp_chop.sas macro
<h4> SAS Macros </h4>
@li mp_chop.sas
@li mp_assert.sas
@li mp_assertscope.sas
**/
/* prep input string */
%let src="%sysfunc(pathname(work))/file.txt";
%let str=Chop here!;
%let out1="%sysfunc(pathname(work))/file1.txt";
%let out2="%sysfunc(pathname(work))/file2.txt";
%let out3="%sysfunc(pathname(work))/file3.txt";
%let out4="%sysfunc(pathname(work))/file4.txt";
data _null_;
file &src;
put "startsection&str.endsection";
run;
%mp_assertscope(SNAPSHOT)
%mp_chop(&src, matchvar=str, keep=FIRST, outfile=&out1)
%mp_chop(&src, matchvar=str, keep=LAST, outfile=&out2)
%mp_chop(&src, matchvar=str, keep=FIRST, matchpoint=END, outfile=&out3)
%mp_chop(&src, matchvar=str, keep=LAST, matchpoint=END, outfile=&out4)
%mp_assertscope(COMPARE)
data _null_;
infile &out1 lrecl=200;
input;
call symputx('test1',_infile_);
data _null_;
infile &out2 lrecl=200;
input;
call symputx('test2',_infile_);
data _null_;
infile &out3 lrecl=200;
input;
call symputx('test3',_infile_);
data _null_;
infile &out4 lrecl=200;
input;
call symputx('test4',_infile_);
run;
%mp_assert(
iftrue=("&test1" ne "startsection"),
desc=Checking keep FIRST matchpoint START
outds=work.test_results
)
%mp_assert(
iftrue=("&test2" ne "Chop here!endsection"),
desc=Checking keep LAST matchpoint START
outds=work.test_results
)
%mp_assert(
iftrue=("&test1" ne "startsectionChop here!"),
desc=Checking keep FIRST matchpoint END
outds=work.test_results
)
%mp_assert(
iftrue=("&test2" ne "endsection"),
desc=Checking keep LAST matchpoint END
outds=work.test_results
)