Skip to content

Commit 0daa4d8

Browse files
committed
add self swap tests
1 parent 0fa4450 commit 0daa4d8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/math/test_stdlib_math.fypp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ contains
269269
if (allocated(error)) return
270270
call check(error, all( y == [${t1}$ :: 1, 2, 3] ) )
271271
if (allocated(error)) return
272+
273+
! check self swap
274+
call swap(x,x)
275+
276+
call check(error, all( x == [${t1}$ :: 4, 5, 6] ) )
277+
if (allocated(error)) return
272278
end subroutine test_swap_${k1}$
273279
#:endfor
274280

@@ -286,6 +292,12 @@ contains
286292
if (allocated(error)) return
287293
call check(error, all( y == cmplx( [1, 2, 3] , [4, 5, 6] ) ) )
288294
if (allocated(error)) return
295+
296+
! check self swap
297+
call swap(x,x)
298+
299+
call check(error, all( x == cmplx( [4, 5, 6] , [1, 2, 3] ) ) )
300+
if (allocated(error)) return
289301
end subroutine test_swap_c${k1}$
290302
#:endfor
291303

@@ -302,6 +314,12 @@ contains
302314
if (allocated(error)) return
303315
call check(error, all( y == ['abcde','fghij'] ) )
304316
if (allocated(error)) return
317+
318+
! check self swap
319+
call swap(x,x)
320+
321+
call check(error, all( x == ['fghij','abcde'] ) )
322+
if (allocated(error)) return
305323
end subroutine test_swap_str
306324

307325
#:for k1 in CMPLX_KINDS

0 commit comments

Comments
 (0)