Skip to content

Commit af09ba2

Browse files
committed
Add test
1 parent afae511 commit af09ba2

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

test/test_set.F90

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ subroutine test_int()
1818
use, intrinsic :: ISO_C_BINDING
1919
use flc_set, only : Set => SetInt
2020
implicit none
21-
type(Set) :: s
21+
type(Set) :: s, other, op_result
2222
integer :: num_erased
2323

2424
s = Set()
@@ -39,10 +39,28 @@ subroutine test_int()
3939
call s%erase(4)
4040

4141
! Insert an array of data
42-
call s%insert([1, 1, 2, 3, 5, 8, 13, 21])
43-
ASSERT(s%size() == 7)
42+
call s%insert([1, 1, 2, 3, 5, 8, 13])
43+
ASSERT(s%size() == 6)
44+
45+
other = Set([6, 1, 3, 4, 7]) ! input can be out of order
46+
47+
op_result = s%difference(other)
48+
ASSERT(op_result%size() == 4) ! 2, 5, 7, 13,
49+
op_result = s%intersection(other)
50+
ASSERT(op_result%size() == 2) ! 1, 3
51+
op_result = s%symmetric_difference(other)
52+
ASSERT(op_result%size() == 7) ! 2, 4, 5, 6, 7, 8, 13
53+
op_result = s%union(other)
54+
ASSERT(op_result%size() == 9)
55+
56+
ASSERT(.not. s%includes(other))
57+
call other%clear()
58+
call other%insert([1, 2, 3])
59+
ASSERT(s%includes(other))
4460

4561
call s%release()
62+
call other%release()
63+
call op_result%release()
4664
end subroutine
4765

4866
!-----------------------------------------------------------------------------!

0 commit comments

Comments
 (0)