From c0d81bd8ecba548698172d64ac85a3ea3bc61ec3 Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Fri, 13 Jun 2008 20:35:12 +0000 Subject: [PATCH] re PR libfortran/35863 ([F2003] Implement ENCODING="UTF-8") 2008-06-13 Jerry DeLisle PR fortran/35863 * gfortran.dg/widechar_IO_1.f90: New test. * gfortran.dg/widechar_IO_2.f90: New test. * gfortran.dg/widechar_IO_3.f90: New test. * gfortran.dg/widechar_IO_4.f90: New test. From-SVN: r136766 --- gcc/testsuite/ChangeLog | 8 +++++++ gcc/testsuite/gfortran.dg/widechar_IO_1.f90 | 20 ++++++++++++++++++ gcc/testsuite/gfortran.dg/widechar_IO_2.f90 | 19 +++++++++++++++++ gcc/testsuite/gfortran.dg/widechar_IO_3.f90 | 23 +++++++++++++++++++++ gcc/testsuite/gfortran.dg/widechar_IO_4.f90 | 18 ++++++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/widechar_IO_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/widechar_IO_2.f90 create mode 100644 gcc/testsuite/gfortran.dg/widechar_IO_3.f90 create mode 100644 gcc/testsuite/gfortran.dg/widechar_IO_4.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 333db9a73ca..dd044c2b2df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2008-06-13 Jerry DeLisle + + PR fortran/35863 + * gfortran.dg/widechar_IO_1.f90: New test. + * gfortran.dg/widechar_IO_2.f90: New test. + * gfortran.dg/widechar_IO_3.f90: New test. + * gfortran.dg/widechar_IO_4.f90: New test. + 2008-06-13 Tobias Burnus PR fortran/36476 diff --git a/gcc/testsuite/gfortran.dg/widechar_IO_1.f90 b/gcc/testsuite/gfortran.dg/widechar_IO_1.f90 new file mode 100644 index 00000000000..0fe479cda64 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/widechar_IO_1.f90 @@ -0,0 +1,20 @@ +! { dg-do run } +! Wide chracter I/O test 1, formatted and mixed kind +! Test case developed by Jerry DeLisle +program test1 + integer, parameter :: k4 = 4 + character(len=10,kind=4) :: wide + character(len=10,kind=1) :: thin + character(kind=1,len=25) :: buffer + wide=k4_"Goodbye!" + thin="Hello!" + write(buffer, '(a)') wide + if (buffer /= "Goodbye!") call abort + open(10, form="formatted", access="stream", status="scratch") + write(10, '(a)') thin + rewind(10) + read(10, '(a)') wide + if (wide /= k4_"Hello!") call abort + write(buffer,*) thin, ">",wide,"<" + if (buffer /= " Hello! >Hello! <") call abort +end program test1 diff --git a/gcc/testsuite/gfortran.dg/widechar_IO_2.f90 b/gcc/testsuite/gfortran.dg/widechar_IO_2.f90 new file mode 100644 index 00000000000..6b13e4f93f1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/widechar_IO_2.f90 @@ -0,0 +1,19 @@ +! { dg-do run } +! Wide chracter I/O test 2, formatted array write and read +! Test case developed by Jerry DeLisle +program chkdata + integer, parameter :: k4=4 + character(len=7, kind=k4), dimension(3) :: mychar + character(50) :: buffer + mychar(1) = k4_"abc1234" + mychar(2) = k4_"def5678" + mychar(3) = k4_"ghi9012" + buffer = "" + write(buffer,'(3(a))') mychar(2:3), mychar(1) + if (buffer /= "def5678ghi9012abc1234") call abort + write(buffer,'(3(a))') mychar + if (buffer /= "abc1234def5678ghi9012") call abort + mychar = "" + read(buffer,'(3(a))') mychar + if (any(mychar.ne.[ k4_"abc1234",k4_"def5678",k4_"ghi9012" ])) call abort +end program chkdata diff --git a/gcc/testsuite/gfortran.dg/widechar_IO_3.f90 b/gcc/testsuite/gfortran.dg/widechar_IO_3.f90 new file mode 100644 index 00000000000..6f4a10c857e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/widechar_IO_3.f90 @@ -0,0 +1,23 @@ +! { dg-do run } +! Wide chracter I/O test 3, unformatted arrays +! Test case developed by Jerry DeLisle +program test1 + integer, parameter :: k4 = 4 + character(len=10,kind=4) :: wide + character(len=10,kind=4), dimension(5,7) :: widearray + wide = k4_"abcdefg" + widearray = k4_"1234abcd" + open(10, form="unformatted", status="scratch") + write(10) wide + rewind(10) + wide = "wrong" + read(10) wide + if (wide /= k4_"abcdefg") call abort + rewind(10) + write(10) widearray(2:4,3:7) + widearray(2:4,3:7)="" + rewind(10) + read(10) widearray(2:4,3:7) + close(10) + if (any(widearray.ne.k4_"1234abcd")) call abort +end program test1 diff --git a/gcc/testsuite/gfortran.dg/widechar_IO_4.f90 b/gcc/testsuite/gfortran.dg/widechar_IO_4.f90 new file mode 100644 index 00000000000..e108b15c4f5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/widechar_IO_4.f90 @@ -0,0 +1,18 @@ +! { dg-do run } +! { dg-options -fbackslash } +! Wide chracter I/O test 4, formatted ISO-8859-1 characters in string +! Test case developed by Jerry DeLisle +! Compile with -fbackslash +integer, parameter :: k4 = 4 +character(kind=1,len=15) :: buffer +character(kind=1, len=1) :: c1, c2 +character(kind=4,len=20) :: str = k4_'X\xF8öABC' ! ISO-8859-1 encoded string +buffer = "" +write(buffer,'(3a)')':',trim(str),':' +if (buffer.ne.':X\xF8öABC: ') call abort +str = "" +read(buffer,'(3a)') c1,str(1:6),c2 +if (c1.ne.':') call abort +if (str.ne.k4_'X\xF8öAB') call abort +if (c2.ne.'C') call abort +end -- 2.30.2