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