[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / gfortran.dg / fseek.f90
blob9e3c7195a3a327fb6a4e0f7efd7a1890eea1e5b9
1 ! { dg-do run }
3 PROGRAM test_fseek
4 INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2, fd=10
5 INTEGER :: ierr = 0
6 INTEGER :: newline_length
8 ! We first need to determine if a newline is one or two characters
9 open (911,status="scratch")
10 write(911,"()")
11 newline_length = ftell(911)
12 close (911)
13 if (newline_length < 1 .or. newline_length > 2) call abort()
15 open(fd, status="scratch")
16 ! expected position: one leading blank + 10 + newline
17 WRITE(fd, *) "1234567890"
18 IF (FTELL(fd) /= 11 + newline_length) CALL abort()
20 ! move backward from current position
21 CALL FSEEK(fd, -11 - newline_length, SEEK_CUR, ierr)
22 IF (ierr /= 0 .OR. FTELL(fd) /= 0) CALL abort()
24 ! move to negative position (error)
25 CALL FSEEK(fd, -1, SEEK_SET, ierr)
26 IF (ierr == 0 .OR. FTELL(fd) /= 0) CALL abort()
28 ! move forward from end (11 + 10 + newline)
29 CALL FSEEK(fd, 10, SEEK_END, ierr)
30 IF (ierr /= 0 .OR. FTELL(fd) /= 21 + newline_length) CALL abort()
32 ! set position (0)
33 CALL FSEEK(fd, 0, SEEK_SET, ierr)
34 IF (ierr /= 0 .OR. FTELL(fd) /= 0) CALL abort()
36 ! move forward from current position
37 CALL FSEEK(fd, 5, SEEK_CUR, ierr)
38 IF (ierr /= 0 .OR. FTELL(fd) /= 5) CALL abort()
40 CALL FSEEK(fd, HUGE(0_1), SEEK_SET, ierr)
41 IF (ierr /= 0 .OR. FTELL(fd) /= HUGE(0_1)) CALL abort()
43 CALL FSEEK(fd, HUGE(0_2), SEEK_SET, ierr)
44 IF (ierr /= 0 .OR. FTELL(fd) /= HUGE(0_2)) CALL abort()
46 CALL FSEEK(fd, HUGE(0_4), SEEK_SET, ierr)
47 IF (ierr /= 0 .OR. FTELL(fd) /= HUGE(0_4)) CALL abort()
49 CALL FSEEK(fd, -HUGE(0_4), SEEK_CUR, ierr)
50 IF (ierr /= 0 .OR. FTELL(fd) /= 0) CALL abort()
51 END PROGRAM