summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/test/main.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2008-02-19 05:52:30 +0000
committerkientzle <kientzle@FreeBSD.org>2008-02-19 05:52:30 +0000
commitc300e636ead4e5c1bd3c3583d2c8dc675c72c408 (patch)
tree70cac778552241f38b1a3107f0b158ec3af5449d /lib/libarchive/test/main.c
parent88b1623cab3601eefeb721c2b276db9d2d187c2d (diff)
downloadFreeBSD-src-c300e636ead4e5c1bd3c3583d2c8dc675c72c408.zip
FreeBSD-src-c300e636ead4e5c1bd3c3583d2c8dc675c72c408.tar.gz
The test_assert() function that backs my custom assert() macro
now returns a value, which supports such convenient constructs as: if (assert(NULL != foo())) { } Also be careful to setlocale("C") for each new test to avoid locale pollution. Also a couple of minor portability enhancements.
Diffstat (limited to 'lib/libarchive/test/main.c')
-rw-r--r--lib/libarchive/test/main.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/libarchive/test/main.c b/lib/libarchive/test/main.c
index ffe81cf..a7289ec 100644
--- a/lib/libarchive/test/main.c
+++ b/lib/libarchive/test/main.c
@@ -34,11 +34,8 @@
*/
#define PROGRAM "LIBARCHIVE"
-/*
- * Various utility routines useful for test programs.
- * Each test program is linked against this file.
- */
#include <errno.h>
+#include <locale.h>
#include <stdarg.h>
#include <time.h>
@@ -226,20 +223,21 @@ failure(const char *fmt, ...)
}
/* Generic assert() just displays the failed condition. */
-void
+int
test_assert(const char *file, int line, int value, const char *condition, void *extra)
{
++assertions;
if (value) {
msg[0] = '\0';
- return;
+ return (value);
}
failures ++;
if (previous_failures(file, line))
- return;
+ return (value);
fprintf(stderr, "%s:%d: Assertion failed\n", file, line);
fprintf(stderr, " Condition: %s\n", condition);
report_failure(extra);
+ return (value);
}
/* assertEqualInt() displays the values of the two integers. */
@@ -553,6 +551,8 @@ static int test_run(int i, const char *tmpdir)
tests[i].name);
exit(1);
}
+ /* Explicitly reset the locale before each test. */
+ setlocale(LC_ALL, "C");
/* Run the actual test. */
(*tests[i].func)();
/* Summarize the results of this test. */
OpenPOWER on IntegriCloud