summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/minmax_char_1.f90
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.dg/minmax_char_1.f90
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gfortran.dg/minmax_char_1.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/minmax_char_1.f9073
1 files changed, 73 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/minmax_char_1.f90 b/gcc/testsuite/gfortran.dg/minmax_char_1.f90
new file mode 100644
index 000000000..9e73e9850
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/minmax_char_1.f90
@@ -0,0 +1,73 @@
+! Tests for MIN and MAX intrinsics with character arguments
+!
+! { dg-do run }
+program test
+ character(len=3), parameter :: sp = "gee"
+ character(len=6), parameter :: tp = "crunch", wp = "flunch"
+ character(len=2), parameter :: up = "az", vp = "da"
+
+ character(len=3) :: s
+ character(len=6) :: t, w
+ character(len=2) :: u, v
+ s = "gee"
+ t = "crunch"
+ u = "az"
+ v = "da"
+ w = "flunch"
+
+ if (.not. equal(min("foo", "bar"), "bar")) call abort
+ if (.not. equal(max("foo", "bar"), "foo")) call abort
+ if (.not. equal(min("bar", "foo"), "bar")) call abort
+ if (.not. equal(max("bar", "foo"), "foo")) call abort
+
+ if (.not. equal(min("bar", "foo", sp), "bar")) call abort
+ if (.not. equal(max("bar", "foo", sp), "gee")) call abort
+ if (.not. equal(min("bar", sp, "foo"), "bar")) call abort
+ if (.not. equal(max("bar", sp, "foo"), "gee")) call abort
+ if (.not. equal(min(sp, "bar", "foo"), "bar")) call abort
+ if (.not. equal(max(sp, "bar", "foo"), "gee")) call abort
+
+ if (.not. equal(min("foo", "bar", s), "bar")) call abort
+ if (.not. equal(max("foo", "bar", s), "gee")) call abort
+ if (.not. equal(min("foo", s, "bar"), "bar")) call abort
+ if (.not. equal(max("foo", s, "bar"), "gee")) call abort
+ if (.not. equal(min(s, "foo", "bar"), "bar")) call abort
+ if (.not. equal(max(s, "foo", "bar"), "gee")) call abort
+
+ if (.not. equal(min("", ""), "")) call abort
+ if (.not. equal(max("", ""), "")) call abort
+ if (.not. equal(min("", " "), " ")) call abort
+ if (.not. equal(max("", " "), " ")) call abort
+
+ if (.not. equal(min(u,v,w), "az ")) call abort
+ if (.not. equal(max(u,v,w), "flunch")) call abort
+ if (.not. equal(min(u,vp,w), "az ")) call abort
+ if (.not. equal(max(u,vp,w), "flunch")) call abort
+ if (.not. equal(min(u,v,wp), "az ")) call abort
+ if (.not. equal(max(u,v,wp), "flunch")) call abort
+ if (.not. equal(min(up,v,w), "az ")) call abort
+ if (.not. equal(max(up,v,w), "flunch")) call abort
+
+ call foo("gee ","az ",s,t,u,v)
+ call foo("gee ","az ",s,t,u,v)
+ call foo("gee ","az ",s,t,u)
+ call foo("gee ","crunch",s,t)
+
+contains
+
+ subroutine foo(res_max, res_min, a, b, c, d)
+ character(len=*) :: res_min, res_max
+ character(len=*), optional :: a, b, c, d
+
+ if (.not. equal(min(a,b,c,d), res_min)) call abort
+ if (.not. equal(max(a,b,c,d), res_max)) call abort
+ end subroutine foo
+
+ pure function equal(a,b)
+ character(len=*), intent(in) :: a, b
+ logical :: equal
+
+ equal = (len(a) == len(b)) .and. (a == b)
+ end function equal
+
+end program test