11.1Sriastrad/* $NetBSD: t_c32rtomb.c,v 1.1 2024/08/15 14:16:34 riastradh Exp $ */ 21.1Sriastrad 31.1Sriastrad/*- 41.1Sriastrad * Copyright (c) 2024 The NetBSD Foundation, Inc. 51.1Sriastrad * All rights reserved. 61.1Sriastrad * 71.1Sriastrad * Redistribution and use in source and binary forms, with or without 81.1Sriastrad * modification, are permitted provided that the following conditions 91.1Sriastrad * are met: 101.1Sriastrad * 1. Redistributions of source code must retain the above copyright 111.1Sriastrad * notice, this list of conditions and the following disclaimer. 121.1Sriastrad * 2. Redistributions in binary form must reproduce the above copyright 131.1Sriastrad * notice, this list of conditions and the following disclaimer in the 141.1Sriastrad * documentation and/or other materials provided with the distribution. 151.1Sriastrad * 161.1Sriastrad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 171.1Sriastrad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 181.1Sriastrad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 191.1Sriastrad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 201.1Sriastrad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 211.1Sriastrad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 221.1Sriastrad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 231.1Sriastrad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 241.1Sriastrad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 251.1Sriastrad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 261.1Sriastrad * POSSIBILITY OF SUCH DAMAGE. 271.1Sriastrad */ 281.1Sriastrad 291.1Sriastrad#include <sys/cdefs.h> 301.1Sriastrad__RCSID("$NetBSD: t_c32rtomb.c,v 1.1 2024/08/15 14:16:34 riastradh Exp $"); 311.1Sriastrad 321.1Sriastrad#include <atf-c.h> 331.1Sriastrad#include <locale.h> 341.1Sriastrad#include <uchar.h> 351.1Sriastrad 361.1Sriastrad#include "h_macros.h" 371.1Sriastrad 381.1SriastradATF_TC(c32rtomb_null); 391.1SriastradATF_TC_HEAD(c32rtomb_null, tc) 401.1Sriastrad{ 411.1Sriastrad atf_tc_set_md_var(tc, "descr", "Test null string output to c32rtomb"); 421.1Sriastrad} 431.1SriastradATF_TC_BODY(c32rtomb_null, tc) 441.1Sriastrad{ 451.1Sriastrad char *locale; 461.1Sriastrad mbstate_t ps = {0}; 471.1Sriastrad size_t n; 481.1Sriastrad 491.1Sriastrad REQUIRE_LIBC((locale = setlocale(LC_ALL, "C")), NULL); 501.1Sriastrad ATF_REQUIRE_EQ_MSG(strcmp(locale, "C"), 0, "locale=%s", locale); 511.1Sriastrad 521.1Sriastrad ATF_CHECK_EQ_MSG((n = c32rtomb(NULL, L'x', &ps)), 1, "n=%zu", n); 531.1Sriastrad} 541.1Sriastrad 551.1SriastradATF_TP_ADD_TCS(tp) 561.1Sriastrad{ 571.1Sriastrad 581.1Sriastrad ATF_TP_ADD_TC(tp, c32rtomb_null); 591.1Sriastrad return atf_no_error(); 601.1Sriastrad} 61