SASUnit Examples  Version 1.2
nobs_test.sas
Go to the documentation of this file.
1 
21 /* change log
22  30.01.2013 BB Hint to failed tests formated consistently " - must be red!"; \brief tag amended "- has to fail!"
23  30.01.2013 BB Change log created
24 */
25 
26 /*-- simple example with sashelp.class ---------------------------------------*/
27 %initTestcase(i_object=nobs.sas, i_desc=simple example with sashelp.class)
28 %let nobs=%nobs(sashelp.class);
29 %endTestcall()
30 %assertEquals(i_actual=&nobs, i_expected=19, i_desc=number of observations in sashelp.class)
31 %endTestcase()
32 
33 /*-- failed test -------------------------------------------------------------*/
34 %initTestcase(i_object=nobs.sas, i_desc=failed test - must be red!)
35 %let nobs=%nobs(sashelp.class);
36 %endTestcall()
37 %assertEquals(i_actual=&nobs, i_expected=20, i_desc=number of observations in dataset sashelp.class - must be red!)
38 %endTestcase()
39 
40 /*-- example with big dataset ------------------------------------------------*/
41 %initTestcase(i_object=nobs.sas, i_desc=%str(example with big dataset))
42 data big;
43  do i=1 to 1000000;
44  x=ranuni(0);
45  output;
46  end;
47 run;
48 %let nobs=%nobs(big);
49 %endTestcall()
50 %assertEquals(i_actual=&nobs, i_expected=1000000, i_desc=number of observations in dataset work.big)
51 %endTestcase()
52 
53 /*-- example with empty dataset ----------------------------------------------*/
54 %initTestcase(i_object=nobs.sas, i_desc=%str(example with empty dataset))
55 data empty;
56  stop;
57 run;
58 %let nobs=%nobs(empty);
59 %endTestcall()
60 %assertEquals(i_actual=&nobs, i_expected=0, i_desc=number of observations in dataset work.empty)
61 %endTestcase()
62 
63 /*-- dataset not specified ---------------------------------------------------*/
64 %initTestcase(i_object=nobs.sas, i_desc=%str(dataset not specified))
65 %let nobs=%nobs(xxx);
66 %endTestcall()
67 %assertEquals(i_actual=&nobs, i_expected=, i_desc=number of observations when dataset is not specified)
68 %endTestcase()
69 
70 /*-- invalid dataset ---------------------------------------------------------*/
71 %initTestcase(i_object=nobs.sas, i_desc=%str(invalid dataset))
72 %let nobs=%nobs(xxx);
73 %endTestcall()
74 %assertEquals(i_actual=&nobs, i_expected=, i_desc=number of observations with invalid dataset)
75 %endTestcase()
76 
77