Published on :
Test CREATION_INTERNE

Test of the _detectSymbols macro

This code is also available in: Français Deutsch Español
Awaiting validation
This test uses the SASUnit framework. It initializes a test scenario and declares global macro variables `g_my_error`, `g_my_warning`, and `g_my_note`. These variables are then reset to `_NONE_`. The `_detectSymbols` macro is called with these variables as output parameters. The script then verifies, via assertions, that `g_my_error` has been set to 'ERROR', `g_my_warning` to 'WARNING', and `g_my_note` to 'NOTE', thus confirming the proper functioning of `_detectSymbols`. This code is compatible with SAS© Viya 4 as it uses standard SAS© macro language features.
Data Analysis

Type : CREATION_INTERNE


No external data is used. The script works with global macro variables defined and manipulated directly within the code to simulate and verify the status of symbols (error, warning, note).

1 Code Block
Macro Declarations and Initializations Data
Explanation :
This block initializes the test scenario and declares the global macro variables `g_my_error`, `g_my_warning`, and `g_my_note`. These variables are then initialized to `_NONE_` before the call to the tested macro, to ensure a known starting state.
Copied!
1%initScenario (i_desc=Test of _detectSymbols.sas)
2 
3%global
4 g_my_error
5 g_my_warning
6 g_my_note
7;
8 
9%let g_my_error = _NONE_;
10%let g_my_warning = _NONE_;
11%let g_my_note = _NONE_;
2 Code Block
Test Case Execution
Explanation :
The test case is defined and the `_detectSymbols` macro is called. The previously declared global macro variables are passed by reference (`r_error_symbol`, `r_warning_symbol`, `r_note_symbol`), allowing `_detectSymbols` to modify their values according to its internal logic. `%endTestcall` marks the end of the tested code execution.
Copied!
1%initTestcase(i_object=_detectSymbols.sas, i_desc=Test with correct call);
2%_detectSymbols(r_error_symbol=g_my_error, r_warning_symbol=g_my_warning, r_note_symbol=g_my_note);
3%endTestcall;
4 
3 Code Block
SASUnit Assertions
Explanation :
Three `%assertEquals` assertions are used to verify that the `_detectSymbols` macro has correctly updated the global macro variables. It is expected that `g_my_error` contains 'ERROR', `g_my_warning` contains 'WARNING', and `g_my_note` contains 'NOTE'. `%endTestcase` closes the individual test case.
Copied!
1%assertEquals (i_actual = &g_my_error.
2 ,i_expected = ERROR
3 ,i_desc = ERROR-Symbol is SET properly
4 );
5
6%assertEquals (i_actual = &g_my_warning.
7 ,i_expected = WARNING
8 ,i_desc = WARNING-Symbol is SET properly
9 );
10%assertEquals (i_actual = &g_my_note.
11 ,i_expected = NOTE
12 ,i_desc = NOTE-Symbol is SET properly
13 );
14%endTestcase;
4 Code Block
SASUnit Scenario End
Explanation :
This block marks the end of the global test scenario defined by `%initScenario`. It is a standard closing command of the SASUnit framework.
Copied!
1%endScenario();
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.
Copyright Info : Copyright 2010-2023 HMS Analytical Software GmbH, http://www.analytical-software.de. This file is part of SASUnit, the unit testing framework for SAS(R) programs. For copyright information and terms of use under the GNU Lesser General Public License, see the included README.md file or https://github.com/HMS-Analytical-Software/SASUnit/wiki/readme/.