]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
These are really all part of the same set of tests, so combine
authorTim Kientzle <kientzle@gmail.com>
Fri, 11 Mar 2011 05:39:45 +0000 (00:39 -0500)
committerTim Kientzle <kientzle@gmail.com>
Fri, 11 Mar 2011 05:39:45 +0000 (00:39 -0500)
them into one source file.

SVN-Revision: 3006

Makefile.am
libarchive/test/CMakeLists.txt
libarchive/test/test_pax_filename_encoding.c
libarchive/test/test_pax_filename_encoding_freebsd.c [deleted file]

index 6b28b5460ca1c358ca2488eccb3f1eab0de26dbd..2470114adc560fd4a974b7ee9a324d407be8a22d 100644 (file)
@@ -273,7 +273,6 @@ libarchive_test_SOURCES=                                    \
        libarchive/test/test_open_file.c                        \
        libarchive/test/test_open_filename.c                    \
        libarchive/test/test_pax_filename_encoding.c            \
-       libarchive/test/test_pax_filename_encoding_freebsd.c    \
        libarchive/test/test_read_compress_program.c            \
        libarchive/test/test_read_data_large.c                  \
        libarchive/test/test_read_disk.c                        \
index 11f7140fd164533b971bb4cfcd41a56fd659e04a..99deeff5a42cfe16c9c67cea90f6db39b938731f 100644 (file)
@@ -42,7 +42,6 @@ IF(ENABLE_TEST)
     test_open_file.c
     test_open_filename.c
     test_pax_filename_encoding.c
-    test_pax_filename_encoding_freebsd.c
     test_read_compress_program.c
     test_read_data_large.c
     test_read_disk.c
index e9d8f1974339a03d66f384127d9f92bf54f928e1..969e3de83863e73893f6bb53958aff68ccf3f7e0 100644 (file)
@@ -325,9 +325,80 @@ test_pax_filename_encoding_3(void)
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
+/*
+ * Verify that KOI8-R filenames are correctly translated to Unicode and UTF-8.
+ */
+static void
+test_pax_filename_encoding_ru_RU()
+{
+       struct archive *a;
+       struct archive_entry *entry;
+       char buff[4096];
+       size_t used;
+
+       if (NULL == setlocale(LC_ALL, "ru_RU.KOI8-R")) {
+               skipping("KOI8-R locale not available on this system.");
+               return;
+       }
+
+       a = archive_write_new();
+       assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+       assertEqualInt(ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
+
+       entry = archive_entry_new2(a);
+       archive_entry_set_pathname(entry, "\xD0\xD2\xC9");
+       archive_entry_set_filetype(entry, AE_IFREG);
+       archive_entry_set_size(entry, 0);
+       assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
+       archive_entry_free(entry);
+       assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+       /* Above three characters in KOI8-R should translate to the following
+        * three characters (two bytes each) in UTF-8. */
+       assertEqualMem(buff + 512, "15 path=\xD0\xBF\xD1\x80\xD0\xB8\x0A", 15);
+}
+
+/*
+ * Verify that EUC-JP filenames are correctly translated to Unicode and UTF-8.
+ */
+static void
+test_pax_filename_encoding_ja_JP()
+{
+       struct archive *a;
+       struct archive_entry *entry;
+       char buff[4096];
+       wchar_t ws[] = {0x8868, L'.', L't', L'x', L't', 0};
+       size_t used;
+
+       if (NULL == setlocale(LC_ALL, "ja_JP.eucJP")) {
+               skipping("eucJP locale not available on this system.");
+               return;
+       }
+
+       a = archive_write_new();
+       assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+       assertEqualInt(ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
+
+       entry = archive_entry_new2(a);
+       archive_entry_set_pathname(entry, "\xC9\xBD.txt");
+       /* Check the Unicode version. */
+       assertEqualMem(ws, archive_entry_pathname_w(entry), sizeof(ws));
+       archive_entry_set_filetype(entry, AE_IFREG);
+       archive_entry_set_size(entry, 0);
+       assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
+       archive_entry_free(entry);
+       assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+       /* Check UTF-8 version. */
+       assertEqualMem(buff + 512, "16 path=\xE8\xA1\xA8.txt\x0A", 16);
+
+}
+
 DEFINE_TEST(test_pax_filename_encoding)
 {
        test_pax_filename_encoding_1();
        test_pax_filename_encoding_2();
        test_pax_filename_encoding_3();
+       test_pax_filename_encoding_ru_RU();
+       test_pax_filename_encoding_ja_JP();
 }
diff --git a/libarchive/test/test_pax_filename_encoding_freebsd.c b/libarchive/test/test_pax_filename_encoding_freebsd.c
deleted file mode 100644 (file)
index ef29b9f..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*-
- * Copyright (c) 2003-2011 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-#include <locale.h>
-
-/*
- * Pax interchange is supposed to encode filenames into
- * UTF-8.
- */
-
-static void
-test_pax_filename_encoding_ru_RU()
-{
-       struct archive *a;
-       struct archive_entry *entry;
-       char buff[4096];
-       size_t used;
-
-       if (NULL == setlocale(LC_ALL, "ru_RU.KOI8-R")) {
-               skipping("KOI8-R locale not available on this system.");
-               return;
-       }
-
-       a = archive_write_new();
-       assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
-       assertEqualInt(ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
-
-       entry = archive_entry_new2(a);
-       archive_entry_set_pathname(entry, "\xD0\xD2\xC9");
-       archive_entry_set_filetype(entry, AE_IFREG);
-       archive_entry_set_size(entry, 0);
-       assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
-       archive_entry_free(entry);
-       assertEqualInt(ARCHIVE_OK, archive_write_free(a));
-
-       /* Above three characters in KOI8-R should translate to the following
-        * three characters (two bytes each) in UTF-8. */
-       assertEqualMem(buff + 512, "15 path=\xD0\xBF\xD1\x80\xD0\xB8\x0A", 15);
-}
-
-static void
-test_pax_filename_encoding_ja_JP()
-{
-       struct archive *a;
-       struct archive_entry *entry;
-       char buff[4096];
-       wchar_t ws[] = {0x8868, L'.', L't', L'x', L't', 0};
-       size_t used;
-
-       if (NULL == setlocale(LC_ALL, "ja_JP.eucJP")) {
-               skipping("eucJP locale not available on this system.");
-               return;
-       }
-
-       a = archive_write_new();
-       assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
-       assertEqualInt(ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
-
-       entry = archive_entry_new2(a);
-       archive_entry_set_pathname(entry, "\xC9\xBD.txt");
-       /* Check the Unicode version. */
-       assertEqualMem(ws, archive_entry_pathname_w(entry), sizeof(ws));
-       archive_entry_set_filetype(entry, AE_IFREG);
-       archive_entry_set_size(entry, 0);
-       assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
-       archive_entry_free(entry);
-       assertEqualInt(ARCHIVE_OK, archive_write_free(a));
-
-       /* Check UTF-8 version. */
-       assertEqualMem(buff + 512, "16 path=\xE8\xA1\xA8.txt\x0A", 16);
-
-}
-
-DEFINE_TEST(test_pax_filename_encoding_freebsd)
-{
-       test_pax_filename_encoding_ru_RU();
-       test_pax_filename_encoding_ja_JP();
-}