Published on :
Unit Test CREATION_INTERNE

Test of the %hassuffix macro

This code is also available in: Deutsch Español Français
This SAS© script is a set of unit tests for the %hassuffix macro. It evaluates different scenarios, including exact matches, partial suffix matches, non-matching cases, and handling of empty strings. The %asserteq macro is used to validate that the result of %hassuffix matches the expected value (1 for true, 0 for false).
Data Analysis

Type : CREATION_INTERNE


The data used are literal character strings passed directly as arguments to macro calls. No external or internal data (like SASHELP) is explicitly read or generated into datasets.

1 Code Block
Macro Call
Explanation :
Tests if the string 'abc' has 'abc' as a suffix. The expected result is 1 (true).
Copied!
1%asserteq(1,%hassuffix(abc,abc));
2 Code Block
Macro Call
Explanation :
Tests if the string 'abc' has 'c' as a suffix. The expected result is 1 (true).
Copied!
1%asserteq(1,%hassuffix(abc,c));
3 Code Block
Macro Call
Explanation :
Tests if the string 'abc' has 'a' as a suffix. The expected result is 0 (false).
Copied!
1%asserteq(0,%hassuffix(abc,a));
4 Code Block
Macro Call
Explanation :
Tests the %hassuffix macro with empty arguments, which is generally interpreted as (empty string, empty string). The expected result is 1 (true).
Copied!
1%asserteq(1,%hassuffix());
5 Code Block
Macro Call
Explanation :
Tests if an empty string has an empty string as a suffix. The expected result is 1 (true).
Copied!
1%asserteq(1,%hassuffix(,));
6 Code Block
Macro Call
Explanation :
Tests if an empty string has 'a' as a suffix. The expected result is 0 (false).
Copied!
1%asserteq(0,%hassuffix(,a));
7 Code Block
Macro Call
Explanation :
Tests if the string 'a' has an empty string as a suffix. The expected result is 1 (true).
Copied!
1%asserteq(1,%hassuffix(a,));
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.