summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/test/test_entry.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libarchive/test/test_entry.c')
-rw-r--r--lib/libarchive/test/test_entry.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/libarchive/test/test_entry.c b/lib/libarchive/test/test_entry.c
index 3fd1d06..638af48 100644
--- a/lib/libarchive/test/test_entry.c
+++ b/lib/libarchive/test/test_entry.c
@@ -25,6 +25,8 @@
#include "test.h"
__FBSDID("$FreeBSD$");
+#include <locale.h>
+
/*
* Most of these tests are system-independent, though a few depend on
* features of the local system. Such tests are conditionalized on
@@ -721,6 +723,39 @@ DEFINE_TEST(test_entry)
#endif
#endif
+ /*
+ * Exercise the character-conversion logic, if we can.
+ */
+ failure("Can't exercise charset-conversion logic.");
+ if (assert(NULL != setlocale(LC_ALL, "de_DE.UTF-8"))) {
+ /* A filename that cannot be converted to wide characters. */
+ archive_entry_copy_pathname(e, "abc\314\214mno\374xyz");
+ failure("Converting invalid chars to Unicode should fail.");
+ assert(NULL == archive_entry_pathname_w(e));
+ //failure("Converting invalid chars to UTF-8 should fail.");
+ //assert(NULL == archive_entry_pathname_utf8(e));
+
+ /* A group name that cannot be converted. */
+ archive_entry_copy_gname(e, "abc\314\214mno\374xyz");
+ failure("Converting invalid chars to Unicode should fail.");
+ assert(NULL == archive_entry_gname_w(e));
+
+ /* A user name that cannot be converted. */
+ archive_entry_copy_uname(e, "abc\314\214mno\374xyz");
+ failure("Converting invalid chars to Unicode should fail.");
+ assert(NULL == archive_entry_uname_w(e));
+
+ /* A hardlink target that cannot be converted. */
+ archive_entry_copy_hardlink(e, "abc\314\214mno\374xyz");
+ failure("Converting invalid chars to Unicode should fail.");
+ assert(NULL == archive_entry_hardlink_w(e));
+
+ /* A symlink target that cannot be converted. */
+ archive_entry_copy_symlink(e, "abc\314\214mno\374xyz");
+ failure("Converting invalid chars to Unicode should fail.");
+ assert(NULL == archive_entry_symlink_w(e));
+ }
+
/* Release the experimental entry. */
archive_entry_free(e);
}
OpenPOWER on IntegriCloud