Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_dttmfmts.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mf_dttmfmts macro
4
5 <h4> SAS Macros </h4>
6 @li mf_dttmfmts.sas
7 @li mp_assert.sas
8 @li mp_assertscope.sas
9
10**/
11
12/* the macro call must not sit between the snapshots behind a %let - that
13 would register the test's own macro variable as a leak */
14%mp_assertscope(SNAPSHOT)
15%put %mf_dttmfmts(DATE);
16%mp_assertscope(COMPARE,
17 desc=mf_dttmfmts does not leak scope,
18 outds=work.test_results
19)
20
21%let datelist=%mf_dttmfmts(DATE);
22%let dtlist=%mf_dttmfmts(DATETIME);
23%let timelist=%mf_dttmfmts(TIME);
24%let lowerlist=%mf_dttmfmts(date);
25
26/* the lists hold commas, so they are inspected in a data step rather than
27 passed to a macro function */
28data _null_;
29 length dl dt tl $4000;
30 dl=symget('datelist');
31 dt=symget('dtlist');
32 tl=symget('timelist');
33 call symputx('date_has_mmddyy',(index(dl,"'MMDDYY'")>0));
34 call symputx('date_has_hhmm',(index(dl,"'HHMM'")>0));
35 call symputx('dt_has_dateampm',(index(dt,"'DATEAMPM'")>0));
36 call symputx('dt_has_mmddyy',(index(dt,"'MMDDYY'")>0));
37 call symputx('time_has_hhmm',(index(tl,"'HHMM'")>0));
38 call symputx('time_has_mmddyy',(index(tl,"'MMDDYY'")>0));
39 call symputx('quoted',(index(dl,"'")>0));
40 call symputx('ci_ok',(dl=symget('lowerlist')));
41run;
42
43%mp_assert(
44 iftrue=(&date_has_mmddyy=1),
45 desc=DATE list holds a date format,
46 outds=work.test_results
47)
48%mp_assert(
49 iftrue=(&date_has_hhmm=0),
50 desc=DATE list does not hold a time format,
51 outds=work.test_results
52)
53%mp_assert(
54 iftrue=(&dt_has_dateampm=1),
55 desc=DATETIME list holds DATEAMPM,
56 outds=work.test_results
57)
58%mp_assert(
59 iftrue=(&dt_has_mmddyy=0),
60 desc=DATETIME list does not hold a date format,
61 outds=work.test_results
62)
63%mp_assert(
64 iftrue=(&time_has_hhmm=1),
65 desc=TIME list holds a time format,
66 outds=work.test_results
67)
68%mp_assert(
69 iftrue=(&time_has_mmddyy=0),
70 desc=TIME list does not hold a date format,
71 outds=work.test_results
72)
73%mp_assert(
74 iftrue=(&quoted=1),
75 desc=the list is quoted so it can be used in an in clause,
76 outds=work.test_results
77)
78%mp_assert(
79 iftrue=(&ci_ok=1),
80 desc=type is case insensitive,
81 outds=work.test_results
82)
83
84/* the scope check above writes straight to the results, so this is what
85 proves it passed */
86data _null_;
87 retain fails 0;
88 set work.test_results end=last;
89 if test_result='FAIL' then fails=fails+1;
90 if last then call symputx('nrfails',fails);
91run;
92%mp_assert(
93 iftrue=(&nrfails=0),
94 desc=no assertion in this test failed,
95 outds=work.test_results
96)