diff options
author | Mattias Andrée <maandree@kth.se> | 2018-08-25 23:30:50 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-08-25 23:30:50 +0200 |
commit | 22aa70eb6fdee109316ea0d81c39e1257b93f009 (patch) | |
tree | 0f7590fb33fcf1853f7cd989b3242cfd33a719ab /libsimple.c | |
parent | m (diff) | |
download | libsimple-22aa70eb6fdee109316ea0d81c39e1257b93f009.tar.gz libsimple-22aa70eb6fdee109316ea0d81c39e1257b93f009.tar.bz2 libsimple-22aa70eb6fdee109316ea0d81c39e1257b93f009.tar.xz |
Tests and minor improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libsimple.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libsimple.c b/libsimple.c index f9657c2..fd7f779 100644 --- a/libsimple.c +++ b/libsimple.c @@ -629,6 +629,30 @@ main(void) fprintf(stderr, "warning: libsimple_memdupa missing\n"); #endif + unsetenv("X"); + assert(!getenv("X")); + assert(!libsimple_getenv_ne("X")); + + putenv("X=xyz"); + assert(!strcmpnul(getenv("X"), "xyz")); + assert(!strcmpnul(libsimple_getenv_ne("X"), "xyz")); + + putenv("X="); + assert(!strcmpnul(getenv("X"), "")); + assert(!libsimple_getenv_ne("X")); + + unsetenv("X"); + assert(!getenv("X")); + assert(!strcmpnul(libsimple_getenv_e("X"), "")); + + putenv("X=xyz"); + assert(!strcmpnul(getenv("X"), "xyz")); + assert(!strcmpnul(libsimple_getenv_e("X"), "xyz")); + + putenv("X="); + assert(!strcmpnul(getenv("X"), "")); + assert(!strcmpnul(libsimple_getenv_e("X"), "")); + return 0; } |