Files
epics-base/modules/libcom/test/epicsEnvUnsetTest.c
Andrew Johnson 3c99391d93 Added SPDX License ID to all EPICS-original source files
In some cases the license-identification header was missing,
so I added that as well. Replaced the remaining headers that
specifically identified "Versions 3.13.7 and higher".

Makefiles and the build system were deliberately excluded.
2020-08-03 11:53:01 -05:00

44 lines
1.1 KiB
C

/*************************************************************************\
* SPDX-License-Identifier: EPICS
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "macLib.h"
#include "envDefs.h"
#include "errlog.h"
#include "epicsUnitTest.h"
#include "testMain.h"
static void check(const char* variable, const char* expected)
{
const char* value;
value = getenv(variable);
if (!testOk((!expected && !value) || (expected && value && strcmp(expected, value) == 0),
"%s = \"%s\"", variable, value))
{
testDiag("should have been \"%s\"", expected);
}
}
MAIN(epicsEnvUnsetTest)
{
eltc(0);
testPlan(3);
check("TEST_VAR_A",NULL);
epicsEnvSet("TEST_VAR_A","test value");
check("TEST_VAR_A","test value");
epicsEnvUnset("TEST_VAR_A");
check("TEST_VAR_A",NULL);
testDone();
return 0;
}