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 mddl_assert.sas
12 @li mp_assert.sas
13 @li mp_assertcols.sas
14 @li mp_assertmodel.sas
15
16**/
17
18/* satisfied conditions */
19%mp_assertcols(sashelp.class,
20 cols=name age sex,
21 test=ALL,
22 desc=Checking ALL is satisfied when every column exists
23)
24
25%mp_assertcols(sashelp.class,
26 cols=name notacol,
27 test=ANY,
28 desc=Checking ANY is satisfied when some of the columns exist
29)
30
31%mp_assertcols(sashelp.class,
32 cols=name weight,
33 test=ANY,
34 desc=Checking ANY is satisfied when every column exists
35)
36
37%mp_assertcols(sashelp.class,
38 cols=notacol othercol,
39 test=NONE,
40 desc=Checking NONE is satisfied when no column exists
41)
42
43/* unsatisfied conditions */
44%mp_assertcols(sashelp.class,
45 cols=name age notacol,
46 test=ALL,
47 desc=Checking ALL is unsatisfied when a column is missing,
48 outds=work.neg_results
49)
50
51%mp_assertcols(sashelp.class,
52 cols=notacol othercol,
53 test=ANY,
54 desc=Checking ANY is unsatisfied when no column exists,
55 outds=work.neg_results
56)
57
58%mp_assertcols(sashelp.class,
59 cols=name height,
60 test=NONE,
61 desc=Checking NONE is unsatisfied when a column exists,
62 outds=work.neg_results
63)
64
65proc sql noprint;
66 select count(*) into: pos_fail from work.test_results
67 where test_result ne 'PASS';
68 select count(*) into: neg_pass from work.neg_results
69 where test_result ne 'FAIL';
70quit;
71
72%mp_assert(iftrue=(&pos_fail=0),
73 desc=Checking the satisfied conditions all recorded PASS)
74
75%mp_assert(iftrue=(&neg_pass=0),
76 desc=Checking the unsatisfied conditions all recorded FAIL)
77
78%mddl_assert(work.assert_schema)
79%mp_assertmodel(work.neg_results,base=work.assert_schema,
80 desc=Checking mp_assertcols output schema)