1// RUN: %clangxx -g %s -o %t && %run %t
2
3#include <assert.h>
4#include <stdio.h>
5
6int main(int argc, char **argv) {
7 FILE *fp = fopen(filename: argv[0], modes: "r");
8 assert(fp);
9
10 char buf[2];
11 char *s = fgets(s: buf, n: sizeof(buf), stream: fp);
12 assert(s);
13
14 assert(!fclose(fp));
15 return 0;
16}
17

source code of compiler-rt/test/sanitizer_common/TestCases/Posix/fgets.cpp