aboutsummaryrefslogtreecommitdiff
path: root/tests/portable/setenv-t.c
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2010-02-09 18:40:22 -0800
committerRuss Allbery <rra@stanford.edu>2010-02-09 18:40:22 -0800
commitc02942ddc12408f0e5b9d828cddf240519d1fe93 (patch)
tree62f80e0ba359c1a13cee7daee228e3e00011a723 /tests/portable/setenv-t.c
parentd05f66dbff10b525d37f60ee01d5b9f94bf5192e (diff)
Update to C TAP Harness 1.1 and rra-c-util 3.0 tests
* Update portable and util tests for C TAP Harness 1.1. * Remove the need for Autoconf substitution in test programs. * Support running a single test program with runtests -o. * Properly handle test cases that are skipped in their entirety. * Much improved C TAP library more closely matching Test::More. Rewrite client/basic-t to use the new test library functions and my current test case coding style.
Diffstat (limited to 'tests/portable/setenv-t.c')
-rw-r--r--tests/portable/setenv-t.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/portable/setenv-t.c b/tests/portable/setenv-t.c
new file mode 100644
index 0000000..5bc59ce
--- /dev/null
+++ b/tests/portable/setenv-t.c
@@ -0,0 +1,46 @@
+/*
+ * setenv test suite.
+ *
+ * Written by Russ Allbery <rra@stanford.edu>
+ * Copyright 2009 Board of Trustees, Leland Stanford Jr. University
+ * Copyright (c) 2004, 2005, 2006
+ * by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+ * 2002, 2003 by The Internet Software Consortium and Rich Salz
+ *
+ * See LICENSE for licensing terms.
+ */
+
+#include <config.h>
+#include <portable/system.h>
+
+#include <errno.h>
+
+#include <tests/tap/basic.h>
+
+int test_setenv(const char *name, const char *value, int overwrite);
+
+static const char test_var[] = "SETENV_TEST";
+static const char test_value1[] = "Do not taunt Happy Fun Ball.";
+static const char test_value2[] = "Do not use Happy Fun Ball on concrete.";
+
+
+int
+main(void)
+{
+ plan(8);
+
+ if (getenv(test_var))
+ bail("%s already in the environment!", test_var);
+
+ ok(test_setenv(test_var, test_value1, 0) == 0, "set string 1");
+ is_string(test_value1, getenv(test_var), "...and getenv correct");
+ ok(test_setenv(test_var, test_value2, 0) == 0, "set string 2");
+ is_string(test_value1, getenv(test_var), "...and getenv unchanged");
+ ok(test_setenv(test_var, test_value2, 1) == 0, "overwrite string 2");
+ is_string(test_value2, getenv(test_var), "...and getenv changed");
+ ok(test_setenv(test_var, "", 1) == 0, "overwrite with empty string");
+ is_string("", getenv(test_var), "...and getenv correct");
+
+ return 0;
+}