From nobody Sat Oct 29 21:10:52 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N0BsT1K8dz4gsh5; Sat, 29 Oct 2022 21:10:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N0BsT0q0Cz3Zby; Sat, 29 Oct 2022 21:10:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667077853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5ub9pBvUxBZtttgINMBnraF4NbyjZbqVnHeG+YxHFts=; b=A4Kc0pVvpKADt2sEmr4GD7FY75w6leGnOgw9AzpUUcgvGcso3Clv95itGE8VRNUVt+Rfa3 v0rjsYBWbz88OZ/2gG+zZoaZVF8Iz1NceSnQIwXMJaK+JMHaK0MwxWSMWLT35KIJY6ribu oYmVlhyx6lL6qrCnFi110hvywB3XpsAo7v/0OuPgYDWKejJAEwyZ20CWFe2oyw6z9hCgx7 325GbT9flLGzE9XI9Bh1BqsTPWen9nfhIAmxNY8FwrZUuZc7E8uTankIC5wPy3V9LbMp1j yR0MaMZuoLp/Xg5rKR/0P/cPqeQxJsWg7clkZ+nqp/gHZgaGcE1U1QVVOjwetw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N0BsS726czX3S; Sat, 29 Oct 2022 21:10:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29TLAqYh067988; Sat, 29 Oct 2022 21:10:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29TLAqOa067987; Sat, 29 Oct 2022 21:10:52 GMT (envelope-from git) Date: Sat, 29 Oct 2022 21:10:52 GMT Message-Id: <202210292110.29TLAqOa067987@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 29972f06f95d - main - strfmon_test: Add a test for strfmon_l List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 29972f06f95d6f5f550ac81367d5ebda8d6860a8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667077853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5ub9pBvUxBZtttgINMBnraF4NbyjZbqVnHeG+YxHFts=; b=GaAkT22egRxKXZ7kem28imcdQImMZQQo18q1ze3c8alOkLU8AKyRrzG73yTpkNr7wGmLiB lxVzda6d0dHHRkHo6IIVchQxVu8XNcJvIbLzUMaxLxJSvcfepsflhG2rXtCTWyytG+85ry N/PZ6ra+UjSSjBXqDdOF5NoGk/DEyitiN2a1eWiQ9Mdk/+eAPFi+B6+onnE78QxY19VK7a DK0CLltbDpw+SYxIgI9HRP7UaIrEBL/5ZITdyHR3PIi6OuSWQplWcG4CtDFSna00XKJUa0 e8NNRKwzlq2/GT9pXaIMJYjhOj71cs4vWAJ0k0XfAVWREoie6XHpO6QTNUjoYg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667077853; a=rsa-sha256; cv=none; b=Y1fCqr0JE5i8cILE3QUumy2S5Pu1PyAvmPYVn2jT8K8ENsRa1t3sB1sV5H6gzzBywvq8R4 pXqVv1ntH5k9fDZ6WTE3uA5JWhEEjXZeU/iXpxg9lQa1HZh5xswPMbxDC+uL30Qx05j2uT iGMty1K2wEhbAbCIi6DRFQ1QlMuOMrF9kh6TX/Rc0WJ5t/1k5rkkfJ+h3BWl4SbrRWcPMC /uIhar0elMeENpiliKi+vbmL1OplQKZPzkJ0v9ZaFy6xU4oPVz1DdzhQAJXzBUL253zfwF Af6mYy8xXTxUHgCm7Cl9hAv3ly0NlkDoeVIvLAfrkUl1jQ1F1RWdZQTUyWlFeA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=29972f06f95d6f5f550ac81367d5ebda8d6860a8 commit 29972f06f95d6f5f550ac81367d5ebda8d6860a8 Author: Jose Luis Duran AuthorDate: 2022-10-28 02:53:43 +0000 Commit: Konstantin Belousov CommitDate: 2022-10-29 21:08:54 +0000 strfmon_test: Add a test for strfmon_l Attempt to test the correctness of strfmon_l(3). Items marked with XXX represent an invalid output. Obtained from: https://github.com/NetBSD/src/commit/e7eba0044fe6128291cbb7e5923c7cf7d87318cc Reviewed by: kib PR: 267410 Github PR: #620 MFC after: 1 week --- lib/libc/tests/stdlib/strfmon_test.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/libc/tests/stdlib/strfmon_test.c b/lib/libc/tests/stdlib/strfmon_test.c index c2fa6250dc58..dcad17d3dbfd 100644 --- a/lib/libc/tests/stdlib/strfmon_test.c +++ b/lib/libc/tests/stdlib/strfmon_test.c @@ -211,6 +211,38 @@ ATF_TC_BODY(strfmon_international_currency_code, tc) } } +ATF_TC(strfmon_l); +ATF_TC_HEAD(strfmon_l, tc) +{ + atf_tc_set_md_var(tc, "descr", + "checks strfmon_l under different locales"); +} +ATF_TC_BODY(strfmon_l, tc) +{ + const struct { + const char *locale; + const char *expected; + } tests[] = { + { "C", "[ **1234.57 ] [ **1234.57 ]" }, + { "de_DE.UTF-8", "[ €**1234.57 ] [ EUR**1234.57 ]" }, /* XXX */ + { "en_GB.UTF-8", "[ £**1234.57 ] [ GBP**1234.57 ]" }, /* XXX */ + }; + locale_t loc; + size_t i; + char buf[100]; + + for (i = 0; i < nitems(tests); ++i) { + loc = newlocale(LC_MONETARY_MASK, tests[i].locale, NULL); + ATF_REQUIRE(loc != NULL); + + strfmon_l(buf, sizeof(buf) - 1, loc, "[%^=*#6n] [%=*#6i]", + 1234.567, 1234.567); + ATF_REQUIRE_STREQ(tests[i].expected, buf); + + freelocale(loc); + } +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strfmon_locale_thousands); @@ -218,5 +250,6 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, strfmon_cs_precedes_0); ATF_TP_ADD_TC(tp, strfmon_cs_precedes_1); ATF_TP_ADD_TC(tp, strfmon_international_currency_code); + ATF_TP_ADD_TC(tp, strfmon_l); return (atf_no_error()); }