📄 page_447.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>page_447</title> <link rel="stylesheet" href="reset.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <table summary="top nav" border="0" width="100%"> <tr> <td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_446.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_447</strong></td> <td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_448.html">next page ></a></td> </tr> <tr> <td align="left" colspan="3" style="background: #ffffff; padding: 20px;"> <table border="0" width="100%" cellpadding="0"><tr><td align="center"> <table border="0" cellpadding="2" cellspacing="0" width="100%"><tr><td align="left"></td> <td align="right"></td> </tr></table></td></tr><tr><td align="left"><p></p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="right"><font face="Times New Roman, Times, Serif" size="2" color="#FF0000">Page 447</font></td></tr></table><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td rowspan="5"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="96" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></td> <td colspan="3" height="12"></td> <td rowspan="5"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="96" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></td></tr><tr><td colspan="3" height="2"><table cellpadding="0" cellspacing="0" border="0"><tr><td></td></tr></table></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="2">Driver A simple </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">main</font><font face="Times New Roman, Times, Serif" size="2"> function that is used to call a function being tested. The use of a driver permits direct control of the testing process.</font></td><td></td></tr><tr><td colspan="3" height="2"><table cellpadding="0" cellspacing="0" border="0"><tr><td></td></tr></table></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">By surrounding a module with a driver and stubs, you gain complete control of the conditions under which it executes. This allows you to test different situations and combinations that may reveal errors. For example, the following program is a driver for the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">FuelMoment</font><font face="Times New Roman, Times, Serif" size="3"> function in the Starship program. Because </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">FuelMoment</font><font face="Times New Roman, Times, Serif" size="3"> doesn't call any other functions, no stubs are necessary.</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">//******************************************************************<br />//聽FuelMomentDriver聽program<br />//聽This聽program聽provides聽an聽environment聽for聽testing聽the<br />//聽FuelMoment聽function聽in聽isolation聽from聽the聽Starship聽program<br />//******************************************************************<br />#include聽<iostream.h><br /><br />const聽float聽LBS_PER_GAL聽=聽6.7;<br /><br />float聽FuelMoment(聽int聽);<br /><br />int聽main()<br />{<br />聽聽聽聽int聽testVal;聽聽聽聽//聽Test聽value聽for聽fuel聽in聽gallons<br /><br />聽聽聽聽cout聽<<聽Fuel聽moment聽for聽gallons聽from聽10聽through聽565<br />聽聽聽聽聽聽聽聽聽<<聽聽in聽steps聽of聽15:聽<<聽endl;<br />聽聽聽聽testVal聽=聽10;<br />聽聽聽聽while聽(testVal聽<=聽565)<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽cout聽<<聽FuelMoment聽(testVal)聽<<聽endl;<br />聽聽聽聽聽聽聽聽testVal聽=聽testVal聽+聽15;<br />聽聽聽聽}<br />聽聽聽聽return聽0;<br />}<br /><br />//******************************************************************<br /><br />float聽FuelMoment(聽/*聽in聽*/聽int聽fuel聽)聽聽聽聽//聽Fuel聽in聽gallons<br />{<br />聽聽聽聽float聽fuelWt;聽聽聽聽聽聽聽聽聽聽聽//聽Weight聽of聽fuel聽in聽pounds<br />聽聽聽聽float聽fuelDistance;聽聽聽聽聽//聽Distance聽from聽front聽of聽plane<br /></font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table></td></tr></table><p><font size="0"></font></p>聽 </td> </tr> <tr> <td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_446.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_447</strong></td> <td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_448.html">next page ></a></td> </tr> </table> </body> </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -