Skip to content

Commit 8a5f70f

Browse files
committed
Add example to testing
1 parent 5880cf5 commit 8a5f70f

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

example/run-examples.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ three
3535
20
3636
EOF
3737

38+
run_test sort_generic << EOF
39+
5
40+
a short string
41+
a shirt string
42+
shorter
43+
and the next string is unallocated
44+
EOF
45+
3846
run_test vecstr << EOF
3947
This is the first string
4048
a second string

example/sort.f90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
program sort_example
88
use, intrinsic :: ISO_C_BINDING
99
use flc
10-
use flc_algorithm, only : sort
10+
use flc_algorithm, only : sort, shuffle
1111
use flc_random, only : Engine, normal_distribution
1212
use example_utils, only : write_version, read_positive_int, STDOUT
1313
implicit none
@@ -29,10 +29,12 @@ program sort_example
2929

3030
! Sort the array
3131
call sort(x)
32-
33-
! Write output
3432
write(STDOUT, "(a, 4(f8.3,','))") "First few elements:", x(:min(4, size(x)))
3533

34+
! Rearrange it randomly
35+
call shuffle(rng, x)
36+
write(STDOUT, "(a, 4(f8.3,','))") "After shuffling:", x(:min(4, size(x)))
37+
3638
call rng%release()
3739
end program
3840

example/vecstr.f90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ program vecstr_example
99
use flc
1010
use flc_string, only : String
1111
use flc_vector, only : VectorString
12-
use example_utils, only : read_strings, STDOUT
12+
use example_utils, only : read_strings, write_version, STDOUT
1313
implicit none
1414
integer :: i
1515
type(VectorString) :: vec
1616
type(String) :: back, front
1717
character(C_CHAR), dimension(:), pointer :: chars
1818

19+
! Print version information
20+
call write_version()
21+
1922
! Read a vector of strings
2023
call read_strings(vec)
2124

0 commit comments

Comments
 (0)