SASUnit Examples  Version 1.2.1
assertperformance.sas
Go to the documentation of this file.
1 
23 /* change history
24  29.01.2013 KL changed link from _sasunit_doc.sas to Sourceforge SASUnit User's Guide
25  29.08.2012 KL
26  For every call of the assert target.cas is rewritten! This slows down performance.
27  In fact there is no need to store the run time in the target.cas.
28  If it's needed it can be done via an update on the data set, but that should be done in endTestcall.
29 */
30 
31 %MACRO assertPerformance(i_expected=, i_desc=);
32 
33 %GLOBAL g_inTestcase;
34 %IF &g_inTestcase EQ 1 %THEN %DO;
35  %endTestcall;
36 %END;
37 %ELSE %IF &g_inTestcase NE 2 %THEN %DO;
38  %PUT &g_error: assert has to be called after initTestcase;
39  %RETURN;
40 %END;
41 
42 /* determine current case id */
43 PROC SQL NOPRINT;
44 %LOCAL l_casid;
45  SELECT max(cas_id) INTO :l_casid FROM target.cas WHERE cas_scnid=&g_scnid;
46 %LET l_casid = &l_casid;
47 QUIT;
48 
49 PROC SQL NOPRINT;
50  SELECT cas_end - cas_start
51  INTO: l_cas_runtime
52  FROM target.cas
53  WHERE
54  cas_scnid = &g_scnid.
55  AND cas_id = &l_casid.;
56 QUIT;
57 
58 /* determine result */
59 %LET l_result = %SYSEVALF(NOT(&l_cas_runtime <= &i_expected));
60  /* evaluation negated because %_sasunit_asserts awaits 0 for l_result if the assertion is true */
61 
62 %_sasunit_asserts(
63  i_type = assertPerformance
64  ,i_expected = &i_expected
65  ,i_actual = &l_cas_runtime
66  ,i_desc = &i_desc
67  ,i_result = &l_result)
68 %MEND assertPerformance;