From f0e7aff793c457f830713b5b052a430997453916 Mon Sep 17 00:00:00 2001
From: "chris.sutcliffe" <ctd.sutcliffe@gmail.com>
Date: Tue, 14 Dec 2021 23:57:04 +0000
Subject: add loop and conditional tests

---
 src/testing/02_conditional_loop_testing.ft | 96 ++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100644 src/testing/02_conditional_loop_testing.ft

(limited to 'src/testing/02_conditional_loop_testing.ft')

diff --git a/src/testing/02_conditional_loop_testing.ft b/src/testing/02_conditional_loop_testing.ft
new file mode 100644
index 0000000..b4d7c01
--- /dev/null
+++ b/src/testing/02_conditional_loop_testing.ft
@@ -0,0 +1,96 @@
+program conditionalLoopTesting
+! fortran conditionals and loop testing harness
+! All tests should pass
+
+print*,"Testing variable logic and storage\n"
+
+! Testing conditional statements if and if else 
+print*,"Testing conditionals (8 tests should be displayed)"
+
+if (5==5) then
+print*,"Conditional test one: passed"
+end if
+
+if (5/=6) then
+print*,"Conditional test two: passed"
+end if
+
+if(5.5==5.5) then
+print*,"Conditional test three: passed"
+end if
+
+if(5.5/=6.6) then
+print*,"Conditional test four: passed"
+end if
+
+if (5==6) then
+print*,"Conditional test five: failed"
+else
+print*,"Conditional test five: passed"
+end if
+
+if (5/=5) then
+print*,"Conditional six: failed"
+else
+print*,"Conditional six: passed"
+end if
+
+if(5.5==6.6) then
+print*,"Conditional test seven: failed"
+else
+print*,"Conditional seven: passed"
+end if
+
+if(5.5/=5.5) then
+print*,"Conditional test eight: failed"
+else
+print*,"Conditional test eight: passed"
+end if
+
+
+! These tests output as expected, so we can simplify further logical tests
+
+print*,"\n\nTesting logic: (five tests should pass)"
+if(6==6 .and. 5==5) then
+print*,"Logical test one: passed"
+end if
+
+if(6==5 .and. 5==5) then
+print*,"Logical test two: failed"
+else
+print*,"Logical test two: passed"
+end if
+
+if(6==6 .and. 5==6) then
+print*,"Logical test three: failed"
+else
+print*,"Logical test three: passed"
+end if
+
+
+if(6==5 .or. 5==5) then
+print*,"Logical test four: passed"
+end if
+
+if(6==5 .or. 5==6) then
+print*,"Logical test five: failed"
+else
+print*,"Logical test five: passed"
+end if
+
+
+print*,"\n\nTesting looping (2 loops 1 to 10 should display)"
+print*,"Looping from 1 to 10 using do statement (for loop equivalent)"
+int::i
+do i=0,10
+print*,i
+end do
+
+print*,"\nLooping from 1 to 10 using do while statement (while loop equivalent)"
+i=0
+do while(i<=10)
+print*,i
+i=i+1
+end do
+
+end program conditionalLoopTesting
\ No newline at end of file
-- 
cgit v1.2.3