aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/fgetc_2.f90
blob: 6dd12c4e242bad6399083cc076cdc1f37b33de9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
! Testcase for the FGETC and FPUTC intrinsics
! { dg-do run }
  character(len=5) s
  integer st

  s = "12345"
  open(10,status="scratch")
  write(10,"(A)") "abcde"
  rewind(10)
  st = fgetc(10,s)
  if ((st /= 0) .or. (s /= "a    ")) call abort
  st = fgetc(10,s)
  close(10)

  open(10,status="scratch")
  s = "12345"
  st = fputc(10,s)
  if (st /= 0) call abort
  st = fputc(10,"2")
  if (st /= 0) call abort
  st = fputc(10,"3 ")
  if (st /= 0) call abort
  rewind(10)
  st = fgetc(10,s)
  if (s(1:1) /= "1") call abort
  st = fgetc(10,s)
  if (s(1:1) /= "2") call abort
  st = fgetc(10,s)
  if ((s(1:1) /= "3") .or. (st /= 0)) call abort
  st = fgetc(10,s)
  if (st /= -1) call abort
  close (10)

! FGETC and FPUTC on units not opened should not work
  st = fgetc(12,s)
  if (st /= -1) call abort
  st = fputc(12,s)
  if (st /= -1) call abort
  end