Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_assertcols.test.sas
Go to the documentation of this file.
1/**
2
3 @file
4 @brief Testing mp_assertcols macro
5 @details Covers each of the three test conditions (ALL, ANY, NONE), both
6 satisfied and unsatisfied. The unsatisfied cases are recorded against a
7 separate results dataset so the suite does not count them as failures -
8 what is under test is that the macro writes FAIL for them.
9
10 <h4> SAS Macros </h4>
11 @li mp_assert.sas
12 @li mp_assertcols.sas
13
14**/
15
16/* satisfied conditions */
17%mp_assertcols(sashelp.class,
18 cols=name age sex,
19 test=ALL,
20 desc=Checking ALL is satisfied when every column exists
21)
22
23%mp_assertcols(sashelp.class,
24 cols=name notacol,
25 test=ANY,
26 desc=Checking ANY is satisfied when some of the columns exist
27)
28
29%mp_assertcols(sashelp.class,
30 cols=name weight,
31 test=ANY,
32 desc=Checking ANY is satisfied when every column exists
33)
34
35%mp_assertcols(sashelp.class,
36 cols=notacol othercol,
37 test=NONE,
38 desc=Checking NONE is satisfied when no column exists
39)
40
41/* unsatisfied conditions */
42%mp_assertcols(sashelp.class,
43 cols=name age notacol,
44 test=ALL,
45 desc=Checking ALL is unsatisfied when a column is missing,
46 outds=work.neg_results
47)
48
49%mp_assertcols(sashelp.class,
50 cols=notacol othercol,
51 test=ANY,
52 desc=Checking ANY is unsatisfied when no column exists,
53 outds=work.neg_results
54)
55
56%mp_assertcols(sashelp.class,
57 cols=name height,
58 test=NONE,
59 desc=Checking NONE is unsatisfied when a column exists,
60 outds=work.neg_results
61)
62
63proc sql noprint;
64 select count(*) into: pos_fail from work.test_results
65 where test_result ne 'PASS';
66 select count(*) into: neg_pass from work.neg_results
67 where test_result ne 'FAIL';
68quit;
69
70%mp_assert(iftrue=(&pos_fail=0),
71 desc=Checking the satisfied conditions all recorded PASS)
72
73%mp_assert(iftrue=(&neg_pass=0),
74 desc=Checking the unsatisfied conditions all recorded FAIL)