efl/legacy/evil/src/bin/evil_test_environment.c

179 lines
2.7 KiB
C
Raw Normal View History

2008-10-23 23:06:57 -07:00
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <string.h>
#include <Evil.h>
#include "evil_suite.h"
#include "evil_test_environment.h"
2008-10-23 23:06:57 -07:00
static int
test_env_test_setenv_NULL(void)
{
char *val;
int res;
res = setenv("EVIL_TEST_ENV", NULL, 1);
if (res < 0)
return 0;
val = getenv("EVIL_TEST_ENV");
return val ? 0 : 1;
}
static int
test_env_test_setenv_NULL_after_set(void)
{
char *val;
int res;
res = setenv("EVIL_TEST_ENV", "val", 1);
if (res < 0)
return 0;
val = getenv("EVIL_TEST_ENV");
if (!val)
return 0;
if (strcmp(val, "val"))
return 0;
res = setenv("EVIL_TEST_ENV", NULL, 1);
if (res < 0)
return 0;
val = getenv("EVIL_TEST_ENV");
return val ? 0 : 1;
}
static int
test_env_test_getenv_one(void)
2008-10-23 23:06:57 -07:00
{
char *val;
int res;
res = setenv("EVIL_TEST_ENV", "val", 1);
2008-10-23 23:06:57 -07:00
if (res < 0)
return 0;
val = getenv("EVIL_TEST_ENV");
if (!val)
return 0;
if (strcmp(val, "val"))
return 0;
return 1;
}
static int
test_env_test_getenv_two(void)
{
char *val;
int res;
res = setenv("EVIL_TEST_ENV1", "val1", 1);
if (res < 0)
return 0;
res = setenv("EVIL_TEST_ENV2", "val2", 1);
if (res < 0)
return 0;
val = getenv("EVIL_TEST_ENV1");
if (!val)
return 0;
2008-10-23 23:06:57 -07:00
if (strcmp(val, "val1"))
return 0;
val = getenv("EVIL_TEST_ENV2");
if (!val)
return 0;
if (strcmp(val, "val2"))
return 0;
return 1;
}
static int
test_env_test_getenv_two_swapped(void)
{
char *val;
int res;
res = setenv("EVIL_TEST_ENV1", "val1", 1);
if (res < 0)
return 0;
res = setenv("EVIL_TEST_ENV2", "val2", 1);
if (res < 0)
return 0;
val = getenv("EVIL_TEST_ENV2");
if (!val)
return 0;
if (strcmp(val, "val2"))
return 0;
val = getenv("EVIL_TEST_ENV1");
if (!val)
return 0;
if (strcmp(val, "val1"))
return 0;
2008-10-23 23:06:57 -07:00
return 1;
}
static int
test_env_test_unsetenv(void)
{
char *val;
int res;
res = setenv("EVIL_TEST_ENV", "val", 1);
if (res < 0)
return 0;
val = getenv("EVIL_TEST_ENV");
if (!val)
return 0;
if (unsetenv("EVIL_TEST_ENV") != 0)
return 0;
val = getenv("EVIL_TEST_ENV");
if (val)
return 0;
return 1;
}
static int
* AUTHORS: * src/lib/Evil.h: * src/lib/Makefile.am: * src/lib/evil_inet.c: * src/lib/evil_mman.c: * src/lib/evil_stdio.c: * src/lib/evil_stdio.h: * src/lib/evil_stdlib.c: * src/lib/evil_util.c: * src/lib/sys/mman.h: * src/lib/evil_printa.c (added): * src/lib/evil_pformatw.c (added): * src/lib/evil_pformat.h (added): * src/lib/evil_printw.c (added): * src/lib/evil_print.h (added): * src/lib/evil_macro.h (added): * src/lib/evil_pformata.c (added): Add POSIX printf family. Code taken from the MinGW-w64 project and modified to be integrated into Evil. * src/bin/Makefile.am: * src/bin/evil_suite.c: * src/bin/evil_test_util.h (added): * src/bin/evil_test_print.c (added): * src/bin/evil_test_print.h (added): * src/bin/evil_test_util.c (added): Add util and printf unit tests * src/lib/evil_errno.c: * src/lib/errno.h (deleted): * src/lib/mingw32ce (added): * src/lib/mingw32ce/errno.h (added): Move errno.h for Windows CE in its own directory to suppress conflicts with standard errno.h when compiling for Windows XP. * src/lib/dlfcn/dlfcn.c: * src/lib/evil_link_ce.c: * src/lib/evil_main.c: * src/lib/evil_unistd.c: Define WIN32_LEAN_AND_MEAN only if it's not defined. * src/lib/evil_fcntl.c: Remove debug. * src/bin/evil_test_dlfcn.c: * src/bin/evil_test_environment.c: * src/bin/evil_test_gettimeofday.c: * src/bin/evil_test_link.c: * src/bin/evil_test_mkstemp.c: * src/bin/evil_test_pipe.c: * src/bin/evil_test_realpath.c: Remove warnings. * src/lib/evil_link_xp.cpp: Formatting. SVN revision: 68084
2012-02-17 12:48:11 -08:00
test_env_tests_run(suite *s __UNUSED__)
{
int res;
res = test_env_test_setenv_NULL();
res &= test_env_test_setenv_NULL_after_set();
res &= test_env_test_getenv_one();
res &= test_env_test_getenv_two();
res &= test_env_test_getenv_two_swapped();
res &= test_env_test_unsetenv();
return res;
}
2008-10-23 23:06:57 -07:00
int
test_environment(suite *s)
{
return test_env_tests_run(s);
}