1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include <stdio.h> 17#include <string.h> 18#include <stdlib.h> 19#include <signal.h> 20#include <wchar.h> 21#include <inttypes.h> 22#include "test.h" 23 24void deal_aberrant(int code) 25{ 26 if (code != SIGSEGV) { 27 t_error("wcstoumax_0200 code is %d are not SIGSEGV", __func__, code); 28 } 29 exit(t_status); 30} 31 32/** 33 * @tc.name : wcstoumax_0100 34 * @tc.desc : Test wcstoumax to get numeric part in wide string 35 * @tc.level : Level 0 36 */ 37void wcstoumax_0100(void) 38{ 39 wchar_t *end = NULL; 40 uintmax_t want = 123U; 41 uintmax_t result = wcstoumax(L" +123x", &end, 10); 42 if (result != want) { 43 t_error("%s wcstoumax get result is %d are not want 123U\n", __func__, result); 44 } 45 if (wcscmp(end, L"x") != 0) { 46 t_error("%s wcstoumax get end is %ls are not want x\n", __func__, end); 47 } 48} 49 50/** 51 * @tc.name : wcstoumax_0200 52 * @tc.desc : Test the result of the wcstoumax method when the incoming parameter is empty 53 * @tc.level : Level 2 54 */ 55void wcstoumax_0200(void) 56{ 57 signal(SIGSEGV, deal_aberrant); 58 uintmax_t result = wcstoumax(NULL, NULL, 0); 59} 60 61int main(int argc, char *argv[]) 62{ 63 wcstoumax_0100(); 64 wcstoumax_0200(); 65 return t_status; 66}