SASUnit Examples  Version 1.5.0
assertperformance.sas
Go to the documentation of this file.
1 
25 %MACRO assertPerformance(i_expected=
26  ,i_desc = Check for run time
27  );
28 
29  /*-- verify correct sequence of calls-----------------------------------------*/
30  %GLOBAL g_inTestcase;
31  %IF &g_inTestcase EQ 1 %THEN %DO;
32  %endTestcall;
33  %END;
34  %ELSE %IF &g_inTestcase NE 2 %THEN %DO;
35  %PUT &g_error.(SASUNIT): assert must be called after initTestcase;
36  %RETURN;
37  %END;
38 
39  %LOCAL l_casid l_result l_errMsg;
40 
41  /* determine current case id */
42  PROC SQL NOPRINT;
43  SELECT max(cas_id) INTO :l_casid FROM target.cas WHERE cas_scnid=&g_scnid;
44  QUIT;
45  %LET l_casid = &l_casid;
46  %IF &l_casid = . OR &l_casid = %THEN %DO;
47  %PUT &g_error.(SASUNIT): assert must not be called before initTestcase;
48  %RETURN;
49  %END;
50 
51  PROC SQL NOPRINT;
52  SELECT cas_end - cas_start
53  INTO: l_cas_runtime
54  FROM target.cas
55  WHERE
56  cas_scnid = &g_scnid.
57  AND cas_id = &l_casid.;
58  QUIT;
59 
60  /* determine result */
61  %LET l_result = %SYSEVALF((NOT(&l_cas_runtime <= &i_expected))*2);
62  /* evaluation negated because %_asserts awaits 0 for l_result if the assertion is true */
63 
64  %LET l_errMsg=%bquote(Expected run time was &i_expected. s, but test case took &l_cas_runtime. s!);
65 
66  %_asserts(i_type = assertPerformance
67  ,i_expected = &i_expected
68  ,i_actual = &l_cas_runtime
69  ,i_desc = &i_desc
70  ,i_result = &l_result
71  ,i_errMsg = &l_errMsg
72  )
73 %MEND assertPerformance;