From 22aa70eb6fdee109316ea0d81c39e1257b93f009 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 25 Aug 2018 23:30:50 +0200 Subject: Tests and minor improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libsimple.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'libsimple.c') 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; } -- cgit v1.2.3-70-g09d2