Skip to content

Bitsets3 #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 55 commits into from
Nov 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
cd7e19d
Added core files for stdlib_bitsets
wclodius2 Sep 29, 2020
e35ebc7
Prepared for testing of stdlib_bitsets
wclodius2 Sep 29, 2020
e2f3d66
Eliminated unused variablese
wclodius2 Sep 30, 2020
7d778cd
Added documentation for stdlib_bitsets
wclodius2 Sep 30, 2020
acfa3ac
Update doc/specs/stdlib_bitsets.md
jvdp1 Oct 4, 2020
7c5361c
Update doc/specs/stdlib_bitsets.md
jvdp1 Oct 4, 2020
eb2e5c1
formatting
jvdp1 Oct 4, 2020
e70c909
Update src/tests/Makefile.manual
jvdp1 Oct 4, 2020
8e25812
Update doc/specs/stdlib_bitsets.md
jvdp1 Oct 4, 2020
c9e851b
Changed makefiles to accept stdlib_bitset*.fypp instead of stdlib_bit…
wclodius2 Oct 8, 2020
d80e5d9
Renamed files stdlib_bitset*.f90 to stdlib_bitset*.fypp
wclodius2 Oct 8, 2020
f2d67fc
Changed preprocessor files to generate logical assignments.
wclodius2 Oct 8, 2020
2833ffa
Removed files now generated by the preprocessor
wclodius2 Oct 8, 2020
3844561
Modified code to use error_handler.
wclodius2 Oct 9, 2020
9e9c252
Better documented status results
wclodius2 Oct 9, 2020
421c4d2
Removed trailing blanks
wclodius2 Oct 9, 2020
d2be3dc
Added missing return
wclodius2 Oct 9, 2020
b0c0f63
Changed WRiTE to WRITE
wclodius2 Oct 9, 2020
b12e398
Changed the kind of bit
wclodius2 Oct 9, 2020
983a083
Changed subtraction of bit from outside an int converson to inside
wclodius2 Oct 9, 2020
38095c0
Deleted redundant returns.
wclodius2 Oct 10, 2020
cc477b9
Deleted redundant return
wclodius2 Oct 10, 2020
beca325
Regularized code fences
wclodius2 Oct 10, 2020
d391970
Some typs and obvious changes
jvdp1 Oct 14, 2020
84d7d33
Apply suggestions from code review
jvdp1 Oct 14, 2020
d6dc6b1
Corrected stdlib_bitsets.md
wclodius2 Oct 15, 2020
daa83d2
Update doc/specs/stdlib_bitsets.md
jvdp1 Oct 15, 2020
30c2116
Apply suggestions from code review
jvdp1 Oct 15, 2020
0e3b788
Merge branch 'bitsets3' of https://github.com/wclodius2/stdlib into b…
wclodius2 Oct 15, 2020
adab166
Changed file names
wclodius2 Oct 15, 2020
d7cf384
Updated makefiles to deal with new names
wclodius2 Oct 15, 2020
aeae7dd
Changed discussion of bitset_type
wclodius2 Oct 15, 2020
8330945
Changed varibles to entities.
wclodius2 Oct 15, 2020
24881a5
Fixed typo in Makefile.manual
wclodius2 Oct 15, 2020
0554f5d
typos
jvdp1 Oct 15, 2020
ecd6c82
Typos and bits_kind fixes
wclodius2 Oct 16, 2020
47c7d6e
Fixed digit_count
wclodius2 Oct 16, 2020
80af2c5
Added dependence on stdlib_kinds.f90
wclodius2 Oct 16, 2020
0deab15
Fixed bits_kind breakage
wclodius2 Oct 16, 2020
9f0e4a9
Fixed up constants
wclodius2 Oct 16, 2020
9f690fd
some typos
jvdp1 Oct 16, 2020
f705346
Added discussion of undefined behavior
wclodius2 Oct 19, 2020
242950b
Fixed typo
wclodius2 Oct 19, 2020
032c440
Added reference to the bitsets module
wclodius2 Oct 19, 2020
e957342
Made it easier to change bits_kind
wclodius2 Oct 20, 2020
9161fc7
Replaced go to 100 with exit
wclodius2 Oct 20, 2020
3235ab4
Changed used modues
wclodius2 Oct 20, 2020
523dbc6
Changed handling of potential integer overflows on reads
wclodius2 Oct 21, 2020
20a15e5
Numerous changes suggested by Jeremie
wclodius2 Oct 21, 2020
57faccd
Replaced go tos
wclodius2 Oct 21, 2020
9c03d16
Replaced go tos
wclodius2 Oct 21, 2020
5c2779d
Documented the "named" form for the comparison operations
wclodius2 Oct 26, 2020
99fa382
typography fixes
milancurcic Nov 13, 2020
acb7cdb
add example to the first paragraph
milancurcic Nov 13, 2020
1be7ca3
Merge https://github.com/fortran-lang/stdlib into bitsets3
wclodius2 Nov 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Numerous changes suggested by Jeremie
Jeremie suggested numerous changes. I implemented most of them.

[ticket: X]
  • Loading branch information
wclodius2 committed Oct 21, 2020
commit 20a15e51f54ee5c81169f363b355893d5dafbb10
76 changes: 42 additions & 34 deletions src/tests/bitsets/test_stdlib_bitset_64.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ program test_stdlib_bitset_64
subroutine test_string_operations()
character(*), parameter:: procedure = 'TEST_STRING_OPERATIONS'

write(*,*)
write(*,*) 'Test string operations: from_string, read_bitset, ' // &
'to_string, and write_bitset'
write(*,'(/a)') 'Test string operations: from_string, ' // &
'read_bitset, to_string, and write_bitset'

call set0 % from_string( bitstring_0 )
if ( bits(set0) /= 33 ) then
Expand Down Expand Up @@ -67,6 +66,9 @@ subroutine test_string_operations()
call set3 % read_bitset( bitstring_0, status )
if ( status /= success ) then
write(*,*) 'read_bitset_string failed with bitstring_0 as expected.'
else
error stop procedure // ' read_bitset_string did not fail ' // &
'with bitstring_0 as expected.'
end if

call set3 % read_bitset( 's33b' // bitstring_0, status )
Expand Down Expand Up @@ -209,6 +211,27 @@ subroutine test_io()
'output and input succeeded.'
end if

open( newunit=unit, file='test.bin', status='replace', &
form='unformatted', access='stream', action='write' )
call set2 % output(unit)
call set1 % output(unit)
call set0 % output(unit)
close( unit )
open( newunit=unit, file='test.bin', status='old', &
form='unformatted', access='stream', action='read' )
call set5 % input(unit)
call set4 % input(unit)
call set3 % input(unit)
close( unit )

if ( set3 /= set0 .or. set4 /= set1 .or. set5 /= set2 ) then
error stop procedure // ' transfer to and from units using ' // &
' stream output and input failed.'
else
write(*,*) 'Transfer to and from units using ' // &
'stream output and input succeeded.'
end if

end subroutine test_io

subroutine test_initialization()
Expand Down Expand Up @@ -404,56 +427,41 @@ subroutine test_bitset_inquiry()

call set0 % not()
do i=0, set0 % bits() - 1
if ( set0 % test(i) ) go to 100
if ( set0 % test(i) ) then
error stop procedure // ' against expectations set0 has ' // &
'at least 1 bit set.'
end if
end do

write(*,*) 'As expected set0 had no bits set.'

go to 110

100 error stop procedure // ' against expectations set0 has ' // &
'at least 1 bit set.'

110 continue

do i=0, set1 % bits() - 1
if ( .not. set1 % test(i) ) go to 200
if ( .not. set1 % test(i) ) then
error stop procedure // ' against expectations set1 has ' // &
'at least 1 bit unset.'
end if
end do

write(*,*) 'As expected set1 had all bits set.'

go to 210

200 error stop procedure // ' against expectations set1 has ' // &
'at least 1 bit unset.'
210 continue

do i=0, set0 % bits() - 1
if ( set0 % value(i) /= 0 ) go to 300
if ( set0 % value(i) /= 0 ) then
error stop procedure // ' against expectations set0 has ' // &
'at least 1 bit set.'
end if
end do

write(*,*) 'As expected set0 had no bits set.'

go to 310

300 error stop procedure // ' against expectations set0 has ' // &
'at least 1 bit set.'

310 continue

do i=0, set1 % bits() - 1
if ( set1 % value(i) /= 1 ) go to 400
if ( set1 % value(i) /= 1 ) then
error stop procedure // ' against expectations set1 has ' // &
'at least 1 bit unset.'
end if
end do

write(*,*) 'As expected set1 had all bits set.'

go to 410

400 error stop procedure // ' against expectations set1 has ' // &
'at least 1 bit unset.'

410 continue

if ( set0 % bits() == 33 ) then
write(*,*) 'set0 has 33 bits as expected.'
else
Expand Down
50 changes: 47 additions & 3 deletions src/tests/bitsets/test_stdlib_bitset_large.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ program test_stdlib_bitset_large
subroutine test_string_operations()
character(*), parameter:: procedure = 'TEST_STRING_OPERATIONS'

write(*,*)
write(*,*) 'Test string operations: from_string, read_bitset, ' // &
'to_string, and write_bitset'
write(*,'(/a)') 'Test string operations: from_string, ' // &
'read_bitset, to_string, and write_bitset'

call set0 % from_string( bitstring_0 )
if ( bits(set0) /= 33 ) then
Expand Down Expand Up @@ -101,6 +100,9 @@ subroutine test_string_operations()
call set3 % read_bitset( bitstring_0, status )
if ( status /= success ) then
write(*,*) 'read_bitset_string failed with bitstring_0 as expected.'
else
error stop procedure // ' read_bitset_string did not fail ' // &
'with bitstring_0 as expected.'
end if

call set13 % read_bitset( bitstring_0 // bitstring_0, status )
Expand Down Expand Up @@ -358,6 +360,27 @@ subroutine test_io()

close( unit )

open( newunit=unit, file='test.bin', status='replace', &
form='unformatted', access='stream', action='write' )
call set2 % output(unit)
call set1 % output(unit)
call set0 % output(unit)
close( unit )
open( newunit=unit, file='test.bin', status='old', &
form='unformatted', access='stream', action='read' )
call set5 % input(unit)
call set4 % input(unit)
call set3 % input(unit)
if ( set3 /= set0 .or. set4 /= set1 .or. set5 /= set2 ) then
error stop procedure // ' transfer to and from units using ' // &
' stream output and input failed.'
else
write(*,*) 'Transfer to and from units using ' // &
'stream output and input succeeded.'
end if

close( unit )

open( newunit=unit, file='test.bin', status='replace', &
form='unformatted', action='write' )
call set12 % output(unit)
Expand All @@ -376,6 +399,27 @@ subroutine test_io()
write(*,*) 'Transfer to and from units using ' // &
'output and input succeeded for bits > 64.'
end if
close(unit)

open( newunit=unit, file='test.bin', status='replace', &
form='unformatted', access='stream', action='write' )
call set12 % output(unit)
call set11 % output(unit)
call set10 % output(unit)
close( unit )
open( newunit=unit, file='test.bin', status='old', &
form='unformatted', access='stream', action='read' )
call set15 % input(unit)
call set14 % input(unit)
call set13 % input(unit)
if ( set13 /= set10 .or. set14 /= set11 .or. set15 /= set12 ) then
error stop procedure // ' transfer to and from units using ' // &
' stream output and input failed for bits . 64.'
else
write(*,*) 'Transfer to and from units using ' // &
'stream output and input succeeded for bits > 64.'
end if
close(unit)

end subroutine test_io

Expand Down