Skip to content

Commit 03df63e

Browse files
committed
fix issues in most demo programs
1 parent 3d4d8a7 commit 03df63e

File tree

119 files changed

+387
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+387
-114
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ if(NOT FYPP)
4949
endif()
5050

5151
add_subdirectory(src)
52+
add_subdirectory(test)
5253

5354
install(EXPORT ${PROJECT_NAME}-targets
5455
NAMESPACE ${PROJECT_NAME}::

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(example)

test/example/CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
macro(ADD_DEMO name)
2+
add_executable(demo_${name} demo_${name}.f90)
3+
target_link_libraries(demo_${name} "${PROJECT_NAME}")
4+
# add_test(NAME ${name}
5+
# COMMAND $<TARGET_FILE:demo_${name}> ${CMAKE_CURRENT_BINARY_DIR}
6+
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
7+
endmacro(ADD_DEMO)
8+
9+
add_subdirectory(array)
10+
add_subdirectory(ascii)
11+
add_subdirectory(bitsets)
12+
add_subdirectory(error)
13+
add_subdirectory(hashmaps)
14+
add_subdirectory(hash_procedures)
15+
add_subdirectory(io)
16+
add_subdirectory(linalg)
17+
add_subdirectory(logger)
18+
add_subdirectory(math)
19+
add_subdirectory(optval)
20+
add_subdirectory(quadrature)
21+
add_subdirectory(random)
22+
add_subdirectory(selection)
23+
add_subdirectory(sorting)
24+
add_subdirectory(specialfunctions_gamma)
25+
add_subdirectory(stats)
26+
add_subdirectory(stats_distribution_exponential)
27+
add_subdirectory(stats_distribution_normal)
28+
add_subdirectory(stats_distribution_uniform)
29+
add_subdirectory(stringlist_type)
30+
add_subdirectory(strings)
31+
add_subdirectory(string_type)
32+
add_subdirectory(version)

test/example/array/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#ADD_DEMO(falseloc)
2+
ADD_DEMO(trueloc)

test/example/ascii/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ADD_DEMO(ascii_reverse)
2+
ADD_DEMO(ascii_to_lower)
3+
ADD_DEMO(ascii_to_sentence)
4+
ADD_DEMO(ascii_to_title)
5+
ADD_DEMO(ascii_to_upper)

test/example/bitsets/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ADD_DEMO(bitsets_all)
2+
ADD_DEMO(bitsets_and)
3+
ADD_DEMO(bitsets_and_not)
4+
ADD_DEMO(bitsets_any)
5+
ADD_DEMO(bitsets_assignment)
6+
ADD_DEMO(bitsets_bit_count)
7+
ADD_DEMO(bitsets_bits)
8+
ADD_DEMO(bitsets_clear)
9+
ADD_DEMO(bitsets_equality)
10+
ADD_DEMO(bitsets_extract)
11+
ADD_DEMO(bitsets_flip)
12+
ADD_DEMO(bitsets_from_string)
13+
ADD_DEMO(bitsets_ge)
14+
ADD_DEMO(bitsets_gt)
15+
ADD_DEMO(bitsets_inequality)
16+
ADD_DEMO(bitsets_init)
17+
ADD_DEMO(bitsets_input)
18+
ADD_DEMO(bitsets_le)
19+
ADD_DEMO(bitsets_lt)
20+
ADD_DEMO(bitsets_none)
21+
ADD_DEMO(bitsets_not)
22+
ADD_DEMO(bitsets_or)
23+
ADD_DEMO(bitsets_output)
24+
ADD_DEMO(bitsets_read_bitset)
25+
ADD_DEMO(bitsets_set)
26+
ADD_DEMO(bitsets_test)
27+
ADD_DEMO(bitsets_to_string)
28+
ADD_DEMO(bitsets_value)
29+
ADD_DEMO(bitsets_write_bitset)
30+
ADD_DEMO(bitsets_xor)

test/example/bitsets/demo_and.f90 renamed to test/example/bitsets/demo_bitsets_and.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ program demo_and
44
call set0 % init(166)
55
call set1 % init(166)
66
call and( set0, set1 ) ! none none
7-
if ( none(set0) ) write(*,*) 'First test of AND worked.'
7+
if ( set0 % none() ) write(*,*) 'First test of AND worked.'
88
call set0 % not()
99
call and( set0, set1 ) ! all none
10-
if ( none(set0) ) write(*,*) 'Second test of AND worked.'
10+
if ( set0 % none() ) write(*,*) 'Second test of AND worked.'
1111
call set1 % not()
1212
call and( set0, set1 ) ! none all
13-
if ( none(set0) ) write(*,*) 'Third test of AND worked.'
13+
if ( set0 % none() ) write(*,*) 'Third test of AND worked.'
1414
call set0 % not()
1515
call and( set0, set1 ) ! all all
16-
if ( all(set0) ) write(*,*) 'Fourth test of AND worked.'
16+
if ( set0 % all() ) write(*,*) 'Fourth test of AND worked.'
1717
end program demo_and

test/example/bitsets/demo_and_not.f90 renamed to test/example/bitsets/demo_bitsets_and_not.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ program demo_and_not
44
call set0 % init(166)
55
call set1 % init(166)
66
call and_not( set0, set1 ) ! none none
7-
if ( none(set0) ) write(*,*) 'First test of AND_NOT worked.'
7+
if ( set0 % none() ) write(*,*) 'First test of AND_NOT worked.'
88
call set0 % not()
99
call and_not( set0, set1 ) ! all none
10-
if ( all(set0) ) write(*,*) 'Second test of AND_NOT worked.'
10+
if ( set0 % all() ) write(*,*) 'Second test of AND_NOT worked.'
1111
call set0 % not()
1212
call set1 % not()
1313
call and_not( set0, set1 ) ! none all
14-
if ( none(set0) ) write(*,*) 'Third test of AND_NOT worked.'
14+
if ( set0 % none() ) write(*,*) 'Third test of AND_NOT worked.'
1515
call set0 % not()
1616
call and_not( set0, set1 ) ! all all
17-
if ( none(set0) ) write(*,*) 'Fourth test of AND_NOT worked.'
17+
if ( set0 % none() ) write(*,*) 'Fourth test of AND_NOT worked.'
1818
end program demo_and_not

test/example/bitsets/demo_assignment.f90 renamed to test/example/bitsets/demo_bitsets_assignment.f90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
program demo_assignment
22
use stdlib_bitsets
3+
use stdlib_kinds, only: int8, int32
4+
implicit none
35
logical(int8) :: logical1(64) = .true.
46
logical(int32), allocatable :: logical2(:)
57
type(bitset_64) :: set0, set1
68
set0 = logical1
79
if ( set0 % bits() /= 64 ) then
8-
error stop procedure // &
10+
error stop &
911
' initialization with logical(int8) failed to set' // &
1012
' the right size.'
1113
else if ( .not. set0 % all() ) then
12-
error stop procedure // ' initialization with' // &
14+
error stop ' initialization with' // &
1315
' logical(int8) failed to set the right values.'
1416
else
1517
write(*,*) 'Initialization with logical(int8) succeeded.'

test/example/bitsets/demo_from_string.f90 renamed to test/example/bitsets/demo_bitsets_from_string.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ program demo_from_string
66
call set0 % from_string( bits_all )
77
if ( bits(set0) /= 33 ) then
88
error stop "FROM_STRING failed to interpret " // &
9-
'BITS_ALL's size properly."
9+
"BITS_ALL's size properly."
1010
else if ( .not. set0 % all() ) then
1111
error stop "FROM_STRING failed to interpret" // &
1212
"BITS_ALL's value properly."

test/example/bitsets/demo_input.f90 renamed to test/example/bitsets/demo_bitsets_input.f90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
program demo_input
2+
use stdlib_bitsets
3+
implicit none
24
character(*), parameter :: &
35
bits_0 = '000000000000000000000000000000000', &
46
bits_1 = '000000000000000000000000000000001', &

test/example/bitsets/demo_or.f90 renamed to test/example/bitsets/demo_bitsets_or.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ program demo_or
44
call set0 % init(166)
55
call set1 % init(166)
66
call or( set0, set1 ) ! none none
7-
if ( none(set0) ) write(*,*) 'First test of OR worked.'
7+
if ( set0 % none() ) write(*,*) 'First test of OR worked.'
88
call set0 % not()
99
call or( set0, set1 ) ! all none
10-
if ( all(set0) ) write(*,*) 'Second test of OR worked.'
10+
if ( set0 % all() ) write(*,*) 'Second test of OR worked.'
1111
call set0 % not()
1212
call set1 % not()
1313
call or( set0, set1 ) ! none all
14-
if ( all(set0) ) write(*,*) 'Third test of OR worked.'
14+
if ( set0 % all() ) write(*,*) 'Third test of OR worked.'
1515
call set0 % not()
1616
call or( set0, set1 ) ! all all
17-
if ( all(set0) ) write(*,*) 'Fourth test of OR worked.'
17+
if ( set0 % all() ) write(*,*) 'Fourth test of OR worked.'
1818
end program demo_or

test/example/bitsets/demo_output.f90 renamed to test/example/bitsets/demo_bitsets_output.f90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
program demo_output
2+
use stdlib_bitsets
3+
implicit none
24
character(*), parameter :: &
35
bits_0 = '000000000000000000000000000000000', &
46
bits_1 = '000000000000000000000000000000001', &

test/example/bitsets/demo_read_bitset.f90 renamed to test/example/bitsets/demo_bitsets_read_bitset.f90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
program demo_read_bitset
2+
use stdlib_bitsets
3+
implicit none
24
character(*), parameter :: &
35
bits_0 = 'S33B000000000000000000000000000000000', &
46
bits_1 = 'S33B000000000000000000000000000000001', &
5-
bits_33 = 'S33B100000000000000000000000000000000'
7+
bits_2 = 'S33B100000000000000000000000000000000'
68
character(:), allocatable :: test_0, test_1, test_2
7-
integer :: unit
9+
integer :: unit, status
810
type(bitset_64) :: set0, set1, set2, set3, set4, set5
911
call set0 % read_bitset( bits_0, status )
1012
call set1 % read_bitset( bits_1, status )
@@ -28,6 +30,6 @@ program demo_read_bitset
2830
call set4 % read_bitset(unit, advance='no')
2931
call set5 % read_bitset(unit)
3032
if ( set3 == set0 .and. set4 == set1 .and. set5 == set2 ) then
31-
write(*,*) WRITE_BITSET to READ_BITSET through unit worked.'
33+
write(*,*) 'WRITE_BITSET to READ_BITSET through unit worked.'
3234
end if
3335
end program demo_read_bitset

test/example/bitsets/demo_write_bitset.f90 renamed to test/example/bitsets/demo_bitsets_write_bitset.f90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
program demo_write_bitset
2+
use stdlib_bitsets
3+
implicit none
24
character(*), parameter :: &
35
bits_0 = 'S33B000000000000000000000000000000000', &
46
bits_1 = 'S33B000000000000000000000000000000001', &
5-
bits_33 = 'S33B100000000000000000000000000000000'
7+
bits_2 = 'S33B100000000000000000000000000000000'
68
character(:), allocatable :: test_0, test_1, test_2
7-
integer :: unit
9+
integer :: unit, status
810
type(bitset_64) :: set0, set1, set2, set3, set4, set5
911
call set0 % read_bitset( bits_0, status )
1012
call set1 % read_bitset( bits_1, status )
@@ -28,6 +30,6 @@ program demo_write_bitset
2830
call set4 % read_bitset(unit, advance='no')
2931
call set5 % read_bitset(unit)
3032
if ( set3 == set0 .and. set4 == set1 .and. set5 == set2 ) then
31-
write(*,*) WRITE_BITSET to READ_BITSET through unit worked.'
33+
write(*,*) 'WRITE_BITSET to READ_BITSET through unit worked.'
3234
end if
3335
end program demo_write_bitset

test/example/bitsets/demo_xor.f90 renamed to test/example/bitsets/demo_bitsets_xor.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ program demo_xor
44
call set0 % init(166)
55
call set1 % init(166)
66
call xor( set0, set1 ) ! none none
7-
if ( none(set0) ) write(*,*) 'First test of XOR worked.'
7+
if ( set0 % none() ) write(*,*) 'First test of XOR worked.'
88
call set0 % not()
99
call xor( set0, set1 ) ! all none
10-
if ( all(set0) ) write(*,*) 'Second test of XOR worked.'
10+
if ( set0 % all() ) write(*,*) 'Second test of XOR worked.'
1111
call set0 % not()
1212
call set1 % not()
1313
call xor( set0, set1 ) ! none all
14-
if ( all(set0) ) write(*,*) 'Third test of XOR worked.'
14+
if ( set0 % all() ) write(*,*) 'Third test of XOR worked.'
1515
call set0 % not()
1616
call xor( set0, set1 ) ! all all
17-
if ( none(set0) ) write(*,*) 'Fourth test of XOR worked.'
17+
if ( set0 % none() ) write(*,*) 'Fourth test of XOR worked.'
1818
end program demo_xor

test/example/error/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ADD_DEMO(check1)
2+
ADD_DEMO(check2)
3+
ADD_DEMO(check3)
4+
ADD_DEMO(check4)
5+
ADD_DEMO(error_stop1)
6+
ADD_DEMO(error_stop2)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ADD_DEMO(fibonacci_hash_64)
2+
ADD_DEMO(fibonacci_hash)
3+
ADD_DEMO(fnv_1a_hash_64)
4+
ADD_DEMO(fnv_1a_hash)
5+
ADD_DEMO(fnv_1_hash_64)
6+
ADD_DEMO(fnv_1_hash)
7+
ADD_DEMO(nmhash32)
8+
ADD_DEMO(nmhash32x)
9+
ADD_DEMO(pengy_hash)
10+
ADD_DEMO(spooky_hash)
11+
ADD_DEMO(universal_mult_hash_64)
12+
ADD_DEMO(universal_mult_hash)
13+
ADD_DEMO(water_hash)

test/example/hash_procedures/demo_universal_mult_hash_64.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
program demo_universal_mult_hash_64
2-
use stdlib_hash_32bit, only: odd_random_integer, &
2+
use stdlib_hash_64bit, only: odd_random_integer, &
33
universal_mult_hash
44
use iso_fortran_env, only: int64
55
implicit none

test/example/hashmaps/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
ADD_DEMO(hashmaps_calls)
2+
ADD_DEMO(hashmaps_copy_key)
3+
#ADD_DEMO(hashmaps_copy_other)
4+
ADD_DEMO(hashmaps_entries)
5+
ADD_DEMO(hashmaps_equal_keys)
6+
ADD_DEMO(hashmaps_fnv_1a_hasher)
7+
ADD_DEMO(hashmaps_fnv_1_hasher)
8+
ADD_DEMO(hashmaps_free_key)
9+
ADD_DEMO(hashmaps_free_other)
10+
ADD_DEMO(hashmaps_get)
11+
ADD_DEMO(hashmaps_get_other_data)
12+
ADD_DEMO(hashmaps_hasher_fun)
13+
ADD_DEMO(hashmaps_init)
14+
ADD_DEMO(hashmaps_key_test)
15+
ADD_DEMO(hashmaps_loading)
16+
ADD_DEMO(hashmaps_map_entry)
17+
ADD_DEMO(hashmaps_num_slots)
18+
ADD_DEMO(hashmaps_probes)
19+
ADD_DEMO(hashmaps_rehash)
20+
ADD_DEMO(hashmaps_remove)
21+
ADD_DEMO(hashmaps_seeded_nmhash32_hasher)
22+
ADD_DEMO(hashmaps_seeded_nmhash32x_hasher)
23+
ADD_DEMO(hashmaps_seeded_water_hasher)
24+
ADD_DEMO(hashmaps_set)
25+
ADD_DEMO(hashmaps_set_other_data)
26+
ADD_DEMO(hashmaps_slots_bits)
27+
ADD_DEMO(hashmaps_total_depth)

test/example/hashmaps/demo_calls.f90 renamed to test/example/hashmaps/demo_hashmaps_calls.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ program demo_calls
33
use stdlib_hashmap_wrappers, only: fnv_1_hasher
44
implicit none
55
type(chaining_hashmap_type) :: map
6-
type(int_calls) :: initial_calls
6+
integer(int_calls) :: initial_calls
77
call map % init( fnv_1_hasher )
88
initial_calls = map % calls()
99
print *, "INITIAL_CALLS = ", initial_calls
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
program demo_copy_key
22
use stdlib_hashmap_wrappers, only: &
3-
copy_key, operator(==), key_type
3+
copy_key, operator(==), key_type, set
44
use iso_fortran_env, only: int8
55
implicit none
66
integer(int8) :: i, value(15)
77
type(key_type) :: old_key, new_key
88
value = [(i, i = 1, 15)]
9-
call set( key_out, value )
10-
call copy_key( key_out, new_key )
9+
call set( old_key, value )
10+
call copy_key( old_key, new_key )
1111
print *, "old_key == new_key = ", old_key == new_key
1212
end program demo_copy_key

test/example/hashmaps/demo_copy_other.f90 renamed to test/example/hashmaps/demo_hashmaps_copy_other.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ program demo_copy_other
44
use iso_fortran_env, only: int8
55
implicit none
66
type(other_type) :: other_in, other_out
7-
integer(int_8) :: i
7+
integer(int8) :: i
88
class(*), allocatable :: dummy
99
type dummy_type
1010
integer(int8) :: value(15)
1111
end type
1212
type(dummy_type) :: dummy_val
1313
do i=1, 15
14-
dummy_val % value1(i) = i
14+
dummy_val % value(i) = i
1515
end do
1616
allocate(other_in % value, source=dummy_val)
1717
call copy_other( other_in, other_out )
1818
select type(other_out)
19-
type(dummy_type)
19+
typeis (dummy_type)
2020
print *, "other_in == other_out = ", &
21-
all( dummy_val % value == other_out % value )
21+
all( other_in % value == other_out % value )
2222
end select
2323
end program demo_copy_other

test/example/hashmaps/demo_entries.f90 renamed to test/example/hashmaps/demo_hashmaps_entries.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ program demo_entries
33
use stdlib_hashmap_wrappers, only: fnv_1_hasher
44
implicit none
55
type(open_hashmap_type) :: map
6-
type(int_index) :: initial_entries
6+
integer(int_index) :: initial_entries
77
call map % init( fnv_1_hasher )
88
initial_entries = map % entries ()
99
print *, "INITIAL_ENTRIES = ", initial_entries

test/example/hashmaps/demo_fnv_1_hasher.f90 renamed to test/example/hashmaps/demo_hashmaps_fnv_1_hasher.f90

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
program demo_fnv_1_hasher
2-
use stdlib_hashmap_wrappers, only: &
3-
fnv_1_hasher, key_type, set
4-
use iso_fortran_env, only: int32
2+
use stdlib_hashmap_wrappers, only: fnv_1_hasher, key_type, set
3+
use iso_fortran_env, only: int8, int32
54
implicit none
65
integer(int8), allocatable :: array1(:)
76
integer(int32) :: hash

test/example/hashmaps/demo_fnv_1a_hasher.f90 renamed to test/example/hashmaps/demo_hashmaps_fnv_1a_hasher.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
program demo_fnv_1a_hasher
22
use stdlib_hashmap_wrappers, only: &
33
fnv_1a_hasher, key_type, set
4-
use iso_fortran_env, only: int32
4+
use iso_fortran_env, only: int8, int32
55
implicit none
66
integer(int8), allocatable :: array1(:)
77
integer(int32) :: hash

0 commit comments

Comments
 (0)