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 "functionalext.h"
17
18 const char *path = "/data/tests/libc-test/src/functionalext/supplement/stdio/fputc.txt";
19
20 /**
21 * @tc.name : fputc_0100
22 * @tc.desc : Verify that a character can be written to the file
23 * @tc.level : level 0.
24 */
fputc_0100(void)25 void fputc_0100(void)
26 {
27 FILE *fptr = fopen(path, "w");
28 int Exit = fputc('a', fptr);
29 EXPECT_EQ("fputc_0100", Exit, 97);
30 fclose(fptr);
31 }
32
33 /**
34 * @tc.name : fputc_0200
35 * @tc.desc : Verify that a character cannot be written to the file
36 * @tc.level : level 2.
37 */
fputc_0200(void)38 void fputc_0200(void)
39 {
40 FILE *fptr = fopen(path, "r");
41 int Exit = fputc('a', fptr);
42 EXPECT_EQ("fputc_0200", Exit, EOF);
43 fclose(fptr);
44 remove(path);
45 }
46
main(void)47 int main(void)
48 {
49 fputc_0100();
50 fputc_0200();
51 return t_status;
52 }