Skip to content

Commit 16117a8

Browse files
committed
input2d: tests
1 parent 4ae8a4a commit 16117a8

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/test_input2d_layer.f90

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
program test_input2d_layer
2+
3+
use iso_fortran_env, only: stderr => error_unit
4+
use nf, only: input, layer
5+
use nf_input2d_layer, only: input2d_layer
6+
7+
implicit none
8+
9+
type(layer) :: test_layer
10+
real, allocatable :: output(:,:)
11+
logical :: ok = .true.
12+
13+
test_layer = input(3, 32)
14+
15+
if (.not. test_layer % name == 'input') then
16+
ok = .false.
17+
write(stderr, '(a)') 'input2d layer has its name set correctly.. failed'
18+
end if
19+
20+
if (.not. test_layer % initialized) then
21+
ok = .false.
22+
write(stderr, '(a)') 'input2d layer should be marked as initialized.. failed'
23+
end if
24+
25+
if (.not. all(test_layer % layer_shape == [3, 32])) then
26+
ok = .false.
27+
write(stderr, '(a)') 'input2d layer is created with requested size.. failed'
28+
end if
29+
30+
if (.not. size(test_layer % input_layer_shape) == 0) then
31+
ok = .false.
32+
write(stderr, '(a)') 'input2d layer has no input layer shape.. failed'
33+
end if
34+
35+
call test_layer % get_output(output)
36+
37+
if (.not. all(output == 0)) then
38+
ok = .false.
39+
write(stderr, '(a)') 'input2d layer values are all initialized to 0.. failed'
40+
end if
41+
42+
if (ok) then
43+
print '(a)', 'test_input2d_layer: All tests passed.'
44+
else
45+
write(stderr, '(a)') 'test_input2d_layer: One or more tests failed.'
46+
stop 1
47+
end if
48+
49+
end program test_input2d_layer

0 commit comments

Comments
 (0)