Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_trimstr.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mf_trimstr.sas macro
4
5 <h4> SAS Macros </h4>
6 @li mf_trimstr.sas
7 @li mp_assert.sas
8 @li mp_assertscope.sas
9
10**/
11
12%mp_assertscope(SNAPSHOT)
13
14/* the three examples in the macro's own documentation */
15%mp_assert(
16 iftrue=("%mf_trimstr(/blah/,/)"="/blah"),
17 desc=Removes a trailing slash,
18 outds=work.test_results
19)
20
21%mp_assert(
22 iftrue=("%mf_trimstr(/blah/,h)"="/blah/"),
23 desc=Leaves a value whose tail does not match alone,
24 outds=work.test_results
25)
26
27%mp_assert(
28 iftrue=("%mf_trimstr(/blah/,h/)"="/bla"),
29 desc=Removes a two character tail,
30 outds=work.test_results
31)
32
33/* a value shorter than the trim string cannot end with it, so nothing is
34 removed - this used to return an empty string, which lost the value */
35%mp_assert(
36 iftrue=("%mf_trimstr(ab,xyz)"="ab"),
37 desc=Returns a value shorter than the trim string unchanged,
38 outds=work.test_results
39)
40
41/* a value equal to the trim string is entirely a tail, so it goes */
42%mp_assert(
43 iftrue=("%mf_trimstr(abc,abc)"=""),
44 desc=Removes a value that is exactly the trim string,
45 outds=work.test_results
46)
47
48%mp_assert(
49 iftrue=("%mf_trimstr(,xyz)"=""),
50 desc=An empty value stays empty,
51 outds=work.test_results
52)
53
54%mp_assert(
55 iftrue=("%mf_trimstr(aaaXYZ,XYZ)"="aaa"),
56 desc=Removes a multi character tail,
57 outds=work.test_results
58)
59
60%mp_assert(
61 iftrue=("%mf_trimstr(x,x)"=""),
62 desc=A single character matching the trim string is removed,
63 outds=work.test_results
64)
65
66%mp_assertscope(COMPARE)