summaryrefslogtreecommitdiffstats
path: root/src/testing/01_variable_testing.ft
blob: eeb886de42dab95e04cc5a3bd8db5c89d5ec1451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
program variabletesting
! fortran variable testing harness

print*,"Testing variable logic and storage\n"

! Integer testing (initialisation, addition, division etc)
! a =7 - 4 + 2
! a =(5+4)*(10/2)+5**2
! print*,a

print*,"Integer logic testing"
int::x
int::y
int::result
x = 5
y = 5

result = x + y
print*,"Addition test: ",result," (should be 10)"
result = x - y
print*,"Subtraction test: ",result," (should be 0)"
result = x * y
print*,"Multiplication test: ",result," (should be 25)"
result = x / y
print*,"Division test: ",result," (should be 1)"


! Real number testing
print*,"\n\nReal number logic testing"
real::xreal
real::yreal
real::resultreal
xreal = 5
yreal = 5

resultreal = xreal + yreal
print*,"Addition test: ",resultreal," (should be 10)"
resultreal = xreal - yreal
print*,"Subtraction test: ",resultreal," (should be 0)"
resultreal = xreal * yreal
print*,"Multiplication test: ",resultreal," (should be 25)"
resultreal = xreal / yreal
print*,"Division test: ",resultreal," (should be 1)"

xreal = 7
yreal = 2
resultreal = xreal / yreal
print*,"Division test two: ",resultreal," (should be 3.5)"

resultreal = (5+4)*(10/2)+5*2
print*,"Order of significance test: ",resultreal," (should be 55)"


! Testing Strings handling here
print*,"\n\nTesting string handling"
character(len=15)::helloworld
helloworld="Hello World!"
print*,"Printed string: ",helloworld


!Testing array storage
print*,"\n\nTesting arrays"
print*,"Storing integers and printing to console:"
int dimension(10)::intArray
int::i

do i=0,9
intArray(i)=i
end do

do i=0,9
print*,intArray(i)
end do


print*,"\nStoring real numbers and printing to console:"
real dimension(10)::realArray
real::j
j = 0.0

do i=0,9
j = j + 1
realArray(i)=j j
end do

do i=0,9
print*,realArray(i)
end do


end program variabletesting