Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 7348b4eba6cdbb7638a2bcf7e83acf03 > files > 45

airrac-doc-0.2.3-2.fc16.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta name="robots" content="index,follow"/>
	<title>test/airrac/YieldTestSuite.cpp Source File</title>
	<link rel="shortcut icon" href="favicon.ico">
	<link href="tabs.css" rel="stylesheet" type="text/css"/>
	<link href="airrac.css" rel="stylesheet" type="text/css"/>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
	
	<script type="text/javascript">
	  var _gaq = _gaq || [];
	  _gaq.push(['_setAccount', 'UA-24983440-1']);
	  _gaq.push(['_setDomainName', 'none']);
	  _gaq.push(['_setAllowLinker', true]);
	  _gaq.push(['_trackPageview']);
	  (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	  })();
	</script>
	<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
  </head>

  <body>
	<div id="top"><!-- do not remove this div! -->
	  
	  <div id="titlearea">
		<table width="100%">
		  <tbody>
			<tr style="height: 56px;">
			  
			  <td style="padding-left: 0.5em;">
				<div id="projectname"><a href="http://airrac.sourceforge.net"><img height="45px" alt="AirRAC Logo" src="airrac_logo.png"></a>
				  
				  &#160;<span id="projectnumber">0.2.3</span>
				  
				</div>
				
				<div id="projectbrief">C++ Simulated Revenue Accounting (RAC) System Library</div>
				
			  </td>
			  
			  

			  <!-- begin SOURCEFORGE_CUSTOM-->
			  <td>
				<div id="sflogo"><a href="http://airrac.sourceforge.net"><img height="45px" alt="SourceForge Logo" src="sfx_logo.png"></a></div>
			  </td>
			  <!-- end SOURCEFORGE_CUSTOM-->

			  
			</tr>
		  </tbody>
		</table>
	  </div>
	  

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="dynsections.js"></script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('YieldTestSuite_8cpp.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">YieldTestSuite.cpp</div>  </div>
</div>
<div class="contents">
<a href="YieldTestSuite_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00005"></a>00005 <span class="comment">// //////////////////////////////////////////////////////////////////////</span>
<a name="l00006"></a>00006 <span class="comment">// Import section</span>
<a name="l00007"></a>00007 <span class="comment">// //////////////////////////////////////////////////////////////////////</span>
<a name="l00008"></a>00008 <span class="comment">// STL</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;sstream&gt;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;fstream&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00012"></a>00012 <span class="comment">// Boost Unit Test Framework (UTF)</span>
<a name="l00013"></a>00013 <span class="preprocessor">#define BOOST_TEST_DYN_LINK</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define BOOST_TEST_MAIN</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#define BOOST_TEST_MODULE YieldTestSuite</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span><span class="preprocessor">#include &lt;boost/test/unit_test.hpp&gt;</span>
<a name="l00017"></a>00017 <span class="comment">// StdAir</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;stdair/basic/BasLogParams.hpp&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;stdair/basic/BasDBParams.hpp&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;stdair/basic/BasFileMgr.hpp&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;stdair/bom/TravelSolutionStruct.hpp&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;stdair/service/Logger.hpp&gt;</span>
<a name="l00023"></a>00023 <span class="comment">// Airrac</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;<a class="code" href="AIRRAC__Service_8hpp.html">airrac/AIRRAC_Service.hpp</a>&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;<a class="code" href="airrac-paths_8hpp.html">airrac/config/airrac-paths.hpp</a>&gt;</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="keyword">namespace </span>boost_utf = boost::unit_test;
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="comment">// (Boost) Unit Test XML Report</span>
<a name="l00030"></a>00030 std::ofstream utfReportStream (<span class="stringliteral">&quot;YieldTestSuite_utfresults.xml&quot;</span>);
<a name="l00031"></a>00031 
<a name="l00035"></a>00035 <span class="keyword">struct </span>UnitTestConfig {
<a name="l00037"></a>00037   UnitTestConfig() {
<a name="l00038"></a>00038     boost_utf::unit_test_log.set_stream (utfReportStream);
<a name="l00039"></a>00039     boost_utf::unit_test_log.set_format (boost_utf::XML);
<a name="l00040"></a>00040     boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
<a name="l00041"></a>00041     <span class="comment">//boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);</span>
<a name="l00042"></a>00042   }
<a name="l00043"></a>00043 
<a name="l00045"></a>00045   ~UnitTestConfig() {
<a name="l00046"></a>00046   }
<a name="l00047"></a>00047 };
<a name="l00048"></a>00048 
<a name="l00049"></a>00049 <span class="comment">// //////////////////////////////////////////////////////////////////////</span>
<a name="l00050"></a>00050 
<a name="l00054"></a>00054 <span class="keywordtype">void</span> testYieldQuoterHelper (<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> iTestFlag,
<a name="l00055"></a>00055                             <span class="keyword">const</span> stdair::Filename_T iYieldInputFilename,
<a name="l00056"></a>00056                             <span class="keyword">const</span> <span class="keywordtype">bool</span> isBuiltin) {
<a name="l00057"></a>00057 
<a name="l00058"></a>00058   <span class="comment">// Output log File</span>
<a name="l00059"></a>00059   std::ostringstream oStr;
<a name="l00060"></a>00060   oStr &lt;&lt; <span class="stringliteral">&quot;FQTTestSuite_&quot;</span> &lt;&lt; iTestFlag &lt;&lt; <span class="stringliteral">&quot;.log&quot;</span>;
<a name="l00061"></a>00061   <span class="keyword">const</span> stdair::Filename_T lLogFilename (oStr.str());
<a name="l00062"></a>00062 
<a name="l00063"></a>00063   <span class="comment">// Set the log parameters</span>
<a name="l00064"></a>00064   std::ofstream logOutputFile;
<a name="l00065"></a>00065   <span class="comment">// Open and clean the log outputfile</span>
<a name="l00066"></a>00066   logOutputFile.open (lLogFilename.c_str());
<a name="l00067"></a>00067   logOutputFile.clear();
<a name="l00068"></a>00068     
<a name="l00069"></a>00069   <span class="comment">// Initialise the AirRAC service object</span>
<a name="l00070"></a>00070   <span class="keyword">const</span> stdair::BasLogParams lLogParams (stdair::LOG::DEBUG,
<a name="l00071"></a>00071                                          logOutputFile);
<a name="l00072"></a>00072   
<a name="l00073"></a>00073   <span class="comment">// Initialise the AirRAC service object</span>
<a name="l00074"></a>00074   AIRRAC::AIRRAC_Service airracService (lLogParams);
<a name="l00075"></a>00075   
<a name="l00076"></a>00076   <span class="comment">// Build a sample list of travel solutions</span>
<a name="l00077"></a>00077   stdair::TravelSolutionList_T lTravelSolutionList;
<a name="l00078"></a>00078   airracService.buildSampleTravelSolutions (lTravelSolutionList);
<a name="l00079"></a>00079 
<a name="l00080"></a>00080   <span class="comment">// Check whether or not a (CSV) input file should be read</span>
<a name="l00081"></a>00081   <span class="keywordflow">if</span> (isBuiltin == <span class="keyword">true</span>) {
<a name="l00082"></a>00082 
<a name="l00083"></a>00083     <span class="comment">// Build the default sample BOM tree (filled with yields) for AirRAC</span>
<a name="l00084"></a>00084     airracService.buildSampleBom();
<a name="l00085"></a>00085 
<a name="l00086"></a>00086   } <span class="keywordflow">else</span> {
<a name="l00087"></a>00087 
<a name="l00088"></a>00088     <span class="comment">// Build the BOM tree from parsing the yield input file    </span>
<a name="l00089"></a>00089     AIRRAC::YieldFilePath lYieldFilePath (iYieldInputFilename);
<a name="l00090"></a>00090     airracService.parseAndLoad (lYieldFilePath);
<a name="l00091"></a>00091   }
<a name="l00092"></a>00092 
<a name="l00093"></a>00093   <span class="comment">// Calculate the yields for the given travel solution</span>
<a name="l00094"></a>00094   airracService.calculateYields (lTravelSolutionList);
<a name="l00095"></a>00095 
<a name="l00096"></a>00096   <span class="comment">// Close the log file</span>
<a name="l00097"></a>00097   logOutputFile.close();
<a name="l00098"></a>00098 
<a name="l00099"></a>00099 }
<a name="l00100"></a>00100 
<a name="l00101"></a>00101 
<a name="l00102"></a>00102 <span class="comment">// /////////////// Main: Unit Test Suite //////////////</span>
<a name="l00103"></a>00103 
<a name="l00104"></a>00104 <span class="comment">// Set the UTF configuration (re-direct the output to a specific file)</span>
<a name="l00105"></a>00105 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
<a name="l00106"></a>00106 
<a name="l00107"></a>00107 <span class="comment">// Start the test suite</span>
<a name="l00108"></a>00108 BOOST_AUTO_TEST_SUITE (master_test_suite)
<a name="l00109"></a>00109 
<a name="l00110"></a>00110 
<a name="l00113"></a>00113 BOOST_AUTO_TEST_CASE (airrac_simple_yield) {
<a name="l00114"></a>00114 
<a name="l00115"></a>00115   <span class="comment">// Input file name</span>
<a name="l00116"></a>00116   <span class="keyword">const</span> stdair::Filename_T lYieldInputFilename (<a class="code" href="airrac-paths_8hpp.html#af06cd429ada6c5a061032f4278de45d1">STDAIR_SAMPLE_DIR</a> <span class="stringliteral">&quot;/yieldstore01.csv&quot;</span>);
<a name="l00117"></a>00117 
<a name="l00118"></a>00118   <span class="comment">// State whether the BOM tree should be built-in or parsed from an input file</span>
<a name="l00119"></a>00119   <span class="keyword">const</span> <span class="keywordtype">bool</span> isBuiltin = <span class="keyword">false</span>;
<a name="l00120"></a>00120 
<a name="l00121"></a>00121   <span class="comment">// Try to yieldQuote the sample default list of travel solutions</span>
<a name="l00122"></a>00122   BOOST_CHECK_NO_THROW (testYieldQuoterHelper (0, lYieldInputFilename, isBuiltin));
<a name="l00123"></a>00123   
<a name="l00124"></a>00124 }
<a name="l00125"></a>00125 
<a name="l00130"></a>00130 BOOST_AUTO_TEST_CASE (airrac_error_parsing_input_file) {
<a name="l00131"></a>00131 
<a name="l00132"></a>00132   <span class="comment">// Input file name</span>
<a name="l00133"></a>00133   <span class="keyword">const</span> stdair::Filename_T lYieldInputFilename (<a class="code" href="airrac-paths_8hpp.html#af06cd429ada6c5a061032f4278de45d1">STDAIR_SAMPLE_DIR</a> <span class="stringliteral">&quot;/yieldstoreError01.csv&quot;</span>);
<a name="l00134"></a>00134 
<a name="l00135"></a>00135   <span class="comment">// State whether the BOM tree should be built-in or parsed from an input file</span>
<a name="l00136"></a>00136   <span class="keyword">const</span> <span class="keywordtype">bool</span> isBuiltin = <span class="keyword">false</span>;
<a name="l00137"></a>00137     
<a name="l00138"></a>00138   <span class="comment">// Try to yield quote the sample default list of travel solutions</span>
<a name="l00139"></a>00139   BOOST_CHECK_THROW (testYieldQuoterHelper (1, lYieldInputFilename, isBuiltin),
<a name="l00140"></a>00140                      <a class="code" href="classAIRRAC_1_1YieldFileParsingFailedException.html">AIRRAC::YieldFileParsingFailedException</a>);
<a name="l00141"></a>00141 }
<a name="l00142"></a>00142 
<a name="l00147"></a>00147 BOOST_AUTO_TEST_CASE (airrac_error_missing_input_file) {
<a name="l00148"></a>00148 
<a name="l00149"></a>00149   <span class="comment">// Input file name</span>
<a name="l00150"></a>00150   <span class="keyword">const</span> stdair::Filename_T lYieldInputFilename (<a class="code" href="airrac-paths_8hpp.html#af06cd429ada6c5a061032f4278de45d1">STDAIR_SAMPLE_DIR</a> <span class="stringliteral">&quot;/missingFile.csv&quot;</span>);
<a name="l00151"></a>00151 
<a name="l00152"></a>00152   <span class="comment">// State whether the BOM tree should be built-in or parsed from an input file</span>
<a name="l00153"></a>00153   <span class="keyword">const</span> <span class="keywordtype">bool</span> isBuiltin = <span class="keyword">false</span>;
<a name="l00154"></a>00154     
<a name="l00155"></a>00155   <span class="comment">// Try to yield quote the sample default list of travel solutions</span>
<a name="l00156"></a>00156   BOOST_CHECK_THROW (testYieldQuoterHelper (2, lYieldInputFilename, isBuiltin),
<a name="l00157"></a>00157                      <a class="code" href="classAIRRAC_1_1YieldInputFileNotFoundException.html">AIRRAC::YieldInputFileNotFoundException</a>);
<a name="l00158"></a>00158 }
<a name="l00159"></a>00159 
<a name="l00163"></a>00163 BOOST_AUTO_TEST_CASE (airrac_simple_yield_built_in) {
<a name="l00164"></a>00164 
<a name="l00165"></a>00165   <span class="comment">// State whether the BOM tree should be built-in or parsed from an input file</span>
<a name="l00166"></a>00166   <span class="keyword">const</span> <span class="keywordtype">bool</span> isBuiltin = <span class="keyword">true</span>;
<a name="l00167"></a>00167 
<a name="l00168"></a>00168   <span class="comment">// Try to yield quote the sample default list of travel solutions</span>
<a name="l00169"></a>00169   BOOST_CHECK_NO_THROW (testYieldQuoterHelper (3, <span class="stringliteral">&quot; &quot;</span>, isBuiltin));
<a name="l00170"></a>00170   
<a name="l00171"></a>00171 }
<a name="l00172"></a>00172 
<a name="l00173"></a>00173 <span class="comment">// End the test suite</span>
<a name="l00174"></a>00174 BOOST_AUTO_TEST_SUITE_END()
<a name="l00175"></a>00175 
<a name="l00176"></a>00176 
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="YieldTestSuite_8cpp.html">YieldTestSuite.cpp</a>      </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

		
		<li class="footer">Generated on Tue Dec 6 2011 14:11:38 for AirRAC by
		  <a href="http://www.doxygen.org/index.html">
			<img class="footer" src="doxygen.png" alt="doxygen"/></a> 
		  1.7.5
		</li>
		<li class="footer">
		  <a href="http://sourceforge.net/projects/airrac"><img class="footer" src="http://sflogo.sourceforge.net/sflogo.php?group_id=317250&type=12&format=.png" alt="SourceForge Logo"></a>
		</li>
	  </ul>
	</div>
	

	
  </body>
</html>