1b9128a37SMartin Matuska /* 2*bd66c1b4SMartin Matuska * SPDX-License-Identifier: BSD-2-Clause 3*bd66c1b4SMartin Matuska * 4b9128a37SMartin Matuska * Copyright (c) 2023 Aaron Lindros 5b9128a37SMartin Matuska * All rights reserved. 6b9128a37SMartin Matuska */ 7b9128a37SMartin Matuska #include "test.h" 8b9128a37SMartin Matuska 913d826ffSMartin Matuska #ifdef HAVE_LOCALE_H 1013d826ffSMartin Matuska #include <locale.h> 1113d826ffSMartin Matuska #endif 1213d826ffSMartin Matuska 13b9128a37SMartin Matuska /* Test I arg - file name encoding */ DEFINE_TEST(test_I)14b9128a37SMartin MatuskaDEFINE_TEST(test_I) 15b9128a37SMartin Matuska { 16b9128a37SMartin Matuska const char *reffile = "test_I.zip"; 17*bd66c1b4SMartin Matuska #if !defined(_WIN32) || defined(__CYGWIN__) 18*bd66c1b4SMartin Matuska const char *envstr = "env LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 " 19*bd66c1b4SMartin Matuska "LC_CTYPE=en_US.UTF-8"; 20*bd66c1b4SMartin Matuska #else 21*bd66c1b4SMartin Matuska const char *envstr = ""; 22*bd66c1b4SMartin Matuska #endif 23b9128a37SMartin Matuska int r; 24b9128a37SMartin Matuska 2513d826ffSMartin Matuska #if HAVE_SETLOCALE 2613d826ffSMartin Matuska if (NULL == setlocale(LC_ALL, "en_US.UTF-8")) { 2713d826ffSMartin Matuska skipping("en_US.UTF-8 locale not available on this system."); 2813d826ffSMartin Matuska return; 2913d826ffSMartin Matuska } 3013d826ffSMartin Matuska #else 3113d826ffSMartin Matuska skipping("setlocale() not available on this system."); 3213d826ffSMartin Matuska #endif 3313d826ffSMartin Matuska 34b9128a37SMartin Matuska extract_reference_file(reffile); 35*bd66c1b4SMartin Matuska r = systemf("%s %s -I UTF-8 %s >test.out 2>test.err", envstr, testprog, 36*bd66c1b4SMartin Matuska reffile); 37b9128a37SMartin Matuska assertEqualInt(0, r); 38b9128a37SMartin Matuska assertNonEmptyFile("test.out"); 39b9128a37SMartin Matuska assertEmptyFile("test.err"); 40b9128a37SMartin Matuska 41b9128a37SMartin Matuska assertTextFileContents("Hello, World!\n", "Γειά σου Κόσμε.txt"); 42b9128a37SMartin Matuska } 43