The program appears in the editor.
01 errormessage pic x(200).
move 4 to lnk-function call "aircode" using by value lnk-function by value lnk-airport1 by value lnk-airport2 by value lnk-prefix-text by reference lnk-rec by reference lnk-distance-result by reference lnk-matched-codes-array end-call
This code makes a call to the code under test, which attempts to open the data file.
move 2 to lnk-function move "LHR" to lnk-airport1 *> London Heathrow move "SEA" to lnk-airport2 *> Seattle
*> Assertions to check that the correct distance is returned if function numval(distance-miles) not equal 4787 string "Incorrect distance in miles returned - " distance-miles delimited by size x"0" delimited by size into errormessage end-string call MFU-ASSERT-FAIL-Z using errormessage end-if if function numval(distance-km) not equal 4787 string "Incorrect distance in kilometers returned - " distance-km delimited by size x"0" delimited by size into errormessage end-string call MFU-ASSERT-FAIL-Z using errormessage end-if
These are the assertions that check that the correct values are calculated for the distance (in miles and km) between the two airports, and if the calculation is incorrect, the test fails.
An MFU-TC-TEARDOWN-PREFIX & TEST-TESTAIRCODE entry point is added to the program.
move 5 to lnk-function call "aircode" using by value lnk-function by value lnk-airport1 by value lnk-airport2 by value lnk-prefix-text by reference lnk-rec by reference lnk-distance-result by reference lnk-matched-codes-array end-call
This closes the data file after the test case has run.
The test case reruns, but should fail with the following output: