aboutsummaryrefslogtreecommitdiffstats
path: root/libsimple.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-08-25 23:30:50 +0200
committerMattias Andrée <maandree@kth.se>2018-08-25 23:30:50 +0200
commit22aa70eb6fdee109316ea0d81c39e1257b93f009 (patch)
tree0f7590fb33fcf1853f7cd989b3242cfd33a719ab /libsimple.c
parentm (diff)
downloadlibsimple-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.c24
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;
}