33 %MACRO assertTableExists (i_libref =
36 ,i_desc = Check
for existence of a specific dataset
42 %IF &g_inTestcase EQ 1 %THEN %DO;
45 %ELSE %IF &g_inTestcase NE 2 %THEN %DO;
46 %PUT &g_error.(SASUNIT): assert must be called after initTestcase;
50 %LOCAL l_dsname l_libref_ok l_table_exist l_result l_date l_suffix l_errMsg;
51 %LET l_dsname =%sysfunc(catx(., &i_libref, &i_memname));
52 %LET l_table_exist = -1;
56 %*************************************************************;
57 %*** Check preconditions ***;
58 %*************************************************************;
60 %*** check
for valid libref ***;
61 %LET l_libref_ok=%sysfunc (libref (&i_libref.));
62 %IF &l_libref_ok. NE 0 %THEN %DO;
63 %LET l_errMsg=Libref &i_libref. is invalid!;
67 %*** check
if i_target is valid ***;
68 %LET i_target=%sysfunc(upcase(&i_target));
69 %IF not(&i_target=DATA or &i_target=VIEW or &i_target=CATALOG) %THEN %DO;
70 %LET l_table_exist = -2;
71 %LET l_errMsg=%bquote(Invalid value
for parameter i_target (&i_target.)!);
75 %*************************************************************;
77 %*************************************************************;
79 %IF %sysfunc(exist(&l_dsname, &i_target)) %THEN %DO;
81 %PUT &g_note.(SASUNIT): &i_target. &l_dsname. exists.;
82 %LET l_errMsg=&i_target &l_dsname exists;
84 %***
get creation und modification date of tested member ***;
86 length _crdate _modate $20;
87 dsid=open(
"&l_dsname") ;
88 _crdate = attrn(dsid,
'CRDTE');
89 _modate = attrn(dsid,
'MODTE');
91 call symput(
'l_date',catt(
"#",_crdate,
"#",_modate));
95 %PUT &g_note.(SASUNIT): &i_target. &l_dsname. does not exist.;
96 %LET l_errMsg=&i_target &l_dsname does not exist;
100 %LET l_result = %eval(1 - &l_table_exist.);
101 %LET l_suffix=%str(, but it should exist!);
102 %IF (&i_not) %THEN %DO;
103 %LET l_result = %eval(1 - &l_result.);
104 %LET l_suffix=%str(, but it should not exist!);
106 %LET l_errMsg =&l_errMsg.&l_suffix.;
107 %LET l_result = %eval(&l_result.*2);
110 %_asserts(i_type = assertTableExists
111 ,i_expected = %str(&i_target.:&l_dsname.:&i_not.)
112 ,i_actual = %str(&l_table_exist.&l_date.)
114 ,i_result = &l_result.
115 ,i_errMsg = &l_errMsg.
118 %MEND assertTableExists;