• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 *ptr = "/data/tests/libc-test/src/functionalext/supplement/stdio/test.txt";
19 
20 /**
21  * @tc.name      : setvbuf_0100
22  * @tc.desc      : Authentication is successful (call the setvbuf function to see the return value)
23  * @tc.level     : Level 0
24  */
setvbuf_0100(void)25 void setvbuf_0100(void)
26 {
27     char buff[1024];
28     FILE *fptr = fopen(ptr, "w+");
29     EXPECT_PTRNE("setvbuf_0100", fptr, NULL);
30 
31     int result = setvbuf(fptr, buff, _IOFBF, 1024);
32     EXPECT_EQ("setvbuf_0100", result, 0);
33 
34     fclose(fptr);
35     remove(ptr);
36 }
37 
38 /**
39  * @tc.name      : setvbuf_0200
40  * @tc.desc      : Authentication is fails (call the setvbuf function to see the return value)
41  * @tc.level     : Level 2
42  */
setvbuf_0200(void)43 void setvbuf_0200(void)
44 {
45     char buff[1024];
46     FILE *fptr = fopen(ptr, "w+");
47     EXPECT_PTRNE("setvbuf_0100", fptr, NULL);
48 
49     int result = setvbuf(fptr, buff, -1, 1024);
50     EXPECT_EQ("setvbuf_0200", result, -1);
51 
52     fclose(fptr);
53     remove(ptr);
54 }
55 
main(int argc,char * argv[])56 int main(int argc, char *argv[])
57 {
58     setvbuf_0100();
59     setvbuf_0200();
60     return t_status;
61 }