glibc/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/test.c
Sergey Kolosov ab4bc8a24e Extend the test coverage
Move some of the RHEL QE testcases upstream to Fedora.
2022-05-31 09:29:27 +02:00

37 lines
617 B
C

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main(int argc, char** argv)
{
FILE *fp;
#ifdef UTF8
setlocale(LC_ALL, "en_US.utf8");
#else
setlocale(LC_ALL, "en_US");
#endif
fp = fopen("output.txt", "w+");
if (fp == NULL) {
perror("fopen");
exit(1);
}
if (fputws(L"abc\n", fp) == -1) {
perror("fputws");
exit(1);
}
printf("before=%d\n", ftell(fp));
if (fseek(fp, 0L, SEEK_END) == -1) {
perror("fseek");
exit(1);
}
printf("fseek=%d\n", ftell(fp));
if (fputws(L"xyz\n", fp) == -1) {
perror("fputws");
exit(1);
}
printf("after=%d\n", ftell(fp));
fclose(fp);
return 0;
}