1 ! Tests for MIN and MAX intrinsics with character arguments
5 character(len
=3), parameter :: sp
= "gee"
6 character(len
=6), parameter :: tp
= "crunch", wp
= "flunch"
7 character(len
=2), parameter :: up
= "az", vp
= "da"
10 character(len
=6) :: t
, w
11 character(len
=2) :: u
, v
18 if (.not
. equal(min("foo", "bar"), "bar")) call abort
19 if (.not
. equal(max("foo", "bar"), "foo")) call abort
20 if (.not
. equal(min("bar", "foo"), "bar")) call abort
21 if (.not
. equal(max("bar", "foo"), "foo")) call abort
23 if (.not
. equal(min("bar", "foo", sp
), "bar")) call abort
24 if (.not
. equal(max("bar", "foo", sp
), "gee")) call abort
25 if (.not
. equal(min("bar", sp
, "foo"), "bar")) call abort
26 if (.not
. equal(max("bar", sp
, "foo"), "gee")) call abort
27 if (.not
. equal(min(sp
, "bar", "foo"), "bar")) call abort
28 if (.not
. equal(max(sp
, "bar", "foo"), "gee")) call abort
30 if (.not
. equal(min("foo", "bar", s
), "bar")) call abort
31 if (.not
. equal(max("foo", "bar", s
), "gee")) call abort
32 if (.not
. equal(min("foo", s
, "bar"), "bar")) call abort
33 if (.not
. equal(max("foo", s
, "bar"), "gee")) call abort
34 if (.not
. equal(min(s
, "foo", "bar"), "bar")) call abort
35 if (.not
. equal(max(s
, "foo", "bar"), "gee")) call abort
37 if (.not
. equal(min("", ""), "")) call abort
38 if (.not
. equal(max("", ""), "")) call abort
39 if (.not
. equal(min("", " "), " ")) call abort
40 if (.not
. equal(max("", " "), " ")) call abort
42 if (.not
. equal(min(u
,v
,w
), "az ")) call abort
43 if (.not
. equal(max(u
,v
,w
), "flunch")) call abort
44 if (.not
. equal(min(u
,vp
,w
), "az ")) call abort
45 if (.not
. equal(max(u
,vp
,w
), "flunch")) call abort
46 if (.not
. equal(min(u
,v
,wp
), "az ")) call abort
47 if (.not
. equal(max(u
,v
,wp
), "flunch")) call abort
48 if (.not
. equal(min(up
,v
,w
), "az ")) call abort
49 if (.not
. equal(max(up
,v
,w
), "flunch")) call abort
51 call foo("gee ","az ",s
,t
,u
,v
)
52 call foo("gee ","az ",s
,t
,u
,v
)
53 call foo("gee ","az ",s
,t
,u
)
54 call foo("gee ","crunch",s
,t
)
58 subroutine foo(res_max
, res_min
, a
, b
, c
, d
)
59 character(len
=*) :: res_min
, res_max
60 character(len
=*), optional
:: a
, b
, c
, d
62 if (.not
. equal(min(a
,b
,c
,d
), res_min
)) call abort
63 if (.not
. equal(max(a
,b
,c
,d
), res_max
)) call abort
66 pure
function equal(a
,b
)
67 character(len
=*), intent(in
) :: a
, b
70 equal
= (len(a
) == len(b
)) .and
. (a
== b
)