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 <wchar.h> 19#include "test.h" 20 21/** 22 * @tc.name : wmemmove_0100 23 * @tc.desc : Copies the specified number of wide characters from the source to the destination 24 * @tc.level : Level 0 25 */ 26void wmemmove_0100(void) 27{ 28 wchar_t dest[] = L"This is a c test for wmemmove function"; 29 const wchar_t src[] = L"src content"; 30 int count = 5; 31 wchar_t tmp[count + 1]; 32 wcsncpy(tmp, src, count); 33 wmemmove(dest, src, count); 34 if (wcsncmp(dest, tmp, count)) { 35 t_error("The dest specified bits are not equal to the src\n", __func__); 36 } 37} 38 39/** 40 * @tc.name : wmemmove_0200 41 * @tc.desc : Dest and src overlaps 42 * @tc.level : Level 1 43 */ 44void wmemmove_0200(void) 45{ 46 wchar_t src[] = L"This is a c test for wmemmove function"; 47 wchar_t *dest = &src[2]; 48 int count = 5; 49 wchar_t tmp[count + 1]; 50 wcsncpy(tmp, src, count); 51 wmemmove(dest, src, count); 52 if (wcsncmp(dest, tmp, count)) { 53 t_error("The dest specified bits are not equal to the src\n", __func__); 54 } 55} 56 57/** 58 * @tc.name : wmemmove_0300 59 * @tc.desc : The first address of dest is the same as src 60 * @tc.level : Level 1 61 */ 62void wmemmove_0300(void) 63{ 64 wchar_t src[] = L"This is a c test for wmemmove function"; 65 wchar_t *dest = &src[0]; 66 int count = 5; 67 wchar_t *result = wmemmove(dest, src, count); 68 if (!(result == dest)) { 69 t_error("The first address of dest is not the same as src\n", __func__); 70 } 71} 72 73int main(int argc, char *argv[]) 74{ 75 wmemmove_0100(); 76 wmemmove_0200(); 77 wmemmove_0300(); 78 return t_status; 79}