SASUnit Examples  Version 1.2.1
assertlog.sas
Go to the documentation of this file.
1 
26 /* change log
27  29.01.2013 KL changed link from _sasunit_doc.sas to Sourceforge SASUnit User's Guide
28  10.10.2008 AM minimal correction for documentation
29  19.08.2008 AM removed language specific text in order to enable national language support
30 */
31 
32 %MACRO assertLog (
33  i_errors = 0
34  ,i_warnings = 0
35  ,i_desc =
36 );
37 
38 %GLOBAL g_inTestcase;
39 %IF &g_inTestcase EQ 1 %THEN %DO;
40  %endTestcall;
41 %END;
42 %ELSE %IF &g_inTestcase NE 2 %THEN %DO;
43  %PUT &g_error: assert muss nach initTestcase aufgerufen werden;
44  %RETURN;
45 %END;
46 
47 PROC SQL NOPRINT;
48 %LOCAL l_casid;
49 /* determine number of the current test case */
50  SELECT max(cas_id) INTO :l_casid FROM target.cas WHERE cas_scnid = &g_scnid;
51 QUIT;
52 
53 %IF &l_casid = . OR &l_casid = %THEN %DO;
54  %PUT &g_error: Assert darf nicht vor initTestcase aufgerufen werden;
55  %RETURN;
56 %END;
57 
58 /* Scan Log */
59 %LOCAL l_error_count l_warning_count;
60 %_sasunit_checklog (
61  i_logfile = &g_log/%sysfunc(putn(&g_scnid,z3.))_%sysfunc(putn(&l_casid,z3.)).log
62  ,i_error = &g_error
63  ,i_warning = &g_warning
64  ,r_errors = l_error_count
65  ,r_warnings= l_warning_count
66 )
67 
68 %LOCAL l_result;
69 %LET l_result = %eval (
70  &l_error_count NE &i_errors
71  OR &l_warning_count NE &i_warnings
72  );
73 
74 %_sasunit_asserts(
75  i_type = assertLog
76  ,i_expected = %str(&i_errors#&i_warnings)
77  ,i_actual = %str(&l_error_count#&l_warning_count)
78  ,i_desc = &i_desc
79  ,i_result = &l_result
80 )
81 
82 %MEND assertLog;