Major update in BTL docs
[SVN r14805]
89
doc/btl.js
Normal file
@ -0,0 +1,89 @@
|
||||
include ( "vis_object_api.js", viso_path );
|
||||
include ( "wipe_away_menu.js", viso_path );
|
||||
|
||||
function get_copyright_date() {
|
||||
document.write( "2001-2002" )
|
||||
}
|
||||
|
||||
function contact_addess() {
|
||||
document.write( "<a href='mailto:rogeeff@emailaccount.com'>Gennadiy Rozental</a>" )
|
||||
}
|
||||
|
||||
function btl_header() {
|
||||
document.write( "<div class='print-header'>" );
|
||||
document.write( "<img border='0' src='imgs/c++boost_bw.gif' style='padding-top:0; margin-top:0; '>" );
|
||||
document.write( "</div>" );
|
||||
|
||||
document.write( "<div class='screen-header'>" );
|
||||
document.write( "<table width='100%' style='border-style: none; padding:0;' cellspacing=0;>" );
|
||||
document.write( "<tr>" );
|
||||
|
||||
document.write( "<td align='left'>" );
|
||||
document.write( "<a name='TOP'><img border='0' src='../../../c++boost.gif' width='277' height='86'></a><br clear=left>" );
|
||||
document.write( "</td>" );
|
||||
|
||||
document.write( "<td align='right' width='70%' id='active_area''>" );
|
||||
|
||||
document.write( "<div id='wipe-away-menu-holder'>" );
|
||||
|
||||
document.write( "<div id='header_menu' class='header-menu'><nobr>" );
|
||||
document.write( "<a href='index.htm'>Home</a> " );
|
||||
document.write( "<a href='faq.htm'>FAQ</a> " );
|
||||
document.write( "<a href='../../../index.htm'>Boost home</a> " );
|
||||
document.write( "<a href='../../../libs/libraries.htm'>Boost libraries</a> " );
|
||||
document.write( "</nobr></div>" );
|
||||
|
||||
document.write( "<img id='header_menu_root' class='header-menu-root' src='imgs/menu_root.gif' onMouseOver='this.src=\"imgs/menu_root_on.gif\";btl_menu.show();' onMouseOut='this.src=\"imgs/menu_root.gif\";' >" );
|
||||
|
||||
document.write( "</div>" );
|
||||
|
||||
document.write( "</td></tr></table></div>" );
|
||||
}
|
||||
|
||||
function hide_btl_menu( e ) {
|
||||
if( viso_event_target( e ) == viso_get("active_area") &&
|
||||
viso_event_to_target( e ) != btl_menu.menu &&
|
||||
viso_event_to_target( e ) != btl_menu.menu_parent &&
|
||||
viso_event_to_target( e ) != btl_menu.menu_root )
|
||||
btl_menu.hide();
|
||||
}
|
||||
|
||||
style_switch.curr_style = true;
|
||||
function style_switch() {
|
||||
if( style_switch.curr_style )
|
||||
viso_get( "screen_style" ).href = "style/btl-simple.css";
|
||||
else
|
||||
viso_get( "screen_style" ).href = "style/btl.css";
|
||||
|
||||
style_switch.curr_style = !style_switch.curr_style;
|
||||
|
||||
btl_menu.init();
|
||||
}
|
||||
|
||||
function btl_menu_init() {
|
||||
btl_menu = new WipeAwayMenu( "header_menu", "header_menu_root", true, "left" );
|
||||
viso_add_event_handler( "onmouseout", hide_btl_menu, viso_get( "active_area" ) )
|
||||
viso_add_event_handler( "onclick", style_switch, viso_get( "header_menu_root" ) )
|
||||
}
|
||||
|
||||
function put_ref_to_top() {
|
||||
document.write( "<div class='ref-to-top'>" );
|
||||
var str = "<a href='#TOP'>" +
|
||||
"<img border='0' src='imgs/uarrow.gif' align='right' width='30'" +
|
||||
"onMouseDown='this.src=\"imgs/uarrow_pressed.gif\"; return true;'; " +
|
||||
"onMouseOut='this.src=\"imgs/uarrow.gif\"; window.status=window.defaultStatus; return true;' " +
|
||||
"onMouseOver='window.status=\"Jump to beggining\"; return true;' ></a>";
|
||||
document.write( str );
|
||||
|
||||
document.write( "</div>" );
|
||||
}
|
||||
|
||||
|
||||
function put_examples_roller( roller_name ) {
|
||||
document.write(
|
||||
"<a href='javascript: void " + roller_name + ".roll();'" +
|
||||
"onMouseOver='window.status='Next example'; return true;'" +
|
||||
"onMouseOut='window.status=window.defaultStatus; return true;' >" +
|
||||
"<img src='imgs/next_arrow.gif' style='border-style:none;' align='top' height='22' /></a>" );
|
||||
|
||||
}
|
@ -1,21 +1,30 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Program Execution Monitor</title>
|
||||
<title>Examples ans test modules</title>
|
||||
<script language="javascript">var viso_path="js-lib"</script>
|
||||
<script language="javascript" src="js-lib/core.js" > </script>
|
||||
|
||||
<link id="screen_style" rel="stylesheet" type="text/css" href="style/btl.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="style/btl_print.css" media="print" />
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
||||
|
||||
<script language="JavaScript">
|
||||
include ( "btl.js" );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#808080" text="#000000" link="#336699" vlink="#3F7EBE" alink="#699BCD">
|
||||
<div align="center">
|
||||
<center>
|
||||
<table border="2" cellpadding="13" bordercolor="#CDCDCD" width="80%" id="AutoNumber1" cellspacing="3" style="border-collapse: collapse">
|
||||
<tr>
|
||||
<td width="100%" align="left" valign="top" bgcolor="#f0f0f0" border="0" >
|
||||
<body onload="btl_menu_init()">
|
||||
<div align="center">
|
||||
<table class="body-table" cellspacing="3" >
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<a name="TOP"><img border="0" src="../../../c++boost.gif" width="277" height="86"></a><br clear=left>
|
||||
<script language="Javascript">btl_header()</script>
|
||||
|
||||
<h1 align="center">Boost Test Library: examples and tests</h1>
|
||||
<h1>Boost Test Library: examples and tests</h1>
|
||||
|
||||
<h2>Examples</h2>
|
||||
|
||||
@ -48,7 +57,7 @@ Expected output:<br>
|
||||
<br>
|
||||
**** error return code 205<br>
|
||||
******* errors detected; see standard output for details ****<br>
|
||||
Result Code: 205</tt></p>
|
||||
Result code: 205</tt></p>
|
||||
|
||||
<h3>2. The Program Execution Monitor test 2</h3>
|
||||
|
||||
@ -62,7 +71,7 @@ Expected output:<br>
|
||||
<br>
|
||||
**** error return code 210<br>
|
||||
******* errors detected; see standard output for details ****<br>
|
||||
Result Code: 210</tt></p>
|
||||
Result code: 210</tt></p>
|
||||
|
||||
<h3>3. The Test Execution Monitor test 1</h3>
|
||||
|
||||
@ -77,7 +86,7 @@ t_main": test test_main_result == 0 || test_main_result == <br>
|
||||
boost::exit_success failed<br>
|
||||
<br>
|
||||
*** Failures in "call_test_main"<br>
|
||||
Result Code: 1</tt></p>
|
||||
Result code: 1</tt></p>
|
||||
|
||||
<h3>4. The Test Execution Monitor test 2</h3>
|
||||
|
||||
@ -95,7 +104,7 @@ all_test_main": sample BOOST_ERROR call<br>
|
||||
in "call_test_main": test 2 == v failed<br>
|
||||
<br>
|
||||
*** Failures in "call_test_main"<br>
|
||||
Result Code: 3</tt></p>
|
||||
Result code: 3</tt></p>
|
||||
|
||||
<h3>5. The Test Execution Monitor test 3</h3>
|
||||
|
||||
@ -111,7 +120,7 @@ in "call_test_main": test v == 2 failed<br>
|
||||
all_test_main": test 2 == v failed<br>
|
||||
<br>
|
||||
*** Failures in "call_test_main"<br>
|
||||
Result Code: 2</tt></p>
|
||||
Result code: 2</tt></p>
|
||||
|
||||
<h3>6. The Test Execution Monitor test 4</h3>
|
||||
|
||||
@ -125,7 +134,7 @@ Exception in "call_test_main": C string:Test error by throwing C-<br>
|
||||
style string exception<br>
|
||||
<br>
|
||||
*** Failures in "call_test_main"<br>
|
||||
Result Code: -1</tt></p>
|
||||
Result code: -1</tt></p>
|
||||
|
||||
<h3>7. The Test Tools test</h3>
|
||||
|
||||
@ -159,7 +168,7 @@ caught\n").str() ) passed<br>
|
||||
<br>
|
||||
*** Failures in "Test Tools test"</tt></p>
|
||||
|
||||
<p><tt>Result Code: 4</tt></p>
|
||||
<p><tt>Result code: 4</tt></p>
|
||||
|
||||
<h3>8. The Unit Test Framework online test</h3>
|
||||
|
||||
@ -173,7 +182,7 @@ Need test pattern (see below): no<br>
|
||||
Expected output:<br>
|
||||
<br>
|
||||
*** No errors detected<br>
|
||||
Result Code: 0<br>
|
||||
Result code: 0<br>
|
||||
</tt></p>
|
||||
|
||||
<h3>9. The Unit Test Framework output test stream test</h3>
|
||||
@ -189,7 +198,7 @@ Expected output:<br>
|
||||
Running 5 test cases...<br>
|
||||
<br>
|
||||
*** No errors detected<br>
|
||||
Result Code: 0<br>
|
||||
Result code: 0<br>
|
||||
</tt></p>
|
||||
|
||||
<h3>10. The Unit Test Framework result report test</h3>
|
||||
@ -207,7 +216,10 @@ Need test pattern: yes<br>
|
||||
Expected output:<br>
|
||||
<br>
|
||||
*** No errors detected<br>
|
||||
Result Code: 0</tt></p>
|
||||
Result code: 0</tt></p>
|
||||
|
||||
<iframe src="../test/result_report_test.cpp" name="inline_source" class="inline-source-inlclusion">
|
||||
</iframe><br>
|
||||
|
||||
<h3>11. The Unit Test Framework extension test</h3>
|
||||
|
||||
@ -219,7 +231,7 @@ Expected output:<br>
|
||||
Running 6 test cases...<br>
|
||||
<br>
|
||||
*** No errors detected<br>
|
||||
Result Code: 0</tt></p>
|
||||
Result code: 0</tt></p>
|
||||
|
||||
<h3>12. The Unit Test Framework errors handling test</h3>
|
||||
|
||||
@ -237,16 +249,20 @@ Need test pattern: yes<br>
|
||||
Expected output:<br>
|
||||
<br>
|
||||
*** Failures in "call_test_main"<br>
|
||||
Result Code: 120</tt></p>
|
||||
Result code: 120</tt></p>
|
||||
<hr>
|
||||
<p>© <a href="mailto:boost_test_library@consultant.com">Gennadiy Rozental</a> 2001</p>
|
||||
<p>© <script language="Javascript">contact_addess()</script>
|
||||
<script language="Javascript">get_copyright_date()</script>
|
||||
</p>
|
||||
|
||||
<p>Revised:
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED"
|
||||
S-Format="%d %B, %Y" startspan -->25 December, 2001<!--webbot bot="Timestamp" endspan i-checksum="38513" -->
|
||||
S-Format="%d %B, %Y" startspan -->25 July, 2002<!--webbot bot="Timestamp" endspan i-checksum="21088" -->
|
||||
</p>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
@ -1,133 +1,134 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Execution Monitor</title>
|
||||
<script language="javascript">var viso_path="js-lib"</script>
|
||||
<script language="javascript" src="js-lib/core.js" > </script>
|
||||
|
||||
<link id="screen_style" rel="stylesheet" type="text/css" href="style/btl.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="style/btl_print.css" media="print" />
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
||||
|
||||
<script language="JavaScript">
|
||||
include ( "btl.js" );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#808080" text="#000000" link="#336699" vlink="#3F7EBE" alink="#699BCD">
|
||||
<body onload="btl_menu_init()">
|
||||
<div align="center">
|
||||
<table class="body-table" cellspacing="3" >
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<div align="center">
|
||||
<center>
|
||||
<script language="Javascript">btl_header()</script>
|
||||
|
||||
<table border="2" cellpadding="13" bordercolor="#CDCDCD" width="80%" id="AutoNumber1" cellspacing="3" style="border-collapse: collapse">
|
||||
<tr>
|
||||
<td width="100%" align="left" valign="TOP" bgcolor="#f0f0f0" border="0" >
|
||||
<h1>Boost Test Library: Execution Monitor</h1>
|
||||
|
||||
<a name="TOP"><img border="0" src="../../../c++boost.gif" width="277" height="86"></a><br clear=left>
|
||||
|
||||
<h1 align="center">Boost Test Library: Execution Monitor</h1>
|
||||
|
||||
<p><b>
|
||||
<p class="page-toc">
|
||||
<a href="#Introduction">Introduction</a><br>
|
||||
<a href="#Benefits">Benefits</a><br>
|
||||
<a href="#Specifications:monitor">Specifications</a><br>
|
||||
<a href="#MonitorCompilation">Compilation</a><br>
|
||||
<a href="#Examples">Examples</a><br>
|
||||
<a href="#Rationale">Rationale</a><br>
|
||||
<a href="#Design">Design
|
||||
</a></b></p>
|
||||
<a href="#Design">Design</a>
|
||||
</p>
|
||||
|
||||
<h2><a name="Introduction">Introduction</a></h2>
|
||||
<p>
|
||||
<p class="1-line-indented">
|
||||
The Boost Test Library's Execution Monitor calls a user-supplied function in a
|
||||
controlled environment, relieving users from
|
||||
a messy error detection.
|
||||
|
||||
To use the Execution Monitor
|
||||
derive a class from
|
||||
the <b>
|
||||
<a href="#Specifications:monitor">boost::execution_monitor</a> </b>and overwrite
|
||||
the virtual
|
||||
method <i>int</i> <b>execution_monitor</b>::function(). To start the monitored
|
||||
function call the <b>execution_monitor</b><u>:</u>:execute( timeout )
|
||||
member function. The Execution Monitor then call The
|
||||
|
||||
<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a>All
|
||||
symbols in the Execution Monitor implementation are located in the namespace
|
||||
boost. </p>
|
||||
controlled environment, relieving users from a messy error detection. To use the Execution Monitor
|
||||
derive a class from the <b><a href="#Specifications:monitor">boost::execution_monitor</a></b>
|
||||
and overwrite the virtual method int <b>execution_monitor::function</b>(). To start the monitored
|
||||
function call the <b>execution_monitor<u>:</u>:execute</b>( timeout ) member
|
||||
function. All symbols in the Execution Monitor implementation are located in the namespace boost.
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<h2><a name="Benefits">Benefits</a></h2>
|
||||
<p>Controlled execution of error prone functions with a uniform error notification.</p>
|
||||
<p class="1-line-indented">Controlled execution of error prone functions with a uniform error notification.</p>
|
||||
|
||||
<h2><a name="Specifications:monitor">Specification</a> of boost::execution_monitor</h2>
|
||||
<p><b>
|
||||
<a href="#Specifications:monitor">boost::execution_monitor</a> </b>uniformly detects and reports the occurrence of several types of signals and exceptions, reducing various errors
|
||||
to a uniform <b> <a href="#Specifications:exception"> boost::execution_exception</a> </b>which is returned to
|
||||
a caller.</p>
|
||||
<p class="1-line-indented">
|
||||
boost::execution_monitor uniformly detects and reports the occurrence of several types of signals and exceptions, reducing various errors
|
||||
to a uniform <a href="#Specifications:exception">boost::execution_exception</a> which is returned to a caller.</p>
|
||||
<p>Usage:</p>
|
||||
<ol>
|
||||
<li>Create class inherited from the <b>execution_monitor</b>.</li>
|
||||
<li>Overwrite the virtual function <i>int</i> <b>execution_monitor</b>::function().</li>
|
||||
<li>Call the method <b>execution_monitor</b>::execute( timeout ). The timeout argument specifies seconds that elapse before a
|
||||
<b><a href="#Specifications:exception"> timer_error</a></b> occurs. May be ignored on some platforms.</li>
|
||||
<li>Create class inherited from the class <span class="new-term">execution_monitor</span>.</li>
|
||||
<li>Overwrite the virtual function int execution_monitor::<span class="new-term">function</span>().</li>
|
||||
<li>Call the method execution_monitor::<span class="new-term">execute</span>( timeout ). The <span class="new-term">timeout</span>
|
||||
argument specifies seconds that elapse before a <a href="#Specifications:exception">timer_error</a>
|
||||
occurs. May be ignored on some platforms.
|
||||
</li>
|
||||
</ol>
|
||||
Effects:
|
||||
<blockquote>
|
||||
Calls the <b>execution_monitor</b>::function() inside a try/catch block which may
|
||||
also include
|
||||
|
||||
other unspecified platform dependent error detection code.
|
||||
Throws<b> <a href="#Specifications:exception">boost::execution_exception</a></b> on an uncaught C++ exception,
|
||||
a hardware or software signal, trap, or other exception.
|
||||
<b>execution_monitor</b>::execute() <u>doesn't</u> consider it an error for
|
||||
the <b>execution_monitor</b>::function() to return a non-zero value.
|
||||
</blockquote>
|
||||
Returns:
|
||||
<blockquote>
|
||||
The integer value returned by the <b>execution_monitor</b>::function().
|
||||
</blockquote>
|
||||
<h2><a name="Specifications:exception">Specification</a> of boost::execution_exception<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></h2>
|
||||
<p>class execution_exception {<br>
|
||||
public: <br>
|
||||
enum error_code {<br>
|
||||
user_error,
|
||||
// user reported non-fatal error<br>
|
||||
cpp_exception_error, // see note (1) below <br>
|
||||
system_error,
|
||||
// see note (2) below <br>
|
||||
timeout_error,
|
||||
// only detectable on certain platforms <br>
|
||||
user_fatal_error,
|
||||
// user reported fatal error <br>
|
||||
system_fatal_error
|
||||
// see note (2) below <br>
|
||||
}</p>
|
||||
<p> error_code code() const;<br>
|
||||
char const* what() const; <br>
|
||||
};</p>
|
||||
<p> Note 1: Only uncaught C++ exceptions are treated as errors. If the application catches a C++ exception, it will never reach the
|
||||
<b><a href="#Specifications:monitor">boost::execution_monitor</a></b>. </p>
|
||||
<p> Note 2: These errors include Unix signals and Windows structured exceptions. They are often initiated by hardware traps. </p>
|
||||
<p> The implementation decides what is a fatal_system_exception and what is just a system_exception. Fatal errors are so likely to have corrupted machine state (like a stack overflow or addressing exception) that it is
|
||||
<p>Effects:</p>
|
||||
<p class="indented">
|
||||
Calls the execution_monitor::function() inside a try/catch block which may also include other unspecified platform dependent error detection code.
|
||||
Throws <a href="#Specifications:exception">boost::execution_exception</a> on an uncaught C++ exception,
|
||||
a hardware or software signal, trap, or other exception. execution_monitor::execute() <u>doesn't</u> consider it an error for
|
||||
the execution_monitor::function() to return a non-zero value.
|
||||
</p>
|
||||
<p>Returns:<p>
|
||||
<p class="indented">
|
||||
The integer value returned by the execution_monitor::function().
|
||||
</p>
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
<h2><a name="Specifications:exception">Specification</a> of boost::execution_exception</h2>
|
||||
<pre class="code"><span class="reserv-word">enum</span> <span class="new-term">execution_exception</span> {
|
||||
<span class="reserv-word">public</span>:
|
||||
<span class="reserv-word">enum</span> error_code {
|
||||
cpp_exception_error, <span class="comment">// see note (1) below</span>
|
||||
system_error, <span class="comment">// see note (2) below</span>
|
||||
timeout_error, <span class="comment">// only detectable on certain platforms</span>
|
||||
user_fatal_error, <span class="comment">// user reported fatal error</span>
|
||||
system_fatal_error <span class="comment">// see note (2) below</span>
|
||||
};
|
||||
|
||||
error_code code() <span class="reserv-word">const</span>;
|
||||
<span class="cpp-type">char</span> <span class="reserv-word">const</span> what() <span class="reserv-word">const</span>;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<p> Note 1: Only uncaught C++ exceptions are treated as errors. If the application catches a C++ exception, it will never reach the
|
||||
<b><a href="#Specifications:monitor">boost::execution_monitor</a></b>.</p>
|
||||
<p> Note 2: These errors include Unix signals and Windows structured exceptions. They are often initiated by hardware traps.</p>
|
||||
<p class="1-line-indented"> The implementation decides what is a fatal_system_exception and what is just a system_exception. Fatal errors are so likely to have corrupted machine state (like a stack overflow or addressing exception) that it is
|
||||
unreasonable to continue execution.
|
||||
<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<script language="Javascript">put_ref_to_top()</script></p>
|
||||
<h2>The <a name="MonitorCompilation">Execution Monitor compilation</a></h2>
|
||||
<p>To use the Execution Monitor standalone you should include an
|
||||
<p class="1-line-indented">To use the Execution Monitor standalone you should include an
|
||||
<a href="../src/execution_monitor.cpp">execution_monitor.cpp</a> into your
|
||||
project. It is also supplied as a part of all other Boost Test Library's
|
||||
components.</p>
|
||||
project. It is also supplied as a part of all other Boost Test Library's components.</p>
|
||||
<h2><a name="Examples">Examples</a></h2>
|
||||
|
||||
For examples of usage of Execution Monitor see <a href="prg_exec_framework.htm">Program
|
||||
Execution Monitor</a>
|
||||
or <a href="unit_test_framework.htm">Unit Test Framework.</a>
|
||||
<p class="1-line-indented">For examples of usage of Execution Monitor see <a href="prg_exec_framework.htm">Program
|
||||
Execution Monitor</a> or <a href="unit_test_framework.htm">Unit Test Framework.</a> </p>
|
||||
|
||||
<h2><a name="Rationale">Rationale</a></h2>
|
||||
<p>Sometimes we need to call a function and make sure that no user or
|
||||
<p class="1-line-indented">Sometimes we need to call a function and make sure that no user or
|
||||
system originated exception are being thrown by it. Also uniform exception reporting would be convenient.
|
||||
While designing we should be aware that we can be in a situation with no (or
|
||||
almost no) memory available.</p>
|
||||
<h2><a name="Design">Design</a></h2>
|
||||
<p>The <a href="test_lib_design.htm">Boost Test Library Design</a><b> </b>document describes the relationship between
|
||||
the Execution Monitor and several other components.
|
||||
<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p class="1-line-indented">The <a href="test_lib_design.htm">Boost Test Library Design</a> document
|
||||
describes the relationship between the Execution Monitor and several other components.
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
<hr>
|
||||
<p>© <a href="mailto:boost_test_library@consultant.com">Gennadiy Rozental</a> 2001</p>
|
||||
<p>©
|
||||
<script language="Javascript">contact_addess()</script>
|
||||
<script language="Javascript">get_copyright_date()</script>
|
||||
</p>
|
||||
<p>Revised:
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED"
|
||||
S-Format="%d %B, %Y" startspan -->24 December, 2001<!--webbot bot="Timestamp" endspan i-checksum="38511" -->
|
||||
</p></TR>
|
||||
S-Format="%d %B, %Y" startspan -->29 July, 2002<!--webbot bot="Timestamp" endspan i-checksum="21096" -->
|
||||
</p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
100
doc/faq.htm
@ -1,77 +1,95 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Program Execution Monitor</title>
|
||||
<title>Frequently Asked Questions</title>
|
||||
<script language="javascript">var viso_path="js-lib"</script>
|
||||
<script language="javascript" src="js-lib/core.js" > </script>
|
||||
|
||||
<link id="screen_style" rel="stylesheet" type="text/css" href="style/btl.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="style/btl_print.css" media="print" />
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
||||
|
||||
<script language="JavaScript">
|
||||
include ( "btl.js" );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#808080" text="#000000" link="#336699" vlink="#3F7EBE" alink="#699BCD">
|
||||
<div align="center">
|
||||
<center>
|
||||
<table border="2" cellpadding="13" bordercolor="#CDCDCD" width="80%" id="AutoNumber1" cellspacing="3" style="border-collapse: collapse">
|
||||
<tr>
|
||||
<td width="100%" align="left" valign="top" bgcolor="#f0f0f0" border="0" >
|
||||
<body onload="btl_menu_init()">
|
||||
<div align="center">
|
||||
<table class="body-table" cellspacing="3" >
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<a name="TOP"><img border="0" src="../../../c++boost.gif" width="277" height="86"></a><br clear=left>
|
||||
<script language="Javascript">btl_header()</script>
|
||||
|
||||
<h1>Boost Test Library: frequently asked questions</h1>
|
||||
|
||||
<h1 align="center">Boost Test Library: frequently asked questions</h1>
|
||||
<ul>
|
||||
<li><a href="#Item 1">Where is located the latest version of the Boost Test
|
||||
Library?</a></li>
|
||||
<li><a href="#Item 1">Where is located the latest version of the Boost Test Library?</a></li>
|
||||
<li><a href="#Item 2">I found a bug. Where could I report it?</a></li>
|
||||
<li><a href="#Item 3">I have a request for a new feature. Where could I ask
|
||||
for it?</a></li>
|
||||
<li><a href="#Item 3">I have a request for a new feature. Where could I ask for it?</a></li>
|
||||
<li><a href="#Item 4">How to create test case?</a></li>
|
||||
<li><a href="#Item 5">How to create test suite?</a></li>
|
||||
<li><a href="#Item 6">Why did I get a linker error when compiling my test
|
||||
program?</a></li>
|
||||
<li><a href="#Item 7">Why did I get a linker error when compiling my test program?</a></li>
|
||||
<li><a href="#Item 7">How could I redirect testing output?</a></li>
|
||||
<li><a href="#Item 8">I want different default log trace level</a></li>
|
||||
</ul>
|
||||
|
||||
<h2><a name="Item 1">Where is located the latest version of the Boost Test
|
||||
Library?</a></h2>
|
||||
<h2><a name="Item 1">Where is located the latest version of the Boost Test Library?</a></h2>
|
||||
|
||||
<p>The latest version of Boost Test Library is available online on
|
||||
<p class="1-line-indented">The latest version of Boost Test Library is available online on
|
||||
<a href="http://www.boost.org">www.boost.org</a>.</p>
|
||||
|
||||
<h2><a name="Item 2">I found a bug. Where could I report it?</a></h2>
|
||||
|
||||
<p>You can send a bug to <a href="mailto:boost_test_library@consultant.com">
|
||||
boost_test_library@consultant.com</a>.</p>
|
||||
<p class="1-line-indented">Send a bug report to <script language="Javascript">contact_addess()</script>.</p>
|
||||
|
||||
<h2><a name="Item 3">I have a request for a new feature. Where could I ask for
|
||||
it?</a></h2>
|
||||
<h2><a name="Item 3">I have a request for a new feature. Where could I ask for it?</a></h2>
|
||||
|
||||
<p>You can send a request to <a href="mailto:boost_test_library@consultant.com">
|
||||
boost_test_library@consultant.com</a>.</p>
|
||||
<p class="1-line-indented">You can send a request to <script language="Javascript">contact_addess()</script>.</p>
|
||||
|
||||
<h2><a name="Item 4">How to create test case?</a></h2>
|
||||
|
||||
<p>To create a test case use the macro BOOST_TEST_CASE( test_function ). For
|
||||
more details see <a href="unit_test_framework.htm">Unit test framework</a>
|
||||
documentation.</p>
|
||||
<p class="1-line-indented">To create a test case use the macro BOOST_TEST_CASE( test_function ). For
|
||||
more details see <a href="unit_test_framework.htm#Components">Unit test framework</a> documentation.</p>
|
||||
|
||||
<h2><a name="Item 5">How to create test suite?</a></h2>
|
||||
|
||||
<p>To create a test suite use the macro BOOST_TEST_SUITE( suite_name ). For more
|
||||
details see <a href="unit_test_framework.htm">Unit test framework</a>
|
||||
documentation.</p>
|
||||
<p class="1-line-indented">To create a test suite use the macro BOOST_TEST_SUITE( suite_name ). For more
|
||||
details see <a href="unit_test_framework.htm#TestSuite">Unit test framework</a> documentation.</p>
|
||||
|
||||
<h2><a name="Item 6">Why did I get a linker error when compiling my test
|
||||
program?</a></h2>
|
||||
<h2><a name="Item 6">Why did I get a linker error when compiling my test program?</a></h2>
|
||||
|
||||
<p>Boost Test Library is implemented offline. To create a test program you
|
||||
<p class="1-line-indented">Boost Test Library is implemented offline. To create a test program you
|
||||
should link with the compiled framework library of include the framework source
|
||||
files into your test program.</p>
|
||||
|
||||
<h2><a name="Item 7">How could I redirect testing output?</a></h2>
|
||||
|
||||
<p class="1-line-indented">Use unit_test_log::instance()->set_log_output( std::ostream& ). For more
|
||||
details see <a href="unit_test_framework.htm#TestLog">Unit test framework</a>
|
||||
documentation.</p>
|
||||
|
||||
<h2><a name="Item 8">I want different default log trace level</a></h2>
|
||||
|
||||
<p class="1-line-indented">Use environment variable BOOST_TEST_LOG_LEVEL to define desired log trace
|
||||
level. You still will be able to reset this value from the command line. For the
|
||||
list of acceptable values see
|
||||
<a href="unit_test_framework.htm#FrameworkParameters">Unit test framework</a> documentation. </p>
|
||||
<hr>
|
||||
<p>© <a href="mailto:boost_test_library@consultant.com">Gennadiy Rozental</a> 2001</p>
|
||||
<p>© <script language="Javascript">contact_addess()</script>
|
||||
<script language="Javascript">get_copyright_date()</script>
|
||||
</p>
|
||||
<p>Revised:
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED"
|
||||
S-Format="%d %B, %Y" startspan -->25 December, 2001<!--webbot bot="Timestamp" endspan i-checksum="38513" -->
|
||||
S-Format="%d %B, %Y" startspan -->26 July, 2002<!--webbot bot="Timestamp" endspan i-checksum="21090" -->
|
||||
</p>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
@ -1,70 +1,97 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Floating point comparison</title>
|
||||
<script language="javascript">var viso_path="js-lib"</script>
|
||||
<script language="javascript" src="js-lib/core.js" > </script>
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Test Tools</title>
|
||||
<link id="screen_style" rel="stylesheet" type="text/css" href="style/btl.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="style/btl_print.css" media="print" />
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
||||
|
||||
<script language="JavaScript">
|
||||
include ( "btl.js" );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#808080" text="#000000" link="#336699" vlink="#3F7EBE" alink="#699BCD">
|
||||
<div align="center">
|
||||
<center>
|
||||
<table border="2" cellpadding="13" bordercolor="#CDCDCD" width="80%" id="AutoNumber1" cellspacing="3" style="border-collapse: collapse">
|
||||
<tr>
|
||||
<td width="100%" align="left" valign="TOP" bgcolor="#f0f0f0" border="0" >
|
||||
<body onload="btl_menu_init()">
|
||||
<div align="center">
|
||||
<table class="body-table" cellspacing="3" >
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<a name="TOP"><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></a><br clear="left">
|
||||
<script language="Javascript">btl_header()</script>
|
||||
|
||||
<h1 align="center">Floating-point comparison algorithms</h1>
|
||||
<p><b>
|
||||
<h1>Floating-point comparison algorithms</h1>
|
||||
|
||||
<p class="page-toc">
|
||||
<a href="#Introduction">Introduction</a><br>
|
||||
<a href="#tolerance">How to choose a tolerance</a><br>
|
||||
<a href="#Specification">The close_at_tolerance algorithm</a></b><br>
|
||||
<b><a href="#Compilation">Compilation</a></b><br>
|
||||
<b>
|
||||
<a href="#Specification">The close_at_tolerance algorithm</a><br>
|
||||
<a href="#Compilation">Compilation</a><br>
|
||||
<a href="#Acknowledgements">Acknowledgements</a><br>
|
||||
<a href="#References">References</a>
|
||||
</b></p>
|
||||
</p>
|
||||
|
||||
<h2><a name="Introduction">Introduction</a></h2>
|
||||
|
||||
<p>In most cases it is unreasonable to use an operator=(...) for a
|
||||
<p class="1-line-indented">In most cases it is unreasonable to use an operator=(...) for a
|
||||
floating-point values equality check The simple solution like abs(f1-f2) <= e does not work
|
||||
for very small or very big values. This floating-point comparison algorithm is
|
||||
based on the more confident solution presented by Knuth in [1]. For a
|
||||
given floating point values <i>u</i> and <i>v</i> and a tolerance <i>e</i>:</p>
|
||||
|
||||
<p> |<i> u </i>-<i> v </i>| <= <i>e * |u|</i> and |<i> u </i>-<i>
|
||||
v </i>| <= <i>e * |v|</i> (<b><a name="F.1">1</a></b>)<br>
|
||||
|
||||
defines a "very close with tolerance <i>e</i>" relationship between <i>u</i> and
|
||||
<i>v<br>
|
||||
</i> |<i> u </i>-<i> v </i>| <= <i>e * |u|</i> or
|
||||
|<i> u </i>-<i> v </i>| <= <i>e * |v|</i> <i> </i>(<b><a name="F.2">2</a></b>)<br>
|
||||
|
||||
defines a "close enough with tolerance <i>e</i>" relationship between <i>u</i> and
|
||||
<i>v</i></p>
|
||||
<table class="2fields">
|
||||
<tr>
|
||||
<td>
|
||||
<p style="text-indent: -20">
|
||||
|<i> u </i>-<i> v </i>| <= <i>e * |u|</i> and |<i> u </i>-<i> v </i>| <= <i>e * |v|<br>
|
||||
</i>defines a "very close with tolerance <i>e</i>" relationship between <i>u</i> and <i>v</i>
|
||||
</td>
|
||||
<td valign="top">
|
||||
(<b><a name="F.1">1</a></b>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p style="text-indent: -20">
|
||||
|<i> u </i>-<i> v </i>| <= <i>e * |u|</i> or |<i> u </i>-<i> v </i>| <= <i>e * |v|<br>
|
||||
</i>defines a "close enough with tolerance <i>e</i>" relationship between <i>u</i> and <i>v</i>
|
||||
</td>
|
||||
<td valign="top">
|
||||
(<a name="F.1"><b>2</b></a>)
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>Both relationships are commutative but are not transitive. The relationship
|
||||
<p class="1-line-indented">Both relationships are commutative but are not transitive. The relationship
|
||||
defined by inequations (<b>1</b>) is stronger that the relationship defined by
|
||||
inequations (<b>2</b>) (i.e. (<b>1</b>) => (<b>2</b>) ). Because of the multiplication
|
||||
inequations (<b>2</b>) (i.e. (<b>1</b>) => (<b>2</b>) ). Because of the multiplication
|
||||
in the right side of inequations, that could cause an unwanted underflow condition, the
|
||||
implementation is using modified version of the inequations (<b>1</b>) and (<b>2</b>)
|
||||
where all underflow, overflow conditions could be guarded safely:</p>
|
||||
|
||||
<p> |<i> u </i>-<i> v </i>| / <i> |u| </i><= <i>e</i> and |<i> u </i>-<i>
|
||||
v </i>| / <i> |v| </i><= <i>e</i>
|
||||
(<b>1`</b>)<br>
|
||||
|<i> u </i>-<i> v </i>| / <i> |u| </i> <= <i>e</i>
|
||||
or |<i> u </i>-<i>
|
||||
v </i>| / <i> |v| </i> <= <i>e</i>
|
||||
(<b>2`</b>)<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<table class="2fields">
|
||||
<tr>
|
||||
<td>
|
||||
<p style="margin-left: -20">
|
||||
|
||||
<h2><b>
|
||||
<a name="tolerance">How to choose a tolerance</a></b></h2>
|
||||
|<i> u </i>-<i> v </i>| / <i> |u| </i><= <i>e</i> and |<i> u </i>-<i> v </i>| / <i> |v| </i><= <i>e<br>
|
||||
</i>|<i> u </i>-<i> v </i>| / <i> |u| </i> <= <i>e</i> or |<i> u </i>-<i> v </i>| / <i> |v| </i> <= <i>e</i>
|
||||
</td>
|
||||
<td>
|
||||
(<b>1`</b>)<br>
|
||||
(<b>2`</b>)
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>In case of absence of a domain specific requirements the value of tolerance could be chosen
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
|
||||
<h2><a name="tolerance">How to choose a tolerance</a></h2>
|
||||
|
||||
<p class="1-line-indented">In case of absence of a domain specific requirements the value of tolerance could be chosen
|
||||
as a sum of the predicted upper limits for
|
||||
"relative rounding errors" of compared values. The "rounding" is the operation
|
||||
by which a real value 'x' is represented in a floating-point format with 'p'
|
||||
@ -80,7 +107,7 @@ point value may be caused by several reasons:</p>
|
||||
<li>Non-arithmetic operation</li>
|
||||
</ul>
|
||||
|
||||
<p>The first two operations proved to have a relative rounding error that does
|
||||
<p class="1-line-indented">The first two operations proved to have a relative rounding error that does
|
||||
not exceed 1/2 * "machine epsilon value" for the appropriate floating point type
|
||||
(represented by std::numeric_limits<FPT>::epsilon()). conversion to binary
|
||||
presentation, sadly, does not have such requirement. So we can't assume that
|
||||
@ -92,7 +119,7 @@ arithmetic and non arithmetic operations might also produce others
|
||||
as underflow/overflow,
|
||||
division-by-zero or 'operation errors'. </p>
|
||||
|
||||
<p>All theorems about the upper limit of a rounding error, including that of
|
||||
<p class="1-line-indented">All theorems about the upper limit of a rounding error, including that of
|
||||
1/2*epsilon, refers <u>only</u> to the 'rounding' operation, nothing more. This
|
||||
means that the 'operation error', that is, the error incurred by the operation
|
||||
itself, besides rounding, isn't considered. In order for numerical software to
|
||||
@ -106,48 +133,61 @@ does not require same behavior from most non-arithmetic operation. The
|
||||
underflow/overflow and division-by-zero errors may cause rounding errors with unpredictable
|
||||
upper limits.</p>
|
||||
|
||||
<p>For a given number of rounding error (in a simple case it's just a
|
||||
number of floating point constants and arithmetic involved) it is proposed to
|
||||
calculate a tolerance as follows:</p>
|
||||
<p class="1-line-indented">For a given number of rounding error (in a simple case it's just a
|
||||
number of floating point constants and arithmetic involved) it is proposed to calculate a tolerance as follows:</p>
|
||||
|
||||
<p> <i>n</i>*std::numeric_limits<T>::epsilon()/2 (<b><a name="F.3">3</a></b>)</p>
|
||||
|
||||
<table class="2fields">
|
||||
<tr>
|
||||
<td>
|
||||
<i>n</i>*std::numeric_limits<T>::epsilon()/2</td>
|
||||
<td>
|
||||
(<b>3</b>)
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>where n is number of floating-point rounding errors.</p>
|
||||
|
||||
<p>For more reading about floating-point comparison see references at the end.</p>
|
||||
<p class="1-line-indented">For more reading about floating-point comparison see references at the end.</p>
|
||||
|
||||
<h2> <b>
|
||||
The <a name="Specification">close_at_tolerance</a> algorithm</b></h2>
|
||||
<h2>The <a name="Specification">close_at_tolerance</a> algorithm</h2>
|
||||
|
||||
<p>The <b>
|
||||
<a name="Specification">close_at_tolerance</a></b> algorithm allows to check the
|
||||
relationship defines by inequations (<b><a href="#F.1">1</a></b>) or (<b><a href="#F.2">2</a></b>).
|
||||
It is implemented as binary predicate.</p>
|
||||
|
||||
<p><i>template</i><<i>typename</i> FPT><br>
|
||||
<i>class</i> close_at_tolerance {<br>
|
||||
<i>public</i>:<br>
|
||||
close_at_tolerance( FPT tolerance, <i>bool</i> strong_or_weak
|
||||
= <i>true</i> );<br>
|
||||
close_at_tolerance( <i>int</i> number_of_rounding_errors, <i>
|
||||
bool</i> strong_or_weak = <i>true</i> );<br>
|
||||
<br>
|
||||
<i>bool</i> operator()( FPT left, FPT right ) <i>const</i>;<br>
|
||||
};</p>
|
||||
<pre class="code"><span class="reserv-word">template</span><<span class="reserv-word">typename</span> FPT>
|
||||
<span class="reserv-word">class</span> close_at_tolerance
|
||||
{
|
||||
<span class="reserv-word">public</span>:
|
||||
close_at_tolerance( FPT tolerance, <span class="cpp-type">bool</span> strong_or_weak = <span class="reserv-word">true</span> );
|
||||
close_at_tolerance( <span class="cpp-type">int</span> number_of_rounding_errors,
|
||||
<span class="cpp-type">bool</span> strong_or_weak = <span class="reserv-word">true</span> );
|
||||
|
||||
<p>The first constructor allows to specify a tolerance value to compare against.
|
||||
<span class="cpp-type">bool</span> <span class="reserv-word">operator</span>()( FPT left, FPT right ) <span class="reserv-word">const</span>;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<p class="1-line-indented">The first constructor allows to specify a tolerance value to compare against.
|
||||
The first constructor allows to specify a number of rounding errors, in which
|
||||
case a tolerance is computed using expression (<b><a href="#F.3">3</a></b>). The
|
||||
strong_or_weak switch allows to which relationship is checked. The default
|
||||
behavior is to check strong relationship defined by inequations (<b><a href="#F.1">1</a></b>).<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
behavior is to check strong relationship defined by inequations (<b><a href="#F.1">1</a></b>).<script language="Javascript">put_ref_to_top()</script></p>
|
||||
<h2><a name="Compilation">Compilation</a></h2>
|
||||
<p>The <b>
|
||||
<p class="1-line-indented">The <b>
|
||||
<a name="Specification">close_at_tolerance</a></b> algorithm is implemented in
|
||||
the header file
|
||||
<a href="../../../boost/test/detail/floating_point_comparison.hpp">
|
||||
floating_point_comparison.hpp</a>.</p>
|
||||
detail/floating_point_comparison.hpp</a>. It is recommended to use test tools
|
||||
wrappers located on <a href="../../../boost/test/test_tools.hpp">test_tools.hpp</a>.
|
||||
Note that you still need to include
|
||||
<a href="../../../boost/test/detail/floating_point_comparison.hpp">
|
||||
detail/floating_point_comparison.hpp</a> yourself since it does not get included
|
||||
automatically.</p>
|
||||
<h2><a name="Acknowledgement">Acknowledgement</a></h2>
|
||||
<p>Fernando Cacciola for very helpful discussion of floating point arithmetic in
|
||||
<p class="1-line-indented">Fernando Cacciola for very helpful discussion of floating point arithmetic in
|
||||
the boost forum.</p>
|
||||
<h2><a name="References">References</a></h2>
|
||||
<p>[1] Knuth D.E. <i>The art of computer programming</i> (vol II)<b>.</b><br>
|
||||
@ -167,16 +207,20 @@ Rounding Error Estimation to Automatic Correction with Automatic Differentiation
|
||||
Floats: How To Determine if Floating Quantities Are Close Enough Once a
|
||||
Tolerance Has Been Reached</a><b> </b>C++ Report March 2000.<br>
|
||||
[5] Pete Becker The Journeyman's Shop: Trap Handlers, Sticky Bits, and
|
||||
Floating-Point Comparisons C/C++ Users Journal December 2000.<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
Floating-Point Comparisons C/C++ Users Journal December 2000.<script language="Javascript">put_ref_to_top()</script></p>
|
||||
<hr>
|
||||
<p>© <a href="mailto:boost_test_library@consultant.com">Gennadiy Rozental</a> 2001</p>
|
||||
<p>© <script language="Javascript">contact_addess()</script>
|
||||
<script language="Javascript">get_copyright_date()</script>
|
||||
</p>
|
||||
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED"
|
||||
S-Format="%d %b %Y" startspan -->24 Dec 2001<!--webbot bot="Timestamp" endspan i-checksum="14398" -->
|
||||
S-Format="%d %b %Y" startspan -->28 Jul 2002<!--webbot bot="Timestamp" endspan i-checksum="15002" -->
|
||||
</p>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,207 +1,205 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Execution Monitor</title>
|
||||
<title>Getting started</title>
|
||||
<script language="javascript">var viso_path="js-lib"</script>
|
||||
<script language="javascript" src="js-lib/core.js" > </script>
|
||||
|
||||
<link id="screen_style" rel="stylesheet" type="text/css" href="style/btl.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="style/btl_print.css" media="print" />
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
||||
|
||||
<script language="JavaScript">
|
||||
include ( "btl.js" );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#808080" text="#000000" link="#336699" vlink="#3F7EBE" alink="#699BCD">
|
||||
<body onload="btl_menu_init()">
|
||||
<div align="center">
|
||||
<table class="body-table" cellspacing="3" >
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<div align="center">
|
||||
<center>
|
||||
|
||||
<table border="2" cellpadding="13" bordercolor="#CDCDCD" width="80%" id="AutoNumber1" cellspacing="3" style="border-collapse: collapse">
|
||||
<tr>
|
||||
<td width="100%" align="left" valign="TOP" bgcolor="#f0f0f0" border="0" >
|
||||
|
||||
<a name="TOP"><img border="0" src="../../../c++boost.gif" width="277" height="86"></a><br clear=left>
|
||||
<script language="Javascript">btl_header()</script>
|
||||
|
||||
<h1 align="center">Getting started to use unit test framework</h1>
|
||||
|
||||
<p>Today is a momentous day. Today I am going to start a new life. I am going to stop
|
||||
<p class="1-line-indented">Today is a momentous day. Today I am going to start a new life. I am going to stop
|
||||
eating a greasy food, start attending a fitness club and ... since today I am going to test programs
|
||||
I am writing. I can start after the last line of a program is completed or, even
|
||||
better idea, I can write tests while I am coding. And maybe next time I will
|
||||
write tests before the coding during the design stage. I have read a lot of literature
|
||||
on how to write the tests, I have the unit test framework in hand and an idea of new
|
||||
class. So let's get started. </p>
|
||||
<p>Let say I want to encapsulate an unchangeable C character buffer with a length
|
||||
class. So let's get started.</p>
|
||||
<p class="1-line-indented">Let say I want to encapsulate an unchangeable C character buffer with a length
|
||||
into the simple class <b>const_string</b>. Rationale: a string class that does not
|
||||
allocate a memory and provide a convenient read-only access to the preallocated
|
||||
character buffer. I will probably want <b>const_string</b> to have an interface similar to
|
||||
the class <b>std::string</b>. What will I do first? In my
|
||||
the class std::string. What will I do first? In my
|
||||
new life I will start with writing a test module for future class <b>const_string</b>. It will look
|
||||
like this:</p>
|
||||
<p>const_string_test.cpp:</p>
|
||||
<p>#include <boost/test/unit_test.hpp><i><br>
|
||||
using namespace</i> boost::unit_test_framework;</p>
|
||||
<p>test_suite*<br>
|
||||
init_unit_test_suite( <i>int</i> argc, <i>char</i>* argv[] )<br>
|
||||
{ <br>
|
||||
test_suite* test= BOOST_TEST_SUITE("const_string
|
||||
test");</p>
|
||||
<p> return test;<br>
|
||||
}</p>
|
||||
<p>// EOF</p>
|
||||
<p>Now I can compile it and link with the unit test framework. Done! I have a
|
||||
<pre class="code">#<span class="reserv-word">include</span> <boost/test/unit_test.hpp>
|
||||
<span class="reserv-word">using namespace</span> boost::unit_test_framework;
|
||||
|
||||
test_suite*
|
||||
init_unit_test_suite( <span class="cpp-type">int</span> argc, <span class="cpp-type">char</span>* argv[] )
|
||||
{
|
||||
test_suite* test= BOOST_TEST_SUITE( <span class="literal">"const_string test"</span> );
|
||||
|
||||
<span class="reserv-word">return</span> test;
|
||||
}
|
||||
|
||||
<span class="comment">// EOF</span></pre>
|
||||
|
||||
<p class="1-line-indented">Now I can compile it and link with the unit test framework. Done! I have a
|
||||
working test program. It is empty, so when I
|
||||
run the program it produces following output:</p>
|
||||
<p>Running 0 test case...<br>
|
||||
*** No errors detected</p>
|
||||
<p>Well, now it could be a good time to start a work on <b>const_string</b>.
|
||||
<p class="test-output">*** No errors detected</p>
|
||||
<p class="1-line-indented">Well, now it could be a good time to start a work on <b>const_string</b>.
|
||||
First thing I imagine would be good to have is a constructors and trivial access
|
||||
methods. So my class initial version looks like this:</p>
|
||||
<p>const_string.hpp</p>
|
||||
<p><i>class</i> const_string {<br>
|
||||
<i>public</i>:<br>
|
||||
// Constructors<br>
|
||||
const_string();<br>
|
||||
const_string( std::string <i>const</i>& s )<br>
|
||||
const_string( <i>char const</i>* s );<br>
|
||||
const_string( <i>char const</i>* s, <i>size_t</i> length );<br>
|
||||
const_string( <i>char const</i>* begin, <i>char const</i>*
|
||||
end );</p>
|
||||
<p> // Access methods<br>
|
||||
<i>char const</i>* data() <i>const</i>;<br>
|
||||
<i>size_t</i>
|
||||
length() <i>const;</i><br>
|
||||
<i>bool</i>
|
||||
is_empty() <i>const</i>;</p>
|
||||
<p> ...<br>
|
||||
};</p>
|
||||
<p>Now I am able to write a first test case - constructors testing - and add it
|
||||
<pre class="code"><span class="reserv-word">class</span> const_string {
|
||||
<span class="reserv-word">public</span>:
|
||||
// Constructors
|
||||
const_string();
|
||||
const_string( <span class="cpp-type">std::string</span> <span class="reserv-word">const</span>& s )
|
||||
const_string( <span class="cpp-type">char</span> <span class="reserv-word">const</span>* s );
|
||||
const_string( <span class="cpp-type">char</span> <span class="reserv-word">const</span>* s, <span class="cpp-type">size_t</span> length );
|
||||
const_string( <span class="cpp-type">char</span> <span class="reserv-word">const</span>* begin, <span class="cpp-type">char</span> <span class="reserv-word">const</span>* end );
|
||||
|
||||
// Access methods
|
||||
<span class="cpp-type">char</span> <span class="reserv-word">const</span>* data() <span class="reserv-word">const</span>;
|
||||
<span class="cpp-type">size_t</span> length() <span class="reserv-word">const</span>;
|
||||
<span class="cpp-type">bool</span> is_empty() <span class="reserv-word">const</span>;
|
||||
|
||||
...
|
||||
};</pre>
|
||||
<p class="1-line-indented">Now I am able to write a first test case - constructors testing - and add it
|
||||
to a test suite. My test program became to look like this:</p>
|
||||
<p>const_string_test.cpp:</p>
|
||||
<p>#include <boost/test/unit_test.hpp><i><br>
|
||||
using namespace</i> boost::unit_test_framework;</p>
|
||||
<p><i>void</i> constructors_test()<br>
|
||||
{ <br>
|
||||
<b>const_string</b> cs0( ""
|
||||
);
|
||||
// 1 //<br>
|
||||
BOOST_CHECK_EQUAL( cs0.length(), (size_t)0 );<br>
|
||||
BOOST_CHECK( cs0.is_empty() );</p>
|
||||
<p> <b>const_string</b> cs01( NULL
|
||||
);
|
||||
// 2 //<br>
|
||||
BOOST_CHECK_EQUAL( cs01.length(), (size_t)0 );<br>
|
||||
BOOST_CHECK( cs01.is_empty() );</p>
|
||||
<p> <b>const_string</b> cs1( "test_string"
|
||||
);
|
||||
// 3 //<br>
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(),
|
||||
"test_string" ), 0 );<br>
|
||||
BOOST_CHECK_EQUAL( cs1.length(),
|
||||
std::strlen("test_string") );</p>
|
||||
<p> std::string s( "test_string"
|
||||
);
|
||||
// 4 //<br>
|
||||
<b>const_string</b> cs2( s );<br>
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs2.data(),
|
||||
"test_string" ), 0 );</p>
|
||||
<p> <b>const_string</b> cs3( cs1
|
||||
);
|
||||
// 5 //<br>
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(),
|
||||
"test_string" ), 0 );</p>
|
||||
<p> <b>const_string</b> cs4( "test_string", 4
|
||||
);
|
||||
// 6 //<br>
|
||||
BOOST_CHECK_EQUAL( std::strncmp( cs4.data(),
|
||||
"test", cs4.length() ), 0 );</p>
|
||||
<p> <b>const_string</b> cs5( s.data(), s.data() + s.length()
|
||||
);
|
||||
// 7 //<br>
|
||||
BOOST_CHECK_EQUAL( std::strncmp( cs5.data(),
|
||||
"test_string", cs5.length() ), 0 );</p>
|
||||
<p> <b>const_string</b> cs_array[] = { "str1",
|
||||
"str2"
|
||||
};
|
||||
// 8 //</p>
|
||||
<p> BOOST_CHECK_EQUAL( cs_array[0], "str1" );<br>
|
||||
BOOST_CHECK_EQUAL( cs_array[1], "str2" );<br>
|
||||
}</p>
|
||||
<p>test_suite*<br>
|
||||
init_unit_test_suite( <i>int</i> argc, <i>char</i>* argv[] )<br>
|
||||
{ <br>
|
||||
test_suite* test= BOOST_TEST_SUITE("const_string
|
||||
test");</p>
|
||||
<p> test->add( BOOST_TEST_CASE( &constructors_test ) );</p>
|
||||
<p> <i>return</i> test;<br>
|
||||
}</p>
|
||||
<p>// EOF</p>
|
||||
<p>The constructors_test test case is intended to check a simple feature of the class <b>const_string</b>:
|
||||
<pre class="code">#include <boost/test/unit_test.hpp>
|
||||
<span class="reserv-word">using namespace</span> boost::unit_test_framework;
|
||||
|
||||
<span class="cpp-type">void</span> constructors_test() {
|
||||
const_string cs0( <span class="literal">""</span> ); <span class="comment">// 1 //</span>
|
||||
BOOST_CHECK_EQUAL( cs0.length(), (<span class="cpp-type">size_t</span>)<span class="literal">0</span> );
|
||||
BOOST_CHECK( cs0.is_empty() );
|
||||
|
||||
const_string cs01( NULL ); <span class="comment">// 2 //</span>
|
||||
BOOST_CHECK_EQUAL( cs01.length(), (<span class="cpp-type">size_t</span>)<span class="literal">0</span> );
|
||||
BOOST_CHECK( cs01.is_empty() );
|
||||
|
||||
const_string cs1( <span class="literal">"test_string"</span> ); <span class="comment">// 3 //</span>
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(), <span class="literal">"test_string"</span> ), <span class="literal">0</span> );
|
||||
BOOST_CHECK_EQUAL( cs1.length(), std::strlen("test_string") );
|
||||
|
||||
<span class="cpp-type">std::string</span> s( <span class="literal">"test_string"</span> ); <span class="comment">// 4 //</span>
|
||||
const_string cs2( s );
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs2.data(), <span class="literal">"test_string"</span> ), <span class="literal">0</span> );
|
||||
|
||||
const_string cs3( cs1 ); <span class="comment">// 5 //</span>
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(), <span class="literal">"test_string"</span> ), <span class="literal">0</span> );
|
||||
|
||||
const_string cs4( <span class="literal">"test_string"</span>, <span class="literal">4</span> ); <span class="comment">// 6 //</span>
|
||||
BOOST_CHECK_EQUAL( std::strncmp( cs4.data(), <span class="literal">"test"</span>, cs4.length() ), <span class="literal">0</span> );
|
||||
|
||||
const_string cs5( s.data(), s.data() + s.length() ); <span class="comment">// 7 //</span>
|
||||
BOOST_CHECK_EQUAL( std::strncmp( cs5.data(), <span class="literal">"test_string"</span>, cs5.length() ), <span class="literal">0</span> );
|
||||
|
||||
const_string cs_array[] = { <span class="literal">"str1"</span>, <span class="literal">"str2"</span> }; <span class="comment">// 8 //</span>
|
||||
BOOST_CHECK_EQUAL( cs_array[<span class="literal">0</span>], <span class="literal">"str1"</span> );
|
||||
BOOST_CHECK_EQUAL( cs_array[<span class="literal">1</span>], <span class="literal">"str2"</span> );
|
||||
}
|
||||
|
||||
test_suite*
|
||||
init_unit_test_suite( <span class="cpp-type">int</span> argc, <span class="cpp-type">char</span>* argv[] )
|
||||
{
|
||||
test_suite* test= BOOST_TEST_SUITE( <span class="literal">"const_string test"</span> );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &constructors_test ) );
|
||||
|
||||
<span class="reserv-word">return</span> test;
|
||||
}
|
||||
|
||||
<span class="comment">// EOF</span></pre>
|
||||
|
||||
<p class="1-line-indented">The constructors_test test case is intended to check a simple feature of the class const_string:
|
||||
an ability to construct itself properly based on different arguments. To test this
|
||||
feature I am using such characteristics of constructed object as a data it
|
||||
contains and a length. The specification of the class <b>const_string</b> does not contain any
|
||||
contains and a length. The specification of the class const_string does not contain any
|
||||
expected failures, so, though the constructor can fail if I would pass a pointer to
|
||||
an invalid memory, error check control is not performed (can't require what was not
|
||||
promised :-)). But for any valid input it should work. So I am trying to check
|
||||
a construction for an empty string (1), a NULL string (2) a regular C string(3),
|
||||
an STL
|
||||
string(4), a copy construction(5) and so on . Well, after fixing all the errors in
|
||||
a construction for an empty string (1), a NULL string (2) a regular C string(3),
|
||||
an STL string(4), a copy construction(5) and so on . Well, after fixing all the errors in
|
||||
the implementation (do you write programs without errors from scratch?) I am able to pass
|
||||
this test case and the unit test framework gives me the following report:</p>
|
||||
<p>Running 1 test case...<br>
|
||||
|
||||
<p class="test-output">Running 1 test case...<br>
|
||||
*** No errors detected</p>
|
||||
<p>Encouraged I am moving on and adding more access methods:</p>
|
||||
|
||||
<p class="1-line-indented">Encouraged I am moving on and adding more access methods:</p>
|
||||
<p>const_string.hpp</p>
|
||||
<p><i>class</i> const_string {<br>
|
||||
<i>public</i>:<br>
|
||||
...<br>
|
||||
<i>char</i> operator[]( <i>size_t</i> index ) <i>const</i>;<br>
|
||||
<i>char</i> at( <i>size_t</i> index ) <i>const</i>;<br>
|
||||
...<br>
|
||||
};</p>
|
||||
<p>I added the new feature - I need a new test case to check it. As a
|
||||
<pre class="code"><span class="reserv-word">class</span> const_string {
|
||||
<span class="reserv-word">public</span>:
|
||||
<span class="cpp-type">char</span> <span class="reserv-word">operator</span>[]( <span class="cpp-type">size_t</span> index ) <span class="reserv-word">const</span>;
|
||||
<span class="cpp-type">char</span> at( <span class="cpp-type">size_t</span> index ) <span class="reserv-word">const</span>;
|
||||
...
|
||||
};
|
||||
</pre>
|
||||
<p class="1-line-indented">I added the new feature - I need a new test case to check it. As a
|
||||
result my test suite became to look like this:</p>
|
||||
<p>const_string_test.cpp:</p>
|
||||
<p>#include <boost/test/unit_test.hpp><i><br>
|
||||
using namespace</i> boost::unit_test_framework;</p>
|
||||
<p><i>void</i> constructors_test()<br>
|
||||
{<br>
|
||||
... <br>
|
||||
}</p>
|
||||
<p><i>void</i> data_access_test()<br>
|
||||
{ <br>
|
||||
<b>const_string</b> cs1( "test_string" );<br>
|
||||
BOOST_CHECK_EQUAL( cs1[(size_t)0], 't'
|
||||
);
|
||||
// 1 //<br>
|
||||
BOOST_CHECK_EQUAL( cs1[(size_t)4], '_' );<br>
|
||||
BOOST_CHECK_EQUAL( cs1[cs1.length()-1], 'g' );</p>
|
||||
<p> BOOST_CHECK_EQUAL( cs1[(size_t)0], cs1.at( 0 )
|
||||
);
|
||||
// 2 //<br>
|
||||
BOOST_CHECK_EQUAL( cs1[(size_t)2], cs1.at( 5 ) );<br>
|
||||
BOOST_CHECK_EQUAL( cs1.at( cs1.length() - 1 ), 'g' );</p>
|
||||
<p> BOOST_CHECK_THROW( cs1.at( cs1.length() ),
|
||||
std::out_of_range ); // 3 //<br>
|
||||
}</p>
|
||||
<p>test_suite*<br>
|
||||
init_unit_test_suite( <i>int</i> argc, <i>char</i>* argv[] )<br>
|
||||
{ <br>
|
||||
test_suite* test= BOOST_TEST_SUITE("const_string
|
||||
test");</p>
|
||||
<p> test->add( BOOST_TEST_CASE( &constructors_test ) );<br>
|
||||
test->add( BOOST_TEST_CASE( &data_access_test ) );</p>
|
||||
<p> <i>return</i> test;<br>
|
||||
}</p>
|
||||
<p>// EOF</p>
|
||||
<p>In the data_access_test test case I am trying to check the class <b>const_string</b> character access
|
||||
correctness. While tests (1) checks valid access using <b>const_string</b>::operator[] and test (2)
|
||||
checks valid access using method <b>const_string</b>::at(), there is one more thing to test. The
|
||||
specification of the method <b>const_string</b>::at() contains validation for the out of bound access. That
|
||||
<pre class="code">#<span class="reserv-word">include</span> <boost/test/unit_test.hpp>
|
||||
<span class="reserv-word">using namespace</span> boost::unit_test_framework;
|
||||
|
||||
<span class="cpp-type">void</span> constructors_test() {
|
||||
...
|
||||
}
|
||||
|
||||
<span class="cpp-type">void</span> data_access_test() {
|
||||
const_string cs1( <span class="literal">"test_string"</span> ); <span class="comment">// 1 //</span>
|
||||
BOOST_CHECK_EQUAL( cs1[(<span class="cpp-type">size_t</span>)<span class="literal">0</span>], <span class="literal">'t'</span> );
|
||||
BOOST_CHECK_EQUAL( cs1[(<span class="cpp-type">size_t</span>)<span class="literal">4</span>], <span class="literal">'_'</span> );
|
||||
BOOST_CHECK_EQUAL( cs1[cs1.length()-<span class="literal">1</span>], <span class="literal">'g'</span> );
|
||||
|
||||
BOOST_CHECK_EQUAL( cs1[(<span class="cpp-type">size_t</span>)<span class="literal">0</span>], cs1.at( <span class="literal">0</span> ) ); <span class="comment">// 2 //</span>
|
||||
BOOST_CHECK_EQUAL( cs1[(<span class="cpp-type">size_t</span>)<span class="literal">2</span>], cs1.at( <span class="literal">5</span> ) );
|
||||
BOOST_CHECK_EQUAL( cs1.at( cs1.length() - <span class="literal">1</span> ), <span class="literal">'g'</span> );
|
||||
|
||||
BOOST_CHECK_THROW( cs1.at( cs1.length() ), std::out_of_range ); <span class="comment">// 3 //</span>
|
||||
}
|
||||
|
||||
test_suite*
|
||||
init_unit_test_suite( <span class="cpp-type">int</span> argc, <span class="cpp-type">char</span>* argv[] )
|
||||
{
|
||||
test_suite* test= BOOST_TEST_SUITE( <span class="literal">"const_string test"</span> );
|
||||
test->add( BOOST_TEST_CASE( &constructors_test ) );
|
||||
test->add( BOOST_TEST_CASE( &data_access_test ) );
|
||||
|
||||
<span class="reserv-word">return</span> test;
|
||||
}
|
||||
|
||||
<span class="comment">// EOF</span>
|
||||
</pre>
|
||||
|
||||
<p class="1-line-indented">In the data_access_test test case I am trying to check the class const_string character access
|
||||
correctness. While tests (1) checks valid access using const_string::operator[] and test (2)
|
||||
checks valid access using method const_string::at(), there is one more thing to test. The
|
||||
specification of the method const_string::at() contains validation for the out of bound access. That
|
||||
was test (3) is intended to do: check that the validation is working. A testing of
|
||||
a validation and error handling code is an important part of a unit testing and should
|
||||
not be left for a production stage. The data_access_test test case passed and I am ready for the next
|
||||
step. </p>
|
||||
<p>Continuing my effort I am able to complete class <b>const_string</b> (see <a href="getting_started/const_string.hpp">Listing
|
||||
step.</p>
|
||||
<p class="1-line-indented">Continuing my effort I am able to complete class const_string (see <a href="getting_started/const_string.hpp">Listing
|
||||
1</a>) and testing module for it (see <a href="getting_started/const_string_test.cpp">Listing
|
||||
2</a>) that is checking all features that are presented in the class <b>const_string</b>
|
||||
specification. </p>
|
||||
<p>Your testing habits could be a little different. You could start with a class/library development and then at some point start writing test cases on
|
||||
2</a>) that is checking all features that are presented in the class const_string
|
||||
specification.</p>
|
||||
<p class="1-line-indented">Your testing habits could be a little different. You could start with a class/library development and then at some point start writing test cases on
|
||||
feature basis. Or you can, given a detailed specification for the future product,
|
||||
including expected interfaces, immediately start with writing all test cases (or
|
||||
it could be a different person, while you working on implementation at the same
|
||||
@ -212,10 +210,16 @@ ability to make a changes of any complexity without involving a lengthy regressi
|
||||
testing of your whole product. Your test module and the unit test framework will
|
||||
stay behind your back to help you with any occasional errors.</p>
|
||||
<hr>
|
||||
<p><EFBFBD> <a href="mailto:boost_test_library@consultant.com">Gennadiy Rozental</a> 2001</p>
|
||||
<p>© <script language="Javascript">contact_addess()</script>
|
||||
<script language="Javascript">get_copyright_date()</script>
|
||||
</p>
|
||||
<p>Revised:
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED"
|
||||
S-Format="%d %B, %Y" startspan -->24 December, 2001<!--webbot bot="Timestamp" endspan i-checksum="38511" -->
|
||||
</p></TR>
|
||||
S-Format="%d %B, %Y" startspan -->28 July, 2002<!--webbot bot="Timestamp" endspan i-checksum="21094" -->
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</div>
|
||||
</body>
|
||||
<html>
|
||||
|
164
doc/getting_started/const_string.hpp
Normal file
@ -0,0 +1,164 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied warranty,
|
||||
// and with no claim as to its suitability for any purpose.
|
||||
|
||||
#ifndef CONST_STRING_HPP
|
||||
#define CONST_STRING_HPP
|
||||
|
||||
// STL
|
||||
#include <string>
|
||||
using std::string;
|
||||
|
||||
namespace common_layer {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** const_string ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class const_string {
|
||||
public:
|
||||
// Subtypes
|
||||
typedef char const* iterator;
|
||||
typedef char const* const_iterator;
|
||||
#if defined(__SUNPRO_CC) && !defined(__SGI_STL_PORT)
|
||||
typedef std::reverse_iterator<iterator,std::random_access_iterator_tag, char, char const&> reverse_iterator;
|
||||
#else
|
||||
typedef std::reverse_iterator<iterator,char, char const&> reverse_iterator;
|
||||
#endif
|
||||
typedef reverse_iterator const_reverse_iterator;
|
||||
|
||||
// Constructor
|
||||
const_string()
|
||||
: m_begin( "" ), m_end( m_begin ) {}
|
||||
|
||||
// Copy constructor is generated by compiler
|
||||
|
||||
const_string( const std::string& s )
|
||||
: m_begin( s.c_str() ),
|
||||
m_end( m_begin + s.length() ) {}
|
||||
|
||||
const_string( char const* s );
|
||||
|
||||
const_string( char const* s, size_t length )
|
||||
: m_begin( s ), m_end( m_begin + length ) { if( length == 0 ) erase(); }
|
||||
|
||||
const_string( char const* first, char const* last )
|
||||
: m_begin( first ), m_end( last ) {}
|
||||
|
||||
// data access methods
|
||||
char operator[]( size_t index ) const { return m_begin[index]; }
|
||||
char at( size_t index ) const;
|
||||
|
||||
char const* data() const { return m_begin; }
|
||||
#ifndef NO_CONST_STRING_IMPLISIT_CONVERTION
|
||||
operator char const*() const { return m_begin; }
|
||||
#endif
|
||||
|
||||
// length operators
|
||||
size_t length() const { return m_end - m_begin; }
|
||||
bool is_empty() const { return m_end == m_begin; }
|
||||
|
||||
void erase() { m_begin = m_end = ""; }
|
||||
void resize( size_t new_len ) { if( m_begin + new_len < m_end ) m_end = m_begin + new_len; }
|
||||
void rshorten( size_t shift = 1 ) { m_end -= shift; if( m_end <= m_begin ) erase(); }
|
||||
void lshorten( size_t shift = 1 ) { m_begin += shift; if( m_end <= m_begin ) erase(); }
|
||||
|
||||
// Assignment operators
|
||||
const_string& operator=( const_string const& s );
|
||||
const_string& operator=( string const& s ) { return *this = const_string( s ); }
|
||||
const_string& operator=( char const* s ) { return *this = const_string( s ); }
|
||||
|
||||
const_string& assign( const_string const& s ) { return *this = s; }
|
||||
const_string& assign( string const& s, size_t len ) { return *this = const_string( s.data(), len ); }
|
||||
const_string& assign( string const& s ) { return *this = const_string( s ); }
|
||||
const_string& assign( char const* s ) { return *this = const_string( s ); }
|
||||
const_string& assign( char const* s, size_t len ) { return *this = const_string( s, len ); }
|
||||
const_string& assign( char const* f, char const* l ) { return *this = const_string( f, l ); }
|
||||
|
||||
void swap( const_string& s ) {
|
||||
// do not want to include alogrithm
|
||||
char const* tmp1 = m_begin;
|
||||
char const* tmp2 = m_end;
|
||||
|
||||
m_begin = s.m_begin;
|
||||
m_end = s.m_end;
|
||||
|
||||
s.m_begin = tmp1;
|
||||
s.m_end = tmp2;
|
||||
}
|
||||
|
||||
// Comparison operators
|
||||
friend bool operator==( const_string const& s1, const_string const& s2 );
|
||||
friend bool operator==( const_string const& s1, char const* s2 ) { return s1 == const_string( s2 ); }
|
||||
friend bool operator==( const_string const& s1, const string& s2 ) { return s1 == const_string( s2 ); }
|
||||
|
||||
friend bool operator!=( const_string const& s1, const_string const& s2 ) { return !(s1 == s2); }
|
||||
friend bool operator!=( const_string const& s1, char const* s2 ) { return !(s1 == s2); }
|
||||
friend bool operator!=( const_string const& s1, const string& s2 ) { return !(s1 == s2); }
|
||||
|
||||
friend bool operator==( char const* s2, const_string const& s1 ) { return s1 == s2; }
|
||||
friend bool operator==( const string& s2, const_string const& s1 ) { return s1 == s2; }
|
||||
|
||||
friend bool operator!=( char const* s2, const_string const& s1 ) { return !(s1 == s2); }
|
||||
friend bool operator!=( const string& s2, const_string const& s1 ) { return !(s1 == s2); }
|
||||
|
||||
// Iterators
|
||||
iterator begin() const { return m_begin; }
|
||||
iterator end() const { return m_end; }
|
||||
reverse_iterator rbegin() const { return m_end; }
|
||||
reverse_iterator rend() const { return m_begin; }
|
||||
|
||||
// search operation
|
||||
iterator find_first_of( char c );
|
||||
iterator find_first_of( const_string cs );
|
||||
iterator find_last_of( char c );
|
||||
iterator find_last_of( const_string cs );
|
||||
|
||||
private:
|
||||
|
||||
// Data members
|
||||
char const* m_begin;
|
||||
char const* m_end;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// first character
|
||||
class first_char {
|
||||
public:
|
||||
char operator()( const_string source, char default_char = '\0' ) const {
|
||||
return source.is_empty() ? default_char : *source.data();
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// last character
|
||||
class last_char {
|
||||
public:
|
||||
char operator()( const_string source, char default_char = '\0' ) const {
|
||||
return source.is_empty() ? default_char : *source.rbegin();
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
inline const_string&
|
||||
const_string::operator=( const_string const& s ) {
|
||||
if( &s != this ) {
|
||||
m_begin = s.m_begin;
|
||||
m_end = s.m_end;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
typedef const_string const literal;
|
||||
|
||||
}; // namespace common_layer
|
||||
|
||||
#endif // CONST_STRING_HPP
|
306
doc/getting_started/const_string_test.cpp
Normal file
@ -0,0 +1,306 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied warranty,
|
||||
// and with no claim as to its suitability for any purpose.
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <const_string.hpp>
|
||||
#include <const_string_traits.hpp>
|
||||
#include <const_string_compare.hpp>
|
||||
#include <const_string_oper.hpp>
|
||||
#include <const_string_io.hpp>
|
||||
|
||||
using common_layer::const_string;
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
using namespace boost::unit_test_framework;
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
# ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std { using ::strlen; using ::strcmp; using ::strncmp; }
|
||||
# endif
|
||||
|
||||
void constructors_test() {
|
||||
const_string cs0( "" );
|
||||
BOOST_CHECK_EQUAL( cs0.length(), (size_t)0 );
|
||||
BOOST_CHECK_EQUAL( cs0.begin(), "" );
|
||||
BOOST_CHECK_EQUAL( cs0.end(), "" );
|
||||
BOOST_CHECK( cs0.is_empty() );
|
||||
|
||||
const_string cs01( NULL );
|
||||
BOOST_CHECK_EQUAL( cs01.length(), (size_t)0 );
|
||||
BOOST_CHECK_EQUAL( cs01.begin(), "" );
|
||||
BOOST_CHECK_EQUAL( cs01.end(), "" );
|
||||
BOOST_CHECK( cs01.is_empty() );
|
||||
|
||||
const_string cs1( "test_string" );
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(), "test_string" ), 0 );
|
||||
BOOST_CHECK_EQUAL( cs1.length(), std::strlen("test_string") );
|
||||
|
||||
std::string s( "test_string" );
|
||||
const_string cs2( s );
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs2.data(), "test_string" ), 0 );
|
||||
|
||||
const_string cs3( cs1 );
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(), "test_string" ), 0 );
|
||||
|
||||
const_string cs4( "test_string", 4 );
|
||||
BOOST_CHECK_EQUAL( std::strncmp( cs4.data(), "test", cs4.length() ), 0 );
|
||||
|
||||
const_string cs5( s.data(), s.data() + s.length() );
|
||||
BOOST_CHECK_EQUAL( std::strncmp( cs5.data(), "test_string", cs5.length() ), 0 );
|
||||
|
||||
const_string cs_array[] = { "str1", "str2" };
|
||||
|
||||
BOOST_CHECK_EQUAL( cs_array[0], "str1" );
|
||||
BOOST_CHECK_EQUAL( cs_array[1], "str2" );
|
||||
}
|
||||
|
||||
void data_access_test() {
|
||||
const_string cs1( "test_string" );
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(), "test_string" ), 0 );
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(), cs1 ), 0 );
|
||||
|
||||
BOOST_CHECK_EQUAL( cs1[(size_t)0], 't' );
|
||||
BOOST_CHECK_EQUAL( cs1[(size_t)4], '_' );
|
||||
BOOST_CHECK_EQUAL( cs1[cs1.length()-1], 'g' );
|
||||
|
||||
BOOST_CHECK_EQUAL( cs1[(size_t)0], cs1.at( 0 ) );
|
||||
BOOST_CHECK_EQUAL( cs1[(size_t)2], cs1.at( 5 ) );
|
||||
BOOST_CHECK_EQUAL( cs1.at( cs1.length() - 1 ), 'g' );
|
||||
|
||||
BOOST_CHECK_THROW( cs1.at( cs1.length() ), std::out_of_range );
|
||||
|
||||
BOOST_CHECK_EQUAL( common_layer::first_char()( cs1 ), 't' );
|
||||
BOOST_CHECK_EQUAL( common_layer::last_char()( cs1 ) , 'g' );
|
||||
}
|
||||
|
||||
void length_test() {
|
||||
const_string cs1;
|
||||
|
||||
BOOST_CHECK_EQUAL( cs1.length(), (size_t)0 );
|
||||
BOOST_CHECK( cs1.is_empty() );
|
||||
|
||||
cs1 = "";
|
||||
BOOST_CHECK_EQUAL( cs1.length(), (size_t)0 );
|
||||
BOOST_CHECK( cs1.is_empty() );
|
||||
|
||||
cs1 = "test_string";
|
||||
BOOST_CHECK_EQUAL( cs1.length(), (size_t)11 );
|
||||
|
||||
cs1.erase();
|
||||
BOOST_CHECK_EQUAL( cs1.length(), (size_t)0 );
|
||||
BOOST_CHECK_EQUAL( cs1.data(), "" );
|
||||
|
||||
cs1 = const_string( "test_string", 4 );
|
||||
BOOST_CHECK_EQUAL( cs1.length(), (size_t)4 );
|
||||
|
||||
cs1.resize( 5 );
|
||||
BOOST_CHECK_EQUAL( cs1.length(), (size_t)4 );
|
||||
|
||||
cs1.resize( 3 );
|
||||
BOOST_CHECK_EQUAL( cs1.length(), (size_t)3 );
|
||||
|
||||
cs1.rshorten();
|
||||
BOOST_CHECK_EQUAL( cs1.length(), (size_t)2 );
|
||||
BOOST_CHECK_EQUAL( cs1[(size_t)0], 't' );
|
||||
|
||||
cs1.lshorten();
|
||||
BOOST_CHECK_EQUAL( cs1.length(), (size_t)1 );
|
||||
BOOST_CHECK_EQUAL( cs1[(size_t)0], 'e' );
|
||||
|
||||
cs1.lshorten();
|
||||
BOOST_CHECK( cs1.is_empty() );
|
||||
BOOST_CHECK_EQUAL( cs1.data(), "" );
|
||||
|
||||
cs1 = "test_string";
|
||||
cs1.lshorten( 11 );
|
||||
BOOST_CHECK( cs1.is_empty() );
|
||||
BOOST_CHECK_EQUAL( cs1.data(), "" );
|
||||
}
|
||||
|
||||
void asignment_test() {
|
||||
const_string cs1;
|
||||
std::string s( "test_string" );
|
||||
|
||||
cs1 = "test";
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(), "test" ), 0 );
|
||||
|
||||
cs1 = s;
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(), "test_string" ), 0 );
|
||||
|
||||
cs1.assign( "test" );
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(), "test" ), 0 );
|
||||
|
||||
const_string cs2( "test_string" );
|
||||
|
||||
cs1.swap( cs2 );
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs1.data(), "test_string" ), 0 );
|
||||
BOOST_CHECK_EQUAL( std::strcmp( cs2.data(), "test" ), 0 );
|
||||
}
|
||||
|
||||
void comparison_test() {
|
||||
const_string cs1( "test_string" );
|
||||
const_string cs2( "test_string" );
|
||||
std::string s( "test_string" );
|
||||
|
||||
BOOST_CHECK_EQUAL( cs1, "test_string" );
|
||||
BOOST_CHECK_EQUAL( "test_string", cs1 );
|
||||
BOOST_CHECK_EQUAL( cs1, cs2 );
|
||||
BOOST_CHECK_EQUAL( cs1, s );
|
||||
BOOST_CHECK_EQUAL( s , cs1 );
|
||||
|
||||
cs1.resize( 4 );
|
||||
|
||||
BOOST_CHECK( cs1 != "test_string" );
|
||||
BOOST_CHECK( "test_string" != cs1 );
|
||||
BOOST_CHECK( cs1 != cs2 );
|
||||
BOOST_CHECK( cs1 != s );
|
||||
BOOST_CHECK( s != cs1 );
|
||||
|
||||
BOOST_CHECK_EQUAL( cs1, "test" );
|
||||
}
|
||||
|
||||
void iterators_test() {
|
||||
const_string cs1( "test_string" );
|
||||
std::string s;
|
||||
|
||||
std::copy( cs1.begin(), cs1.end(), std::back_inserter( s ) );
|
||||
BOOST_CHECK_EQUAL( cs1, s );
|
||||
|
||||
s.erase();
|
||||
|
||||
std::copy( cs1.rbegin(), cs1.rend(), std::back_inserter( s ) );
|
||||
BOOST_CHECK_EQUAL( const_string( s ), "gnirts_tset" );
|
||||
}
|
||||
|
||||
void traits_test() {
|
||||
const_string cs1( "1234567" );
|
||||
|
||||
BOOST_CHECK( common_layer::isDigit()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlpha()( cs1 ) );
|
||||
BOOST_CHECK( common_layer::isAlnum()( cs1 ) );
|
||||
BOOST_CHECK( common_layer::isNumber()( cs1 ) );
|
||||
|
||||
cs1 = "asdRTY";
|
||||
|
||||
BOOST_CHECK( !common_layer::isDigit()( cs1 ) );
|
||||
BOOST_CHECK( common_layer::isAlpha()( cs1 ) );
|
||||
BOOST_CHECK( common_layer::isAlnum()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isNumber()( cs1 ) );
|
||||
|
||||
cs1 = "-145";
|
||||
|
||||
BOOST_CHECK( !common_layer::isDigit()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlpha()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlnum()( cs1 ) );
|
||||
BOOST_CHECK( common_layer::isNumber()( cs1 ) );
|
||||
|
||||
cs1 = "+145e-3";
|
||||
|
||||
BOOST_CHECK( !common_layer::isDigit()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlpha()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlnum()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isNumber()( cs1 ) );
|
||||
|
||||
cs1 = "+145.3";
|
||||
|
||||
BOOST_CHECK( !common_layer::isDigit()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlpha()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlnum()( cs1 ) );
|
||||
BOOST_CHECK( common_layer::isNumber()( cs1 ) );
|
||||
|
||||
cs1 = "145L";
|
||||
|
||||
BOOST_CHECK( !common_layer::isDigit()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlpha()( cs1 ) );
|
||||
BOOST_CHECK( common_layer::isAlnum()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isNumber()( cs1 ) );
|
||||
|
||||
cs1 = "145#";
|
||||
|
||||
BOOST_CHECK( !common_layer::isDigit()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlpha()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlnum()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isNumber()( cs1 ) );
|
||||
|
||||
cs1 = "145.34.45";
|
||||
|
||||
BOOST_CHECK( !common_layer::isDigit()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlpha()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isAlnum()( cs1 ) );
|
||||
BOOST_CHECK( !common_layer::isNumber()( cs1 ) );
|
||||
}
|
||||
|
||||
void compare_test() {
|
||||
const_string cs1( "abcd" );
|
||||
const_string cs2( "abbdd" );
|
||||
const_string cs3( "abbde" );
|
||||
const_string cs4( "aBCd" );
|
||||
|
||||
BOOST_CHECK( std::less<const_string>()( cs1, cs2 ) );
|
||||
BOOST_CHECK( std::less<const_string>()( cs2, cs3 ) );
|
||||
BOOST_CHECK( std::less<const_string>()( cs1, cs3 ) );
|
||||
BOOST_CHECK( common_layer::case_ins_eq()( cs1, cs4 ) );
|
||||
}
|
||||
|
||||
void operations_test() {
|
||||
const_string cs1( "abcd " );
|
||||
const_string cs2( " abcd" );
|
||||
const_string cs3( " abcd " );
|
||||
|
||||
BOOST_CHECK_EQUAL( common_layer::trim_left<const_string>()( cs2 ) , "abcd" );
|
||||
BOOST_CHECK_EQUAL( common_layer::trim_right<const_string>()( cs1 ), "abcd" );
|
||||
BOOST_CHECK_EQUAL( common_layer::trim<const_string>()( cs3 ) , "abcd" );
|
||||
}
|
||||
|
||||
void io_test() {
|
||||
const_string cs1( "test_string" );
|
||||
cs1.rshorten( 7 );
|
||||
|
||||
boost::output_test_stream ostr;
|
||||
|
||||
ostr << std::setw( 6 ) << cs1;
|
||||
BOOST_CHECK( ostr.is_equal( " test" ) );
|
||||
|
||||
ostr << std::setw( 3 ) << cs1;
|
||||
BOOST_CHECK( ostr.is_equal( "test" ) );
|
||||
|
||||
ostr << std::setw( 5 ) << std::setiosflags( std::ios_base::left ) << cs1;
|
||||
BOOST_CHECK( ostr.is_equal( "test " ) );
|
||||
}
|
||||
|
||||
void search_test() {
|
||||
const_string cs( "test_string" );
|
||||
|
||||
BOOST_CHECK_EQUAL( cs.find_first_of( 't' ), cs.begin() );
|
||||
BOOST_CHECK_EQUAL( cs.find_last_of( 't' ), cs.begin() + 6 );
|
||||
|
||||
BOOST_CHECK_EQUAL( cs.find_first_of( "st" ), cs.begin() + 2 );
|
||||
BOOST_CHECK_EQUAL( cs.find_last_of( "st" ), cs.begin() + 5 );
|
||||
}
|
||||
|
||||
test_suite*init_unit_test_suite( int argc, char* argv[] ) {
|
||||
test_suite* test= BOOST_TEST_SUITE("const_string test");
|
||||
|
||||
test->add( BOOST_TEST_CASE( &constructors_test ) );
|
||||
test->add( BOOST_TEST_CASE( &data_access_test ) );
|
||||
test->add( BOOST_TEST_CASE( &length_test ) );
|
||||
test->add( BOOST_TEST_CASE( &asignment_test ) );
|
||||
test->add( BOOST_TEST_CASE( &comparison_test ) );
|
||||
test->add( BOOST_TEST_CASE( &iterators_test ) );
|
||||
test->add( BOOST_TEST_CASE( &traits_test ) );
|
||||
test->add( BOOST_TEST_CASE( &compare_test ) );
|
||||
test->add( BOOST_TEST_CASE( &operations_test ) );
|
||||
test->add( BOOST_TEST_CASE( &io_test ) );
|
||||
test->add( BOOST_TEST_CASE( &search_test ) );
|
||||
|
||||
return test;
|
||||
}
|
||||
|
||||
// EOF
|
BIN
doc/imgs/c++boost_bw.gif
Normal file
After Width: | Height: | Size: 8.9 KiB |
BIN
doc/imgs/menu_root.gif
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
doc/imgs/menu_root_on.gif
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
doc/imgs/next_arrow.gif
Normal file
After Width: | Height: | Size: 715 B |
BIN
doc/imgs/uarrow.gif
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
doc/imgs/uarrow_pressed.gif
Normal file
After Width: | Height: | Size: 1.7 KiB |
167
doc/index.htm
@ -1,153 +1,152 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Boost Test Libraries</title>
|
||||
<script language="javascript">var viso_path="js-lib"</script>
|
||||
<script language="javascript" src="js-lib/core.js" > </script>
|
||||
|
||||
<link id="screen_style" rel="stylesheet" type="text/css" href="style/btl.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="style/btl_print.css" media="print" />
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
||||
|
||||
<script language="JavaScript">
|
||||
include ( "btl.js" );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#808080" text="#000000" link="#336699" vlink="#3F7EBE" alink="#699BCD">
|
||||
<div align="center">
|
||||
<center>
|
||||
<table border="2" cellpadding="13" bordercolor="#CDCDCD" width="80%" id="AutoNumber1" cellspacing="3" style="border-collapse: collapse">
|
||||
<tr>
|
||||
<td width="100%" align="left" valign="top" bgcolor="#f0f0f0" border="0" >
|
||||
<body onload="btl_menu_init()">
|
||||
<div align="center"">
|
||||
<table class="body-table" cellspacing="3" >
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<a name="TOP"><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86" align="left"></a>
|
||||
<br>
|
||||
<br>
|
||||
<p align="right"><b>
|
||||
<script language="Javascript">btl_header()</script>
|
||||
|
||||
<a href="../../../index.htm"><font face="Arial" color="#000000">Home</font></a>
|
||||
<a href="../../../libs/libraries.htm"><font face="Arial" color="#000000">Libraries</font></a>
|
||||
<a href="../../../people/people.htm"><font face="Arial" color="#000000">People</font></a>
|
||||
<a href="../../../more/faq.htm"><font face="Arial" color="#000000">FAQ</font></a>
|
||||
<a href="../../../more/index.htm"><font face="Arial" color="#000000">More</font></a></b><br clear=left>
|
||||
<h1>Boost Test Library</h1>
|
||||
|
||||
<p class=epigraph>"Test everything that could possibly break"</p>
|
||||
<p class=epigraph>XP maxim</p>
|
||||
|
||||
<h1 align="center"><b>Boost Test Library</b></h1>
|
||||
|
||||
<p align="right"><font face="Century Gothic"><i>"Test everything that could
|
||||
possibly break"</i></font></p>
|
||||
|
||||
<p align="right"><i><font face="Century Gothic">XP maxim</font></i></p>
|
||||
|
||||
<p><b>
|
||||
<p class="page-toc">
|
||||
<a href="#Introduction">Introduction</a><br>
|
||||
<a href="#Components">Components<br></a>
|
||||
<a href="execution_monitor.htm">Execution monitor</a><br>
|
||||
<a href="prg_exec_monitor.htm">Program Execution Monitor</a><br>
|
||||
<a href="test_tools.htm">Test Tools</a><br>
|
||||
<a href="test_exec_monitor.htm">Test Execution Monitor</a><br>
|
||||
<a href="unit_test_framework.htm">Unit Test Framework</a>
|
||||
<a href="#FAQ"><br>FAQ</a><br>
|
||||
<a href="#Components">Components</a>
|
||||
<p class="page-toc-indented">
|
||||
<a href="execution_monitor.htm">Execution monitor</a><br>
|
||||
<a href="prg_exec_monitor.htm">Program Execution Monitor</a><br>
|
||||
<a href="test_tools.htm">Test Tools</a><br>
|
||||
<a href="test_exec_monitor.htm">Test Execution Monitor</a><br>
|
||||
<a href="unit_test_framework.htm">Unit Test Framework</a>
|
||||
</p>
|
||||
<p class="page-toc">
|
||||
<a href="#FAQ">FAQ</a><br>
|
||||
<a href="#Design">Design</a><br>
|
||||
<a href="#Open Issues">Open Issues</a><br>
|
||||
<a href="#Portability">Portability</a><br>
|
||||
<a href="#Acknowledgements">Acknowledgements</a>
|
||||
</b></p>
|
||||
</p>
|
||||
|
||||
<h2><a name="Introduction">Introduction</a></h2>
|
||||
<p> Boost Test Library provides a matched set of components for writing test programs,
|
||||
organizing tests in to simple test cases, test suites, and controlling their
|
||||
runtime execution. The
|
||||
<p class="1-line-indented">The Boost Test Library provides a matched set of components for writing test programs,
|
||||
organizing tests in to simple test cases and test suites, and controlling their runtime execution. The
|
||||
<a href="prg_exec_monitor.htm"> Program Execution Monitor</a> is also useful in some production (non-test) environments.
|
||||
<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
</p>
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
<h2><a name="Components">Components</a></h2>
|
||||
<ul>
|
||||
<li><a href="execution_monitor.htm">Execution Monitor</a> - a basic exception and error
|
||||
detection and reporting facility for use in both production and test programs.
|
||||
The Execution Monitor calls a user-supplied function and reports all caught
|
||||
runtime exceptions. It is used internally by other Boost Test Library
|
||||
components. It also could be used in some production environment to implement
|
||||
controlled dangerous functions call.</li>
|
||||
<li><a href="execution_monitor.htm">Execution Monitor</a> - a basic exception
|
||||
and error detection and reporting facility for use in both production and test
|
||||
programs. The Execution Monitor calls a user-supplied function and reports all
|
||||
caught runtime exceptions. It is used internally by other Boost Test Library
|
||||
components. It also could be used in some production environment to make
|
||||
controlled calls of functions which might otherwise crash the program.</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="prg_exec_monitor.htm">Program Execution Monitor</a> - a simple helper facility to
|
||||
be used to monitor a program execution. The Program Execution Monitor provides
|
||||
the <b>main()</b> function
|
||||
and uses the Execution Monitor to control a program execution. It is supposed
|
||||
to be used in production environment to produce uniform error reports. To
|
||||
control programs working in test environment prefer the <a href="test_exec_monitor.htm">Test Execution Monitor</a>.</li>
|
||||
and uses the Execution Monitor to control a program execution. It should be used in production environment to produce uniform error reports. To
|
||||
control programs working in test environment, use the <a href="test_exec_monitor.htm">Test Execution Monitor</a>
|
||||
instead.</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="test_tools.htm">Test Tools</a> - a toolbox for various testing needs.
|
||||
<li><a href="test_tools.htm">Test Tools</a> - a toolbox for various testing needs.
|
||||
Test Tools are used by test programs working under control of the <a href="test_exec_monitor.htm">Test Execution Monitor</a>
|
||||
or the <a href="unit_test_framework.htm">Unit Test Framework</a>.
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="test_exec_monitor.htm">Test Execution Monitor</a> - a simple helper facility
|
||||
to be used to monitor a test program execution. The Test Execution Monitor provides
|
||||
the <b>main()</b>
|
||||
function to control a simple test program execution and allows to use the <a href="test_tools.htm">Test Tools</a>
|
||||
<li><a href="test_exec_monitor.htm">Test Execution Monitor</a> - causes a test
|
||||
program to run in a monitored environment. The Test Execution Monitor provides
|
||||
the <b>main()</b> function to control a simple test program execution and allows to use the <a href="test_tools.htm">Test Tools</a>
|
||||
to implement test logic. It is intended to be used in test environment. To
|
||||
control production code execution use the <a href="prg_exec_monitor.htm">Program Execution Monitor</a>.</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="unit_test_framework.htm">Unit Test Framework</a> - a framework
|
||||
that simplifies writing
|
||||
and organizing test cases. The framework supports test cases written as simple
|
||||
free functions or member functions and organizes them into a tree of test
|
||||
suites. The framework allows to use the <a href="test_tools.htm">Test Tools</a>
|
||||
to implement a test cases and provides
|
||||
a facility to
|
||||
manage a log report level and a result report level.<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a>
|
||||
that simplifies writing and organizing test cases. The framework supports test cases written as simple
|
||||
free functions or member functions and organizes them into a tree of test suites. The framework allows
|
||||
to use the <a href="test_tools.htm">Test Tools</a> to implement a test cases and provides a facility to
|
||||
manage a log report level and a result report level.
|
||||
</li>
|
||||
</ul>
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
|
||||
<h2><a name="FAQ">FAQ</a></h2>
|
||||
<p>See <a href="faq.htm">Boost Test Library FAQ</a>.</p>
|
||||
<p class="1-line-indented">See <a href="faq.htm">Boost Test Library FAQ</a>.</p>
|
||||
<h2><a name="Design">Design</a></h2>
|
||||
<p>See <a href="test_lib_design.htm">Boost Test Library Design</a>.
|
||||
</p>
|
||||
<p class="1-line-indented">See <a href="test_lib_design.htm">Boost Test Library Design</a>.</p>
|
||||
<h2><a name="Open Issues">Open Issues</a></h2>
|
||||
<ul>
|
||||
<li>What dependences will we tolerate in Boost Test Library? Also we need
|
||||
means to overcome this restriction for extensions.</li>
|
||||
<li>Memory usage test tools.</li>
|
||||
<li>Performance test tools.</li>
|
||||
<li>Facilities to allow testing of template function for the provided type
|
||||
list.</li>
|
||||
<li>Facilities to allow testing of template function for the provided type list.</li>
|
||||
<li>How to implement compilability checks.</li>
|
||||
<li>Selective test cases run: ways to define by user and notify the
|
||||
framework.</li>
|
||||
<li>Command line argument processing facility: external or internal, simple or
|
||||
advanced?</li>
|
||||
<li>Selective test cases run: ways to define by user and notify the framework.</li>
|
||||
<li>Command line argument processing facility: external or internal, simple or advanced?</li>
|
||||
<li>Integration of the unit test framework into the Boost Build System.</li>
|
||||
<li>Support for the testing of multi-threaded programs.</li>
|
||||
<li>Make BOOST_TEST_CLOSE to print values properly</li>
|
||||
<li>Make BOOST_TEST_CLOSE print values properly</li>
|
||||
<li>Timeout implementation on Win32 platform.</li>
|
||||
<li>Need to separate reference and tutorial material</li>
|
||||
<li>Unit Test Framework extension should be documented</li>
|
||||
<li>Should the execution monitor page contain an example? <a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></li>
|
||||
<li>Should the execution monitor page contain an example?</li>
|
||||
</ul>
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
<h2><a name="Portability">Portability</a></h2>
|
||||
<p>Because the Boost Test Library is critical for porting and testing Boost libraries, it has been written to be
|
||||
extremely conservative in
|
||||
its use of C++ features, and to keep dependencies to a bare minimum.</p>
|
||||
<p>Tests have been run (and work) under numerous compilers.</p>
|
||||
<p class="1-line-indented">Because the Boost Test Library is critical for porting and testing Boost libraries, it has been written to be
|
||||
extremely conservative in its use of C++ features, and to keep dependencies to a bare minimum.</p>
|
||||
<p class="1-line-indented">Tests have been run (and work) under numerous compilers.</p>
|
||||
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
|
||||
<p>Original Test Library:</p>
|
||||
<p>Ed Brey, Kevlin Henney, Ullrich Koethe, and Thomas Matelich provided very
|
||||
<p class="1-line-indented">Ed Brey, Kevlin Henney, Ullrich Koethe, and Thomas Matelich provided very
|
||||
helpful comments during development. Dave Abrahams, Ed Brey, William Kempf, Jens
|
||||
Maurer, and Wilka suggested numerous improvements during the Formal
|
||||
Review. Jens Maurer was the review manager. Beman Dawes was the
|
||||
Maurer, and Wilka suggested numerous improvements during the Formal Review. Jens Maurer was the review manager. Beman Dawes is the
|
||||
developer and maintainer.</p>
|
||||
<p>Second Release:</p>
|
||||
<p>Beman Dawes and Ullrich Koethe started the library.<br>
|
||||
Gennadiy Rozental is the developer and maintainer.<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
|
||||
<p class="1-line-indented">Beman Dawes and Ullrich Koethe started the library.
|
||||
Fernando Cacciola, Jeremy Siek, Beman Dawes, Ullrich Koethe, Dave Abrahams
|
||||
suggested numerous improvements during the Formal Review. Jeremy Siek was the review manager. Dave Abrahams edited this documentation.
|
||||
Beman Dawes was a great help in both final testing and merging library with rest of the boost.
|
||||
Gennadiy Rozental is the developer and maintainer.
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
<hr>
|
||||
<p>© Beman Dawes, <a href="mailto:boost_test_library@consultant.com">Gennadiy Rozental</a> 2001</p>
|
||||
<p>© Beman Dawes 2000, <script language="Javascript">contact_addess()</script>
|
||||
<script language="Javascript">get_copyright_date()</script>
|
||||
</p>
|
||||
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED"
|
||||
S-Format="%d %B, %Y" startspan -->12 August, 2002<!--webbot bot="Timestamp" endspan i-checksum="34409" -->
|
||||
S-Format="%d %B, %Y" startspan -->09 August, 2002<!--webbot bot="Timestamp" endspan i-CheckSum="34422" -->
|
||||
</p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
54
doc/js-lib/array_ex.js
Normal file
@ -0,0 +1,54 @@
|
||||
if( !Array.prototype.push ) {
|
||||
Array.prototype.push = function( new_el ) {
|
||||
this[this.length] = new_el;
|
||||
|
||||
return this.length;
|
||||
};
|
||||
}
|
||||
|
||||
if( !Array.prototype.pop ) {
|
||||
Array.prototype.pop = function() {
|
||||
if( this.length > 0 ) {
|
||||
var last_element = this[this.length-1];
|
||||
this.length = this.length-1;
|
||||
|
||||
return last_element;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
if( !Array.prototype.indexOf ) {
|
||||
Array.prototype.indexOf = function( el ) {
|
||||
for( var index = 0; index < this.length; ++index ) {
|
||||
if( this[index] == el )
|
||||
return index;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if( !Array.prototype.contains ) {
|
||||
Array.prototype.contains = function( el ) {
|
||||
return this.indexOf( el ) != -1;
|
||||
};
|
||||
|
||||
if( !Array.prototype.remove ) {
|
||||
Array.prototype.remove = function( el ) {
|
||||
var index = this.indexOf( el );
|
||||
|
||||
if( index > -1 ) {
|
||||
for( var index2 = index+1; index2 < this.length; index2++ ) {
|
||||
this[index2-1] = this[index2];
|
||||
}
|
||||
|
||||
this.pop();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
// EOF
|
7
doc/js-lib/browser.js
Normal file
@ -0,0 +1,7 @@
|
||||
// Determine browser.
|
||||
|
||||
var ns4 = document.layers;
|
||||
var ie = document.all && navigator.userAgent.indexOf("Opera")==-1;
|
||||
var dom = document.getElementById&&!ie&&navigator.userAgent.indexOf("Opera")==-1;
|
||||
|
||||
// EOF
|
39
doc/js-lib/callback_api.js
Normal file
@ -0,0 +1,39 @@
|
||||
function Callback( func, target_obj ) {
|
||||
this.func = func;
|
||||
this.target_obj = target_obj;
|
||||
this.args = new Array();
|
||||
this.add_args( arguments, 2 );
|
||||
}
|
||||
|
||||
Callback.prototype.toString = function() {
|
||||
var res = this.target_obj ? 'object.' : '';
|
||||
res += funcname( this.func ) + '( ';
|
||||
for( var i=0; i < this.args.length; i++ )
|
||||
res += this.args[i];
|
||||
res += '... )';
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Callback.prototype.add_args = function( args_array, first_arg_index ) {
|
||||
var index = first_arg_index ? first_arg_index : 0;
|
||||
for( ; index < args_array.length; index++ )
|
||||
this.args.push( args_array[index] );
|
||||
}
|
||||
|
||||
Callback.prototype.run = function() {
|
||||
if( arguments.length > 0 ) {
|
||||
var args_list = new Array();
|
||||
for( var i = 0; i < this.args.length; i++ )
|
||||
args_list.push( this.args[i] );
|
||||
|
||||
for( var i = 0; i < arguments.length; i++ )
|
||||
args_list.push( arguments[i] );
|
||||
}
|
||||
else
|
||||
var args_list = this.args;
|
||||
|
||||
return this.func.apply( this.target_obj, args_list );
|
||||
}
|
||||
|
||||
// EOF
|
80
doc/js-lib/core.js
Normal file
@ -0,0 +1,80 @@
|
||||
function include( file, path ) {
|
||||
document.write( '<script language="javascript" src="' );
|
||||
if( path )
|
||||
document.write( path + '/' );
|
||||
document.write( file + '" > </script>' );
|
||||
}
|
||||
|
||||
// ************************************************************************** //
|
||||
|
||||
function normalize_int( v ) {
|
||||
var r = parseInt( v );
|
||||
return isNaN( r ) ? 0 : r;
|
||||
}
|
||||
|
||||
// ************************************************************************** //
|
||||
|
||||
Object.prototype.is_a = function( type ) {
|
||||
return this.constructor == type;
|
||||
}
|
||||
|
||||
// ************************************************************************** //
|
||||
|
||||
function funcname( f ) {
|
||||
var s = f.toString().match( /function (\w*)/ )[1];
|
||||
|
||||
return (!s || s.length == 0) ? "anonymous" : s;
|
||||
}
|
||||
|
||||
// ************************************************************************** //
|
||||
|
||||
include ( 'browser.js', viso_path );
|
||||
include ( 'array_ex.js', viso_path );
|
||||
|
||||
// ************************************************************************** //
|
||||
|
||||
function normalize_integer_value( v ) {
|
||||
if( v === undefined )
|
||||
return 0 ;
|
||||
|
||||
if( v === null )
|
||||
return v;
|
||||
|
||||
return parseInt(v) || 0;
|
||||
}
|
||||
|
||||
Pair = function ( x, y ) {
|
||||
this.x = normalize_integer_value( x );
|
||||
this.y = normalize_integer_value( y );
|
||||
}
|
||||
|
||||
Pair.prototype.add = function( the_shift ) {
|
||||
return new Pair(
|
||||
this.x + parseInt( the_shift.x ),
|
||||
this.y + parseInt( the_shift.y ) );
|
||||
}
|
||||
|
||||
Pair.prototype.toString = function() {
|
||||
return '('+this.x+','+this.y+')';
|
||||
}
|
||||
|
||||
// ************************************************************************** //
|
||||
|
||||
function Quadruple( x1, x2, x3, x4 ) {
|
||||
this.x1 = normalize_integer_value( x1 );
|
||||
this.x2 = normalize_integer_value( x2 );
|
||||
this.x3 = normalize_integer_value( x3 );
|
||||
this.x4 = normalize_integer_value( x4 );
|
||||
}
|
||||
|
||||
Quadruple.prototype.add = function( the_shift ) {
|
||||
return new Quadruple(
|
||||
this.x1 + parseInt( the_shift.x1 ),
|
||||
this.x2 + parseInt( the_shift.x2 ),
|
||||
this.x3 + parseInt( the_shift.x3 ),
|
||||
this.x4 + parseInt( the_shift.x4 ) );
|
||||
}
|
||||
|
||||
// ************************************************************************** //
|
||||
|
||||
// EOF
|
18
doc/js-lib/examples/core_example.html
Normal file
@ -0,0 +1,18 @@
|
||||
<html>
|
||||
<head>
|
||||
<script language="javascript">var viso_path=".."</script>
|
||||
<script language="javascript" src="../core.js" > </script>
|
||||
</head>
|
||||
<body>
|
||||
<script language="javascript">
|
||||
var f = include;
|
||||
alert( include );
|
||||
alert( funcname( f ) );
|
||||
alert( Array.prototype.push );
|
||||
alert( funcname(Array.prototype.push) );
|
||||
var p = new Pair;
|
||||
alert( p );
|
||||
alert( p.is_a( Pair ) );
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
46
doc/js-lib/examples/scheduler_api_example.html
Normal file
@ -0,0 +1,46 @@
|
||||
<html>
|
||||
<head>
|
||||
<script language="javascript">var viso_path=".."</script>
|
||||
<script language="javascript" src="../core.js" > </script>
|
||||
<script language="javascript">
|
||||
include ( "scheduler_api.js", viso_path );
|
||||
</script>
|
||||
<script>
|
||||
|
||||
test_func0.index = 0
|
||||
function test_func0() {
|
||||
alert( test_func0.index++ );
|
||||
|
||||
if( test_func0.index >= 10 ) {
|
||||
test_func0.index = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function call_back() {
|
||||
alert( "call_back" );
|
||||
}
|
||||
|
||||
test_func1.index = 0
|
||||
function test_func1( step ) {
|
||||
alert( test_func1.index );
|
||||
test_func1.index += step;
|
||||
|
||||
if( test_func1.index >= 10 ) {
|
||||
test_func1.index = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TaskScheduler.schedule( new Callback( test_func0 ) );
|
||||
TaskScheduler.schedule( new Callback( test_func1, null, 2 ), 100, false, new Callback( call_back ) );
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
53
doc/js-lib/examples/smooth_move_example.html
Normal file
@ -0,0 +1,53 @@
|
||||
<html>
|
||||
<head>
|
||||
<script language="javascript">var viso_path=".."</script>
|
||||
<script language="javascript" src="../core.js" > </script>
|
||||
<script language="javascript">
|
||||
include ( "vis_object_api.js", viso_path );
|
||||
|
||||
function hmove() {
|
||||
viso_smooth_move( viso_get( "idMove" ), 10,
|
||||
function( counter ) {
|
||||
return (counter < 160) ? new Pair( counter*4, 0 ) : null;
|
||||
} );
|
||||
}
|
||||
|
||||
function vmove() {
|
||||
viso_smooth_move( viso_get( "idMove" ), 10,
|
||||
function( counter ) {
|
||||
return (counter < 80) ? new Pair( 0, counter*5 ) : null;
|
||||
} );
|
||||
}
|
||||
|
||||
function hvmove() {
|
||||
viso_smooth_move( viso_get( "idMove" ), 10,
|
||||
function( counter ) {
|
||||
return (counter < 80) ? new Pair( counter*5, counter*counter/15 ) : null;
|
||||
} );
|
||||
}
|
||||
|
||||
function algmove() {
|
||||
viso_smooth_move( viso_get( "idMove" ), 10,
|
||||
new Function( "counter", viso_get( "alg" ).value ) );
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<span id="idMove" style="position:relative"/>To be moved</span>
|
||||
</div>
|
||||
<div style="position: absolute; bottom: 0px; width: 100%; height: 100px;">
|
||||
<input type="button" value="Restore" onClick="viso_move_to( viso_get( 'idMove' ), new Pair(0,0) );"><br>
|
||||
<input type="button" value="HMove" onClick="hmove();">
|
||||
<input type="button" value="VMove" onClick="vmove();">
|
||||
<input type="button" value="HVMove" onClick="hvmove();"><br>
|
||||
function( counter ) { <br>
|
||||
<textarea id="alg" cols="80" rows="5"></textarea><br>
|
||||
}<br>
|
||||
<input type="button" value="Move using this algorithm" onClick="algmove();"><br>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
85
doc/js-lib/examples/smooth_scroll_example.html
Normal file
@ -0,0 +1,85 @@
|
||||
<html>
|
||||
<head>
|
||||
<script language="javascript">var viso_path=".."</script>
|
||||
<script language="javascript" src="../core.js" > </script>
|
||||
<script language="javascript">
|
||||
include ( "vis_object_api.js", viso_path );
|
||||
</script>
|
||||
<script language="javascript">
|
||||
function lscroll() {
|
||||
viso_smooth_scroll( viso_get( "idMove" ), 10,
|
||||
function( counter ) {
|
||||
return new Pair( counter*5, 0 );
|
||||
} );
|
||||
}
|
||||
|
||||
function rscroll() {
|
||||
viso_smooth_scroll( viso_get( "idMove" ), 10,
|
||||
function( counter ) {
|
||||
return new Pair( -counter*5, 0 );
|
||||
} );
|
||||
}
|
||||
|
||||
function tscroll() {
|
||||
viso_smooth_scroll( viso_get( "idMove" ), 10,
|
||||
function( counter ) {
|
||||
return new Pair( 0, counter*5 );
|
||||
} );
|
||||
}
|
||||
|
||||
function bscroll() {
|
||||
viso_smooth_scroll( viso_get( "idMove" ), 10,
|
||||
function( counter ) {
|
||||
return new Pair( 0, -counter*5 );
|
||||
} );
|
||||
}
|
||||
|
||||
function algscroll() {
|
||||
viso_smooth_scroll( viso_get( "idMove" ), 10,
|
||||
function( counter ) {
|
||||
return new Pair( counter*5, counter*5 );
|
||||
} );
|
||||
}
|
||||
|
||||
function update_parameters()
|
||||
{
|
||||
viso_set_html( viso_get("par_clip_left") , viso_get_clip_area( viso_get( "idMove" ) ).x1 );
|
||||
viso_set_html( viso_get("par_clip_right") , viso_get_clip_area( viso_get( "idMove" ) ).x3 );
|
||||
viso_set_html( viso_get("par_clip_top") , viso_get_clip_area( viso_get( "idMove" ) ).x2 );
|
||||
viso_set_html( viso_get("par_clip_bottom") , viso_get_clip_area( viso_get( "idMove" ) ).x4 );
|
||||
viso_set_html( viso_get("par_clip_width") , viso_get_clip_width( viso_get( "idMove" ) ) );
|
||||
viso_set_html( viso_get("par_clip_height") , viso_get_clip_height( viso_get( "idMove" ) ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TaskScheduler.schedule( new Callback( update_parameters ), 100 );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
Clip left: <span id="par_clip_left"></span>
|
||||
Clip Right: <span id="par_clip_right"></span>
|
||||
Clip top: <span id="par_clip_top"></span>
|
||||
Clip Bottom: <span id="par_clip_bottom"></span>
|
||||
Clip Width: <span id="par_clip_width"></span>
|
||||
Clip Height: <span id="par_clip_height"></span>
|
||||
<br><br><br>
|
||||
|
||||
<div id="idMove" style="border: 2 solid; width:300; height:100; position:absolute; left:300; top:200; clip: rect(0,200,50,0)">
|
||||
<table border="1" >
|
||||
<tr><td>To be moved</td></tr></table>
|
||||
</div>
|
||||
<div style="position: absolute; bottom: 0px; width: 100%; height: 100px;">
|
||||
<input type="button" value="Scroll Left" onClick="lscroll();">
|
||||
<input type="button" value="Scroll Right" onClick="rscroll();"<br>
|
||||
<br>
|
||||
<input type="button" value="Scroll Top" onClick="tscroll();">
|
||||
<input type="button" value="Scroll Bottom" onClick="bscroll();"<br>
|
||||
<br>
|
||||
<input type="button" value="Scroll Alg" onClick="algscroll();">
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
83
doc/js-lib/examples/transitions_example.html
Normal file
@ -0,0 +1,83 @@
|
||||
<html>
|
||||
<head>
|
||||
<script language="javascript">var viso_path=".."</script>
|
||||
<script language="javascript" src="../core.js" > </script>
|
||||
<script language="javascript">
|
||||
include ( "transitions.js", viso_path );
|
||||
|
||||
var from_obj, to_obj;
|
||||
|
||||
function apply_transition() {
|
||||
var selector = viso_get("id_selector");
|
||||
var transition_id = selector.options[selector.selectedIndex].value;
|
||||
|
||||
viso_make_transition( from_obj, to_obj, transition_id, 10, new Callback( switch_objs ),
|
||||
viso_get("x_step_size").value,
|
||||
viso_get("y_step_size").value );
|
||||
}
|
||||
|
||||
function init() {
|
||||
from_obj = viso_get( 'div1' );
|
||||
to_obj = viso_get( 'div2' );
|
||||
|
||||
viso_set_height( viso_get("holder"), viso_get_height( from_obj ) );
|
||||
viso_set_width( viso_get("holder"), viso_get_width( from_obj ) );
|
||||
}
|
||||
|
||||
function switch_objs() {
|
||||
var tmp = to_obj;
|
||||
to_obj = from_obj;
|
||||
from_obj = tmp;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body onLoad="init();" style="padding:2em">
|
||||
<div>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<div id="holder" >
|
||||
<span id="div1" style="position:absolute; background: white">
|
||||
<nobr><font size=5>Original text</font></nobr>
|
||||
</span>
|
||||
<span id="div2" style="display:none; position:absolute; background: white">
|
||||
<nobr><font size=7>Another longer text</font></nobr>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td width="40%">
|
||||
Side text
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Some other text
|
||||
</div>
|
||||
<div style="position: absolute; bottom: 0px; width: 100%; height: 100px;">
|
||||
X step size: <input type="text" value="10" id="x_step_size">
|
||||
Y step size: <input type="text" value="10" id="y_step_size">
|
||||
Transition:
|
||||
<select Name="id_selector" onchange="apply_transition();">
|
||||
<option Value="wipe-right"> wipe-right
|
||||
<option Value="wipe-left"> wipe-left
|
||||
<option Value="wipe-up"> wipe-up
|
||||
<option Value="wipe-down"> wipe-down
|
||||
<option Value="box-in"> box-in
|
||||
<option Value="box-out"> box-out
|
||||
<option Value="box-in-out"> box-in-out
|
||||
<option Value="split-in-vert"> split-in-vert
|
||||
<option Value="split-out-vert"> split-out-vert
|
||||
<option Value="split-in-out-vert"> split-in-out-vert
|
||||
<option Value="split-in-hor"> split-in-hor
|
||||
<option Value="split-out-hor"> split-out-hor
|
||||
<option Value="split-in-out-hor"> split-in-out-hor
|
||||
</select>
|
||||
<br>
|
||||
<input type="button" value="Apply" onClick="apply_transition();">
|
||||
<br><br>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
151
doc/js-lib/examples/vis_object_api_example.html
Normal file
@ -0,0 +1,151 @@
|
||||
<html>
|
||||
<head>
|
||||
<script language="javascript">var viso_path=".."</script>
|
||||
<script language="javascript" src="../core.js" > </script>
|
||||
<script language="javascript">
|
||||
include ( "vis_object_api.js", viso_path );
|
||||
|
||||
function target_id()
|
||||
{
|
||||
var selector = viso_get("id_selector");
|
||||
return selector.options[selector.selectedIndex].value;
|
||||
}
|
||||
|
||||
function wrap_parameter( value )
|
||||
{
|
||||
return '<font color="rbg(200,50,75)">' + value + '</font>'
|
||||
}
|
||||
|
||||
function update_parameters()
|
||||
{
|
||||
viso_set_html( viso_get("par_left") , wrap_parameter( viso_get_left( viso_get( target_id() ) ) ) );
|
||||
viso_set_html( viso_get("par_right") , wrap_parameter( viso_get_right( viso_get( target_id() ) ) ) );
|
||||
viso_set_html( viso_get("par_top") , wrap_parameter( viso_get_top( viso_get( target_id() ) ) ) );
|
||||
viso_set_html( viso_get("par_bottom") , wrap_parameter( viso_get_bottom( viso_get( target_id() ) ) ) );
|
||||
viso_set_html( viso_get("par_width") , wrap_parameter( viso_get_width( viso_get( target_id() ) ) ) );
|
||||
viso_set_html( viso_get("par_height") , wrap_parameter( viso_get_height( viso_get( target_id() ) ) ) );
|
||||
|
||||
viso_set_html( viso_get("par_clip_left") , wrap_parameter( viso_get_clip_area( viso_get( target_id() ) ).x1 ) );
|
||||
viso_set_html( viso_get("par_clip_right") , wrap_parameter( viso_get_clip_area( viso_get( target_id() ) ).x3 ) );
|
||||
viso_set_html( viso_get("par_clip_top") , wrap_parameter( viso_get_clip_area( viso_get( target_id() ) ).x2 ) );
|
||||
viso_set_html( viso_get("par_clip_bottom") , wrap_parameter( viso_get_clip_area( viso_get( target_id() ) ).x4 ) );
|
||||
viso_set_html( viso_get("par_clip_width") , wrap_parameter( viso_get_clip_width( viso_get( target_id() ) ) ) );
|
||||
viso_set_html( viso_get("par_clip_height") , wrap_parameter( viso_get_clip_height( viso_get( target_id() ) ) ) );
|
||||
|
||||
viso_set_html( viso_get("par_page_left") , wrap_parameter( viso_get_page_left( viso_get( target_id() ) ) ) );
|
||||
viso_set_html( viso_get("par_page_top") , wrap_parameter( viso_get_page_top( viso_get( target_id() ) ) ) );
|
||||
viso_set_html( viso_get("par_zindex") , wrap_parameter( viso_get_zindex( viso_get( target_id() ) ) ) );
|
||||
|
||||
viso_set_html( viso_get("par_visibility") , wrap_parameter( '"'+ viso_get_visibility( viso_get( target_id() ) ) + '"' ) );
|
||||
viso_set_html( viso_get("par_is_visible") , wrap_parameter( viso_is_visible( viso_get( target_id() ) ) ) );
|
||||
viso_set_html( viso_get("par_is_displayed"), wrap_parameter( viso_is_displayed( viso_get( target_id() ) ) ) );
|
||||
// viso_set_html( viso_get("par_id") , wrap_parameter( viso_get_id( viso_get( target_id() ) ) ) );
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body onLoad="update_parameters();">
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td width="30%" align="top">
|
||||
|
||||
<form>
|
||||
Select object:
|
||||
<select id="id_selector" onchange="update_parameters();">
|
||||
<OPTION Value="idIMG"> Image
|
||||
<OPTION Value="idTBL"> Table
|
||||
<OPTION Value="idTXT"> Text
|
||||
</select>
|
||||
|
||||
</form>
|
||||
</td>
|
||||
<td width="70%" style="color:rgb(40,10,230)">
|
||||
|
||||
Left: <span id="par_left"></span>
|
||||
Right: <span id="par_right"></span>
|
||||
Top: <span id="par_top"></span>
|
||||
Bottom: <span id="par_bottom"></span>
|
||||
Width: <span id="par_width"></span>
|
||||
Height: <span id="par_height"></span>
|
||||
<br><br>
|
||||
Clip left: <span id="par_clip_left"></span>
|
||||
Clip Right: <span id="par_clip_right"></span>
|
||||
Clip top: <span id="par_clip_top"></span>
|
||||
Clip Bottom: <span id="par_clip_bottom"></span>
|
||||
Clip Width: <span id="par_clip_width"></span>
|
||||
Clip Height: <span id="par_clip_height"></span>
|
||||
<br><br>
|
||||
Page left: <span id="par_page_left"></span>
|
||||
Page top: <span id="par_page_top"></span>
|
||||
Z Index: <span id="par_zindex"></span>
|
||||
<br><br>
|
||||
Visibility: <span id="par_visibility"></span>
|
||||
Is visible: <span id="par_is_visible"></span>
|
||||
Is displayed: <span id="par_is_displayed"></span><br>
|
||||
<br>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<table width="100%" id="body-table">
|
||||
<tr>
|
||||
<td width="60%" style="padding: 20" >
|
||||
|
||||
<img src="../../imgs/c++boost_bw.gif" id="idIMG" style="position:relative; left:0; top:0; clip: rect(30,50,100,10)"/><br>
|
||||
|
||||
<table border="1" id="idTBL" style="position:relative; left:0; top:0; visibility:visible;">
|
||||
<tr>
|
||||
<td width="70" height="50">
|
||||
Hello!
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p id="idTXT" style="position:absolute; left:30; top:500;clip: rect(0,200,40,0)">THIS IS TEXT</p>
|
||||
|
||||
</td>
|
||||
|
||||
<td width="40%" style="border-left: 1 solid; padding: 20">
|
||||
<form>
|
||||
<input type="button" value="Hide" onClick="viso_hide( viso_get( target_id() ) );update_parameters();">
|
||||
<input type="button" value="Show" onClick="viso_show( viso_get( target_id() ) );update_parameters();"><br>
|
||||
<input type="button" value="Remove" onClick="viso_remove( viso_get( target_id() ) );update_parameters();">
|
||||
<input type="button" value="Display" onClick="viso_display( viso_get( target_id() ) );update_parameters();"><br>
|
||||
<input type="text" id="moveX" value="0">
|
||||
<input type="text" id="moveY" value="0">
|
||||
<input type="button" value="Move"
|
||||
onClick="viso_move_to( viso_get( target_id() ), new Pair( viso_get('moveX').value, viso_get('moveY').value ) ); update_parameters();"><br>
|
||||
<input type="text" id="shiftX" value="0">
|
||||
<input type="text" id="shiftY" value="0">
|
||||
<input type="button" value="Shift"
|
||||
onClick="viso_move_by( viso_get( target_id() ), new Pair( viso_get( 'shiftX' ).value,viso_get('shiftY').value ) ); update_parameters();"><br>
|
||||
Left: <input type="text" id="setX" value="0">
|
||||
<input type="button" value="Set"
|
||||
onClick="viso_set_left( viso_get( target_id() ),viso_get( 'setX' ).value ); update_parameters();"><br>
|
||||
Top: <input type="text" id="setY" value="0">
|
||||
<input type="button" value="Set"
|
||||
onClick="viso_set_top( viso_get( target_id() ),viso_get( 'setY' ).value ); update_parameters();"><br>
|
||||
zIndex: <input type="text" id="setzIndex" value="0">
|
||||
<input type="button" value="Set"
|
||||
onClick="viso_set_zindex( viso_get( target_id() ),viso_get( 'setzIndex' ).value ); update_parameters();"><br>
|
||||
<input type="text" id="scrollByX" value="0">
|
||||
<input type="text" id="scrollByY" value="0">
|
||||
<input type="button" value="Scroll by"
|
||||
onClick="viso_scroll_by( viso_get( target_id() ),viso_get('scrollByX').value,viso_get('scrollByY').value ); update_parameters();"><br>
|
||||
|
||||
Content: <input type="text" id="content" value="">
|
||||
<input type="button" value="Set"
|
||||
onClick="viso_set_html( viso_get( target_id() ), viso_get( 'content' ).value ); update_parameters();"><br>
|
||||
|
||||
</form>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
87
doc/js-lib/examples/vis_object_api_example_2.html
Normal file
@ -0,0 +1,87 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<script language="javascript">var viso_path=".."</script>
|
||||
<script language="javascript" src="../core.js" > </script>
|
||||
<script language="javascript">
|
||||
include ( "vis_object_api.js", viso_path );
|
||||
|
||||
function mmove_handler( e ) {
|
||||
viso_get( "screen_x" ).innerHTML = e.screenX;
|
||||
viso_get( "screen_y" ).innerHTML = e.screenY;
|
||||
viso_get( "offset_x" ).innerHTML = viso_event_offset_x( e );
|
||||
viso_get( "offset_y" ).innerHTML = viso_event_offset_x( e );
|
||||
}
|
||||
|
||||
function page_init() {
|
||||
viso_add_event_handler( "onmousemove", mmove_handler );
|
||||
|
||||
viso_get( "div1_x" ).innerHTML = viso_get_left( viso_get( "div1" ) );
|
||||
viso_get( "div1_y" ).innerHTML = viso_get_top( viso_get( "div1" ) );
|
||||
viso_get( "div1_page_x" ).innerHTML = viso_get_page_left( viso_get( "div1" ) );
|
||||
viso_get( "div1_page_y" ).innerHTML = viso_get_page_top( viso_get( "div1" ) );
|
||||
viso_get( "div1_parent" ).innerHTML = viso_get_parent( viso_get( "div1" ) ).id;
|
||||
viso_get( "div1_offset_parent" ).innerHTML = viso_get( "div1" ).offsetParent.id;
|
||||
|
||||
viso_get( "div2_x" ).innerHTML = viso_get_left( viso_get( "div2" ) );
|
||||
viso_get( "div2_y" ).innerHTML = viso_get_top( viso_get( "div2" ) );
|
||||
viso_get( "div2_page_x" ).innerHTML = viso_get_page_left( viso_get( "div2" ) );
|
||||
viso_get( "div2_page_y" ).innerHTML = viso_get_page_top( viso_get( "div2" ) );
|
||||
viso_get( "div2_parent" ).innerHTML = viso_get_parent( viso_get( "div2" ) ).id;
|
||||
viso_get( "div2_offset_parent" ).innerHTML = viso_get( "div2" ).offsetParent.id;
|
||||
|
||||
viso_get( "div3_x" ).innerHTML = viso_get_left( viso_get( "div3" ) );
|
||||
viso_get( "div3_y" ).innerHTML = viso_get_top( viso_get( "div3" ) );
|
||||
viso_get( "div3_page_x" ).innerHTML = viso_get_page_left( viso_get( "div3" ) );
|
||||
viso_get( "div3_page_y" ).innerHTML = viso_get_page_top( viso_get( "div3" ) );
|
||||
viso_get( "div3_parent" ).innerHTML = viso_get_parent( viso_get( "div2" ) ).id;
|
||||
viso_get( "div3_offset_parent" ).innerHTML = viso_get( "div2" ).offsetParent.id;
|
||||
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
|
||||
DIV {
|
||||
border-width:2px;
|
||||
border-style:solid;
|
||||
padding: 5;
|
||||
} </style>
|
||||
</head>
|
||||
|
||||
<body id="BODY" onLoad="page_init();">
|
||||
<div id="div1" >
|
||||
DIV1:<br>
|
||||
Left: <span id="div1_x"></span>
|
||||
Top: <span id="div1_y"></span>
|
||||
Page Left: <span id="div1_page_x"></span>
|
||||
Page Top: <span id="div1_page_y"></span>
|
||||
Parent: <span id="div1_parent"></span>
|
||||
OffParent: <span id="div1_offset_parent"></span>
|
||||
<div id="div2">
|
||||
DIV2:<br>
|
||||
Left: <span id="div2_x"></span>
|
||||
Top: <span id="div2_y"></span>
|
||||
Page Left: <span id="div2_page_x"></span>
|
||||
Page Top: <span id="div2_page_y"></span>
|
||||
Parent: <span id="div2_parent"></span>
|
||||
OffParent: <span id="div2_offset_parent"></span>
|
||||
<div id="div3">
|
||||
DIV3:<br>
|
||||
Left: <span id="div3_x"></span>
|
||||
Top: <span id="div3_y"></span>
|
||||
Page Left: <span id="div3_page_x"></span>
|
||||
Page Top: <span id="div3_page_y"></span>
|
||||
Parent: <span id="div3_parent"></span>
|
||||
OffParent: <span id="div3_offset_parent"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer" style="position: absolute; bottom: 0px; width: 90%; height: 100px;">
|
||||
Screen X: <span id="screen_x"></span>
|
||||
Screen Y: <span id="screen_y"></span><br>
|
||||
Offset X: <span id="offset_x"></span>
|
||||
Offset Y: <span id="offset_y"></span>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
98
doc/js-lib/examples/wipe_away_menu_example.html
Normal file
@ -0,0 +1,98 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<script language="javascript">var viso_path=".."</script>
|
||||
<script language="javascript" src="../core.js" > </script>
|
||||
<script language="javascript">
|
||||
include ( "wipe_away_menu.js", viso_path );
|
||||
|
||||
function mmove_handler() {
|
||||
screen_x.innerText = event.screenX;
|
||||
screen_y.innerText = event.screenY;
|
||||
offset_x.innerText = event.offsetX;
|
||||
offset_y.innerText = event.offsetY;
|
||||
client_x.innerText = event.clientX;
|
||||
client_y.innerText = event.clientY;
|
||||
}
|
||||
|
||||
var menu1, menu2, menu3, menu4;
|
||||
|
||||
function page_init() {
|
||||
menu1 = new WipeAwayMenu( "menu1", "menu_root", true, "left",
|
||||
{ tran:"box-out", speed:10, x_step:20 },
|
||||
{ tran:"box-in", speed:10, x_step:20 } );
|
||||
menu2 = new WipeAwayMenu( "menu2", "menu_root", true, "right",
|
||||
{ tran:"split-out-hor", speed:10, y_step:3 },
|
||||
{ tran:"split-in-hor", speed:10, y_step:3 } );
|
||||
menu3 = new WipeAwayMenu( "menu3", "menu_root", true, "top",
|
||||
{ tran:"split-out-vert", speed:10, x_step:7 },
|
||||
{ tran:"split-in-vert", speed:10, x_step:7 } );
|
||||
menu4 = new WipeAwayMenu( "menu4", "menu_root", true, "down" );
|
||||
}
|
||||
|
||||
function show_menus() {
|
||||
menu1.show();
|
||||
menu2.show();
|
||||
menu3.show();
|
||||
menu4.show();
|
||||
}
|
||||
|
||||
function close_menus() {
|
||||
menu1.hide();
|
||||
menu2.hide();
|
||||
menu3.hide();
|
||||
menu4.hide();
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
.menu
|
||||
{
|
||||
font-weight: bold;
|
||||
font-family: Arial;
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body id="BODY" onLoad="page_init();" onMouseMove="mmove_handler()">
|
||||
|
||||
<div id="centerer" align="center" >
|
||||
|
||||
<div id="menu_holder">
|
||||
|
||||
<div id="menu1" class="menu" style="position: absolute;">
|
||||
<nobr><font size=8>Link1 Link2 Link3 </font></nobr>
|
||||
</div>
|
||||
|
||||
<div id="menu2" class="menu">
|
||||
<nobr><font size=3>Link4 Link5 Link5 </font></nobr>
|
||||
</div>
|
||||
|
||||
<div id="menu3" class="menu">
|
||||
<font size=8>Link1<br>Link2<br>Link3</font>
|
||||
</div>
|
||||
|
||||
<div id="menu4" class="menu">
|
||||
<font size=3>Link4<br>Link5<br>Link6</font>
|
||||
</div>
|
||||
|
||||
|
||||
<span id="menu_root" style="position:relative; top:350">
|
||||
<a href="javascript:void close_menus();"><span onMouseOver="show_menus();"><font size=6>Menu</font></span></a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div style="position: absolute; bottom: 0px; width: 100%; height: 100px;">
|
||||
<hr>
|
||||
Screen X: <span id="screen_x"></span>
|
||||
Screen Y: <span id="screen_y"></span><br>
|
||||
Offset X: <span id="offset_x"></span>
|
||||
Offset Y: <span id="offset_y"></span>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
47
doc/js-lib/scheduler_api.js
Normal file
@ -0,0 +1,47 @@
|
||||
include ( 'callback_api.js', viso_path );
|
||||
|
||||
function ScheduledTaskInfo( func, once, finish_callback_func ) {
|
||||
this.func = func;
|
||||
this.tid = null;
|
||||
this.once = once ? true : false;
|
||||
this.counter = 0;
|
||||
this.cb = finish_callback_func;
|
||||
}
|
||||
|
||||
function Scheduler() {
|
||||
this.uniq_task_id = 0;
|
||||
this.tasks_info = new Array();
|
||||
}
|
||||
|
||||
TaskScheduler = new Scheduler();
|
||||
|
||||
Scheduler.prototype.schedule = function( func, timeout, once, end_callback ) {
|
||||
var task_id = "task" + this.uniq_task_id++;
|
||||
var task_info = new ScheduledTaskInfo( func, once, end_callback );
|
||||
|
||||
task_info.tid = setInterval( 'TaskScheduler.run("' + task_id + '")', timeout );
|
||||
|
||||
this.tasks_info[task_id] = task_info;
|
||||
|
||||
return task_id;
|
||||
}
|
||||
|
||||
Scheduler.prototype.cancel_task = function( task_id ) {
|
||||
var task_info = this.tasks_info[task_id];
|
||||
|
||||
clearInterval( task_info.tid );
|
||||
|
||||
if( task_info.cb )
|
||||
task_info.cb.run();
|
||||
|
||||
delete this.tasks_info[task_id];
|
||||
}
|
||||
|
||||
Scheduler.prototype.run = function( task_id ) {
|
||||
var task_info = this.tasks_info[task_id];
|
||||
|
||||
if( !task_info.func.run( task_info.counter++ ) || task_info.once )
|
||||
this.cancel_task( task_id );
|
||||
}
|
||||
|
||||
// EOF
|
221
doc/js-lib/transitions.js
Normal file
@ -0,0 +1,221 @@
|
||||
include ( 'callback_api.js', viso_path );
|
||||
include ( 'scheduler_api.js', viso_path );
|
||||
include ( 'vis_object_api.js', viso_path );
|
||||
|
||||
function viso_make_transition( from_vis_obj, to_vis_obj, transition, speed,
|
||||
callback, x_step_size, y_step_size,
|
||||
dont_align_parent ) {
|
||||
var dcl_from = new Quadruple;
|
||||
var dcl_to = new Quadruple;
|
||||
var total_steps;
|
||||
|
||||
x_step_size = x_step_size ? x_step_size : 10;
|
||||
x_step_size = Math.max( x_step_size, 2 );
|
||||
|
||||
y_step_size = y_step_size ? y_step_size : 2;
|
||||
y_step_size = Math.max( y_step_size, 2 );
|
||||
|
||||
viso_clip( to_vis_obj, new Quadruple );
|
||||
|
||||
viso_display( to_vis_obj );
|
||||
|
||||
var from_sizes = from_vis_obj ? viso_get_sizes( from_vis_obj ) : new Pair();
|
||||
var to_sizes = to_vis_obj ? viso_get_sizes( to_vis_obj ) : new Pair();
|
||||
|
||||
var x_work_size = Math.max( from_sizes.x, to_sizes.x );
|
||||
var y_work_size = Math.max( from_sizes.y, to_sizes.y );
|
||||
|
||||
viso_clip( from_vis_obj,
|
||||
new Quadruple( 0, 0, x_work_size, y_work_size ) );
|
||||
|
||||
switch( transition ) {
|
||||
case "wipe-right":
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( 0, 0, 0, y_work_size ) );
|
||||
dcl_from.x1 = x_step_size;
|
||||
dcl_to.x3 = x_step_size;
|
||||
total_steps = x_work_size / x_step_size;
|
||||
break;
|
||||
case "wipe-left":
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( x_work_size, 0, x_work_size, y_work_size ) );
|
||||
dcl_from.x3 = -x_step_size;
|
||||
dcl_to.x1 = -x_step_size;
|
||||
total_steps = x_work_size / x_step_size;
|
||||
break;
|
||||
case "wipe-down":
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( 0, 0, x_work_size, 0 ) );
|
||||
dcl_from.x2 = y_step_size;
|
||||
dcl_to.x4 = y_step_size;
|
||||
total_steps = y_work_size / y_step_size;
|
||||
break;
|
||||
case "wipe-up":
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( 0, y_work_size, x_work_size, y_work_size ) );
|
||||
dcl_from.x4 = -y_step_size;
|
||||
dcl_to.x2 = -y_step_size;
|
||||
total_steps = y_work_size / y_step_size;
|
||||
break;
|
||||
case "split-in-vert":
|
||||
viso_set_zindex( from_vis_obj, 1 );
|
||||
viso_set_zindex( to_vis_obj, 0 );
|
||||
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( 0, 0, x_work_size, y_work_size ) );
|
||||
dcl_from.x1 = Math.ceil( x_step_size/2 );
|
||||
dcl_from.x3 = -Math.ceil( x_step_size/2 );
|
||||
total_steps = x_work_size/x_step_size;
|
||||
break;
|
||||
case "split-out-vert":
|
||||
viso_set_zindex( from_vis_obj, 0 );
|
||||
viso_set_zindex( to_vis_obj, 1 );
|
||||
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( x_work_size/2, 0, x_work_size/2, y_work_size ) );
|
||||
dcl_to.x1 = -Math.ceil( x_step_size/2 );
|
||||
dcl_to.x3 = Math.ceil( x_step_size/2 );
|
||||
total_steps = x_work_size/x_step_size;
|
||||
break;
|
||||
case "split-in-out-vert":
|
||||
viso_set_zindex( from_vis_obj, 0 );
|
||||
viso_set_zindex( to_vis_obj, 1 );
|
||||
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( x_work_size/2, 0, x_work_size/2, y_work_size ) );
|
||||
dcl_from.x1 = Math.ceil( x_step_size/2 );
|
||||
dcl_from.x3 = -Math.ceil( x_step_size/2 );
|
||||
dcl_to.x1 = -Math.ceil( x_step_size/2 );
|
||||
dcl_to.x3 = Math.ceil( x_step_size/2 );
|
||||
total_steps = x_work_size/x_step_size;
|
||||
break;
|
||||
case "split-in-hor":
|
||||
viso_set_zindex( from_vis_obj, 1 );
|
||||
viso_set_zindex( to_vis_obj, 0 );
|
||||
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( 0, 0, x_work_size, y_work_size ) );
|
||||
dcl_from.x2 = Math.ceil( y_step_size/2 );
|
||||
dcl_from.x4 = -Math.ceil( y_step_size/2 );
|
||||
total_steps = y_work_size/y_step_size;
|
||||
break;
|
||||
case "split-out-hor":
|
||||
viso_set_zindex( from_vis_obj, 0 );
|
||||
viso_set_zindex( to_vis_obj, 1 );
|
||||
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( 0, y_work_size/2, x_work_size, y_work_size/2 ) );
|
||||
dcl_to.x2 = -Math.ceil( y_step_size/2 );
|
||||
dcl_to.x4 = Math.ceil( y_step_size/2 );
|
||||
total_steps = y_work_size/y_step_size;
|
||||
break;
|
||||
case "split-in-out-hor":
|
||||
viso_set_zindex( from_vis_obj, 0 );
|
||||
viso_set_zindex( to_vis_obj, 1 );
|
||||
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( 0, y_work_size/2, x_work_size, y_work_size/2 ) );
|
||||
dcl_from.x2 = Math.ceil( y_step_size/2 );
|
||||
dcl_from.x4 = -Math.ceil( y_step_size/2 );
|
||||
dcl_to.x2 = -Math.ceil( y_step_size/2 );
|
||||
dcl_to.x4 = Math.ceil( y_step_size/2 );
|
||||
total_steps = y_work_size/y_step_size;
|
||||
break;
|
||||
case "box-in":
|
||||
viso_set_zindex( from_vis_obj, 1 );
|
||||
viso_set_zindex( to_vis_obj, 0 );
|
||||
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( 0, 0, x_work_size, y_work_size ) );
|
||||
total_steps = Math.max( x_work_size/x_step_size, y_work_size/y_step_size );
|
||||
x_step_size = Math.ceil( x_work_size/(2*total_steps) );
|
||||
y_step_size = Math.ceil( y_work_size/(2*total_steps) );
|
||||
dcl_from.x1 = x_step_size;
|
||||
dcl_from.x2 = y_step_size;
|
||||
dcl_from.x3 = -x_step_size;
|
||||
dcl_from.x4 = -y_step_size;
|
||||
break;
|
||||
case "box-out":
|
||||
viso_set_zindex( from_vis_obj, 0 );
|
||||
viso_set_zindex( to_vis_obj, 1 );
|
||||
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( x_work_size/2, y_work_size/2, x_work_size/2, y_work_size/2 ) );
|
||||
total_steps = Math.max( x_work_size/x_step_size, y_work_size/y_step_size );
|
||||
x_step_size = Math.ceil( x_work_size/(2*total_steps) );
|
||||
y_step_size = Math.ceil( y_work_size/(2*total_steps) );
|
||||
dcl_to.x1 = -x_step_size;
|
||||
dcl_to.x2 = -y_step_size;
|
||||
dcl_to.x3 = x_step_size;
|
||||
dcl_to.x4 = y_step_size;
|
||||
break;
|
||||
case "box-in-out":
|
||||
viso_set_zindex( from_vis_obj, 0 );
|
||||
viso_set_zindex( to_vis_obj, 1 );
|
||||
|
||||
viso_clip( to_vis_obj,
|
||||
new Quadruple( x_work_size/2, y_work_size/2, x_work_size/2, y_work_size/2 ) );
|
||||
total_steps = Math.max( x_work_size/x_step_size, y_work_size/y_step_size );
|
||||
x_step_size = Math.ceil( x_work_size/(2*total_steps) );
|
||||
y_step_size = Math.ceil( y_work_size/(2*total_steps) );
|
||||
dcl_from.x1 = x_step_size;
|
||||
dcl_from.x2 = y_step_size;
|
||||
dcl_from.x3 = -x_step_size;
|
||||
dcl_from.x4 = -y_step_size;
|
||||
dcl_to.x1 = -x_step_size;
|
||||
dcl_to.x2 = -y_step_size;
|
||||
dcl_to.x3 = x_step_size;
|
||||
dcl_to.x4 = y_step_size;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if( !dont_align_parent && to_vis_obj ) {
|
||||
var parent = viso_get_parent( to_vis_obj );
|
||||
var parent_sizes = viso_get_sizes( parent );
|
||||
|
||||
if( parent_sizes.y < to_sizes.y ) {
|
||||
viso_set_height( parent, to_sizes.y );
|
||||
}
|
||||
|
||||
if( parent_sizes.x < to_sizes.x ) {
|
||||
viso_set_width( parent, to_sizes.x );
|
||||
}
|
||||
}
|
||||
|
||||
callback = callback ? callback : null;
|
||||
var bound_work_func = new Callback( viso_do_transition, null,
|
||||
from_vis_obj, to_vis_obj,
|
||||
dcl_from, dcl_to,
|
||||
total_steps, dont_align_parent );
|
||||
return TaskScheduler.schedule( bound_work_func, speed, false, callback );
|
||||
}
|
||||
|
||||
function viso_do_transition( from_vis_obj, to_vis_obj,
|
||||
dcl_from, dcl_to, total_steps,
|
||||
dont_align_parent, counter ) {
|
||||
viso_change_clip_by( from_vis_obj, dcl_from );
|
||||
viso_change_clip_by( to_vis_obj, dcl_to );
|
||||
|
||||
if( counter < total_steps )
|
||||
return true;
|
||||
|
||||
viso_remove( from_vis_obj );
|
||||
|
||||
if( !dont_align_parent && to_vis_obj ) {
|
||||
var parent = viso_get_parent( to_vis_obj );
|
||||
var parent_sizes = viso_get_sizes( parent );
|
||||
var to_sizes = viso_get_sizes( to_vis_obj );
|
||||
|
||||
if( parent_sizes.y > to_sizes.y ) {
|
||||
viso_set_height( parent, to_sizes.y );
|
||||
}
|
||||
if( parent_sizes.x > to_sizes.x ) {
|
||||
viso_set_width( parent, to_sizes.x );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// EOF
|
39
doc/js-lib/vis_obj_loop_roller.js
Normal file
@ -0,0 +1,39 @@
|
||||
include ( 'vis_object_api.js', viso_path );
|
||||
include ( 'transitions.js', viso_path );
|
||||
|
||||
function VisObjLoopRoller( transition_id ) {
|
||||
this.curr_index = 0;
|
||||
this.objs = new Array();
|
||||
this.transition_id = transition_id;
|
||||
var objs_ids_start = 1;
|
||||
|
||||
if( transition_id ) {
|
||||
this.speed = arguments[1];
|
||||
this.step = arguments[2];
|
||||
objs_ids_start = 3;
|
||||
}
|
||||
|
||||
for( var i = objs_ids_start; i < arguments.length; i++ ) {
|
||||
var obj = viso_get( arguments[i] );
|
||||
this.objs[i-objs_ids_start] = viso_get( arguments[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VisObjLoopRoller.prototype.roll = function() {
|
||||
var from_obj = this.objs[this.curr_index++];
|
||||
|
||||
this.curr_index %= this.objs.length;
|
||||
var to_obj = this.objs[this.curr_index];
|
||||
|
||||
if( !this.transition_id ) {
|
||||
var was_displayed = viso_is_displayed( from_obj );
|
||||
viso_set_displayed( from_obj, viso_is_displayed( to_obj ) );
|
||||
viso_set_displayed( to_obj, was_displayed );
|
||||
}
|
||||
else {
|
||||
viso_make_transition( from_obj, to_obj, this.transition_id, this.speed, null, this.step );
|
||||
}
|
||||
}
|
||||
|
||||
// EOF
|
659
doc/js-lib/vis_object_api.js
Normal file
@ -0,0 +1,659 @@
|
||||
include ( 'callback_api.js', viso_path );
|
||||
include ( 'scheduler_api.js', viso_path );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// object utilities.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function viso_get( vis_obj_id ) {
|
||||
if( ns4 )
|
||||
return viso_find( vis_obj_id, document );
|
||||
if( ie )
|
||||
return eval( 'document.all.' + vis_obj_id );
|
||||
if( dom )
|
||||
return document.getElementById( vis_obj_id );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function viso_find( vis_obj_id, doc ) {
|
||||
for( var i = 0; i < doc.objs.length; i++ ) {
|
||||
var vis_obj = doc.objs[i];
|
||||
|
||||
if( vis_obj.name == vis_obj_id )
|
||||
return vis_obj;
|
||||
|
||||
if( vis_obj.document.objs.length > 0 ) {
|
||||
vis_obj = viso_find( vis_obj_id, vis_obj.document );
|
||||
if( vis_obj != null )
|
||||
return vis_obj;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function viso_get_parent( vis_obj ) {
|
||||
if( ns4 )
|
||||
alert( "to be impl")
|
||||
else if (ie)
|
||||
return vis_obj.parentElement;
|
||||
else if (dom)
|
||||
return vis_obj.parentNode;
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
function viso_get_id( vis_obj ) {
|
||||
if( ns4 )
|
||||
return vis_obj.name;
|
||||
if( ie || dom )
|
||||
return vis_obj.id;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// object style
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function viso_get_style(vis_obj) {
|
||||
if( ns4 )
|
||||
return vis_obj;
|
||||
else if( ie || dom )
|
||||
return vis_obj.style;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// object content
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function viso_set_html( vis_obj, html ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
html = (html != null && html != undefined) ? html : '';
|
||||
|
||||
if( ns4 ) {
|
||||
vis_obj.document.open();
|
||||
vis_obj.document.write(html);
|
||||
vis_obj.document.close();
|
||||
|
||||
for( var i=0; i<vis_obj.document.images.length; i++ )
|
||||
vis_obj.document.images[i].lyrobj=vis_obj;
|
||||
|
||||
for( var i=0; i<vis_obj.document.links.length; i++ )
|
||||
vis_obj.document.links[i].lyrobj=vis_obj;
|
||||
|
||||
} else if( ie ) {
|
||||
vis_obj.innerHTML = html;
|
||||
|
||||
var images = vis_obj.all.tags( "img" );
|
||||
for( var i=0;i<images.length; i++ )
|
||||
images[i].lyrobj=vis_obj;
|
||||
|
||||
} else if( dom ) {
|
||||
while( vis_obj.hasChildNodes() )
|
||||
vis_obj.removeChild( vis_obj.firstChild );
|
||||
|
||||
var r = vis_obj.ownerDocument.createRange();
|
||||
r.selectNodeContents( vis_obj );
|
||||
r.collapse( true );
|
||||
|
||||
var df = r.createContextualFragment( html );
|
||||
vis_obj.appendChild( df );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// object display.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function viso_remove( vis_obj ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
viso_get_style( vis_obj ).display = "none";
|
||||
}
|
||||
|
||||
function viso_display( vis_obj ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
viso_get_style( vis_obj ).display = "";
|
||||
}
|
||||
|
||||
function viso_set_displayed( vis_obj, on_off ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
if( on_off )
|
||||
viso_display( vis_obj );
|
||||
else
|
||||
viso_remove( vis_obj )
|
||||
}
|
||||
|
||||
function viso_is_displayed( vis_obj ) {
|
||||
return viso_get_style( vis_obj ).display != "none";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// object visibility.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function viso_hide( vis_obj ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
if( ns4 )
|
||||
vis_obj.visibility = "hide";
|
||||
else if( ie || dom )
|
||||
vis_obj.style.visibility = "hidden";
|
||||
}
|
||||
|
||||
function viso_show( vis_obj ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
if( ns4 )
|
||||
vis_obj.visibility = "show";
|
||||
else if( ie || dom )
|
||||
vis_obj.style.visibility = "visible";
|
||||
}
|
||||
|
||||
function viso_inherit_visibility( vis_obj ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
viso_get_style( vis_obj ).visibility = "inherit";
|
||||
}
|
||||
|
||||
function viso_get_visibility( vis_obj ) {
|
||||
if( ns4 ) {
|
||||
if( vis_obj.visibility == "show" )
|
||||
return "visible";
|
||||
if( vis_obj.visibility == "hide" )
|
||||
return "hidden";
|
||||
return vis_obj.visibility;
|
||||
}
|
||||
|
||||
if( ie || dom )
|
||||
return vis_obj.style.visibility;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function viso_is_visible( vis_obj ) {
|
||||
return viso_get_visibility( vis_obj ) != "hidden";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// object size and positioning.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function viso_get_left( vis_obj ) {
|
||||
return normalize_int( viso_get_style( vis_obj ).left );
|
||||
}
|
||||
|
||||
function viso_set_left( vis_obj, x ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
viso_move_to( vis_obj, new Pair( x, null ) );
|
||||
}
|
||||
|
||||
function shift_left_by( vis_obj, dx ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
viso_move_by( vis_obj, new Pair( dx, 0 ) );
|
||||
}
|
||||
|
||||
function viso_get_top( vis_obj ) {
|
||||
return normalize_int( viso_get_style( vis_obj ).top );
|
||||
}
|
||||
|
||||
function viso_set_top( vis_obj, y ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
viso_move_to( vis_obj, new Pair( null, y ) );
|
||||
}
|
||||
|
||||
function shift_top_by( vis_obj, dy ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
viso_move_by( vis_obj, new Pair( 0, dy ) );
|
||||
}
|
||||
|
||||
function viso_get_right( vis_obj ) {
|
||||
return viso_get_left( vis_obj ) + viso_get_width( vis_obj );
|
||||
}
|
||||
|
||||
function viso_get_bottom( vis_obj ) {
|
||||
return viso_get_top( vis_obj ) + viso_get_height( vis_obj );
|
||||
}
|
||||
|
||||
function viso_get_width( vis_obj ) {
|
||||
if( ns4 ) {
|
||||
if( vis_obj.document.width )
|
||||
return normalize_int( vis_obj.document.width );
|
||||
else
|
||||
return normalize_int( vis_obj.clip.right ) - normalize_int( vis_obj.clip.left );
|
||||
}
|
||||
if( ie || dom ) {
|
||||
if( vis_obj.style.width )
|
||||
return normalize_int( vis_obj.style.width );
|
||||
else
|
||||
return normalize_int( vis_obj.offsetWidth );
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function viso_set_width( vis_obj, w ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
if( ns4 ) {
|
||||
vis_obj.document.width = normalize_int( w );
|
||||
}
|
||||
if( ie || dom ) {
|
||||
vis_obj.style.width = normalize_int( w );
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function viso_insure_width( vis_obj, w ) {
|
||||
if( viso_get_width( vis_obj ) < w )
|
||||
viso_set_width( vis_obj, w );
|
||||
}
|
||||
|
||||
function viso_get_height( vis_obj ) {
|
||||
if( ns4 ) {
|
||||
if( vis_obj.document.height )
|
||||
return normalize_int( vis_obj.document.height );
|
||||
else
|
||||
return normalize_int( vis_obj.clip.bottom ) - normalize_int( vis_obj.clip.top );
|
||||
}
|
||||
if( ie || dom ) {
|
||||
if( vis_obj.style.height )
|
||||
return normalize_int( vis_obj.style.height );
|
||||
else
|
||||
return normalize_int( vis_obj.offsetHeight );
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function viso_set_height( vis_obj, h ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
if( ns4 ) {
|
||||
vis_obj.document.height = normalize_int( h );
|
||||
}
|
||||
if( ie || dom ) {
|
||||
vis_obj.style.height = normalize_int( h );
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function viso_insure_height( vis_obj, h ) {
|
||||
if( viso_get_height( vis_obj ) < h )
|
||||
viso_set_height( vis_obj, h );
|
||||
}
|
||||
|
||||
function viso_get_sizes( vis_obj ) {
|
||||
return new Pair( viso_get_width( vis_obj ), viso_get_height( vis_obj ) );
|
||||
}
|
||||
|
||||
function viso_get_zindex( vis_obj ) {
|
||||
return normalize_int( viso_get_style( vis_obj ).zIndex );
|
||||
}
|
||||
|
||||
function viso_set_zindex( vis_obj, z ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
viso_get_style( vis_obj ).zIndex = z;
|
||||
}
|
||||
|
||||
function viso_get_position( vis_obj ) {
|
||||
return new Pair( viso_get_left( vis_obj ), viso_get_top( vis_obj ) );
|
||||
}
|
||||
|
||||
function viso_move_to( vis_obj, new_pos ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
if( new_pos.x == null ) new_pos.x = viso_get_left( vis_obj );
|
||||
if( new_pos.y == null ) new_pos.y = viso_get_top( vis_obj );
|
||||
|
||||
if( ns4 )
|
||||
vis_obj.moveTo( normalize_int( new_pos.x ), normalize_int( new_pos.y ) );
|
||||
else if( ie || dom ) {
|
||||
vis_obj.style.left = normalize_int( new_pos.x );
|
||||
vis_obj.style.top = normalize_int( new_pos.y );
|
||||
}
|
||||
}
|
||||
|
||||
function viso_move_by( vis_obj, shift ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
if( ns4 )
|
||||
vis_obj.moveBy( normalize_int( shift.x ), normalize_int( shift.y ) );
|
||||
else if( ie || dom ) {
|
||||
vis_obj.style.left = normalize_int( vis_obj.style.left )+normalize_int( shift.x );
|
||||
vis_obj.style.top = normalize_int( vis_obj.style.top ) +normalize_int( shift.y );
|
||||
}
|
||||
}
|
||||
|
||||
function viso_smooth_move( vis_obj, speed, algorithm ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
var bound_work_func = new Callback( viso_do_smooth_move, null,
|
||||
vis_obj, algorithm,
|
||||
viso_get_position( vis_obj ) );
|
||||
TaskScheduler.schedule( bound_work_func, speed );
|
||||
}
|
||||
|
||||
function viso_do_smooth_move( vis_obj, algorithm, orig_position, counter ) {
|
||||
var shift = algorithm( counter );
|
||||
|
||||
if( shift == null )
|
||||
return false;
|
||||
|
||||
viso_move_to( vis_obj, orig_position.add( shift ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function viso_get_page_left( vis_obj ) {
|
||||
if( ns4 )
|
||||
return normalize_int( vis_obj.pageX );
|
||||
if( ie || dom ) {
|
||||
var x = 0;
|
||||
while ( vis_obj.offsetParent != null ) {
|
||||
x += normalize_int( vis_obj.offsetLeft );
|
||||
vis_obj = vis_obj.offsetParent;
|
||||
}
|
||||
x += normalize_int( vis_obj.offsetLeft );
|
||||
return x;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function viso_get_page_top( vis_obj ) {
|
||||
if( ns4 )
|
||||
return normalize_int( vis_obj.pageY );
|
||||
if( ie || dom ) {
|
||||
var y = 0;
|
||||
while ( vis_obj.offsetParent != null ) {
|
||||
y += normalize_int( vis_obj.offsetTop );
|
||||
vis_obj = vis_obj.offsetParent;
|
||||
}
|
||||
y += normalize_int( vis_obj.offsetTop );
|
||||
return y;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function viso_get_page_position( vis_obj ) {
|
||||
return new Pair( viso_get_page_left( vis_obj ), viso_get_page_top( vis_obj ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// object clipping.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function viso_get_clip_area( vis_obj ) {
|
||||
if( ns4 )
|
||||
return new Quadruple( vis_obj.clip.left,
|
||||
vis_obj.clip.top,
|
||||
vis_obj.clip.right,
|
||||
vis_obj.clip.bottom );
|
||||
if( ie || dom ) {
|
||||
var res = new Quadruple;
|
||||
var str = vis_obj.style.clip;
|
||||
if( str ) {
|
||||
var i;
|
||||
i = str.indexOf( "(" );
|
||||
res.x2 = normalize_int( str.substring( i + 1, str.length ), 10 );
|
||||
i = str.indexOf( " ", i + 1 );
|
||||
res.x3 = normalize_int( str.substring( i + 1, str.length ), 10 );
|
||||
i = str.indexOf( " ", i + 1 );
|
||||
res.x4 = normalize_int( str.substring( i + 1, str.length ), 10 );
|
||||
i = str.indexOf( " ", i + 1 );
|
||||
res.x1 = normalize_int( str.substring( i + 1, str.length ), 10 );
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function viso_clip( vis_obj, clip_area ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
if( ns4 ) {
|
||||
vis_obj.clip.left = clip_area.x1;
|
||||
vis_obj.clip.top = clip_area.x2;
|
||||
vis_obj.clip.right = clip_area.x3;
|
||||
vis_obj.clip.bottom = clip_area.x4;
|
||||
}
|
||||
else if( ie || dom )
|
||||
vis_obj.style.clip = 'rect( ' + clip_area.x2 + ' '
|
||||
+ clip_area.x3 + ' '
|
||||
+ clip_area.x4 + ' '
|
||||
+ clip_area.x1 + ' )';
|
||||
}
|
||||
|
||||
function viso_change_clip_by( vis_obj, clip_diff ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
var clip_area = viso_get_clip_area( vis_obj );
|
||||
|
||||
viso_clip( vis_obj, clip_area.add( clip_diff ) );
|
||||
}
|
||||
|
||||
function viso_get_clip_width( vis_obj ) {
|
||||
if( ns4 )
|
||||
return normalize_int( vis_obj.clip.width );
|
||||
if( ie || dom ) {
|
||||
if( !vis_obj.style.clip )
|
||||
return normalize_int( vis_obj.style.width );
|
||||
var clip_area = viso_get_clip_area( vis_obj );
|
||||
|
||||
return clip_area.x3 - clip_area.x1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function viso_get_clip_height( vis_obj ) {
|
||||
if( ns4 )
|
||||
return normalize_int( vis_obj.clip.height );
|
||||
if( ie || dom ) {
|
||||
if( !vis_obj.style.clip )
|
||||
return normalize_int( vis_obj.style.height );
|
||||
var clip_area = viso_get_clip_area( vis_obj );
|
||||
|
||||
return clip_area.x4 - clip_area.x2;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// object scrolling.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function viso_scroll_to( vis_obj, x, y, bound ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
var clip_area = viso_get_clip_area( vis_obj );
|
||||
var dx = x - clip_area.x1;
|
||||
var dy = y - clip_area.x2;
|
||||
|
||||
return viso_scroll_by( vis_obj, dx, dy, bound );
|
||||
}
|
||||
|
||||
function viso_scroll_by( vis_obj, dx, dy, bound ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
dx = normalize_int( dx );
|
||||
dy = normalize_int( dy );
|
||||
|
||||
if( dx == 0 && dy == 0 )
|
||||
return true;
|
||||
|
||||
var clip_area = viso_get_clip_area( vis_obj );
|
||||
if( bound ) {
|
||||
var sizes = viso_get_sizes( vis_obj );
|
||||
|
||||
dx = Math.max( dx, -clip_area.x1 );
|
||||
dx = Math.min( dx, sizes.x - clip_area.x3 );
|
||||
|
||||
dy = Math.max( dy, -clip_area.x2 );
|
||||
dy = Math.min( dy, sizes.y - clip_area.x4 );
|
||||
|
||||
if( dx == 0 && dy == 0 )
|
||||
return false;
|
||||
}
|
||||
viso_clip( vis_obj, clip_area.add( new Quadruple( dx, dy, dx, dy ) ) );
|
||||
viso_move_by( vis_obj, new Pair( -dx, -dy ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function viso_smooth_scroll( vis_obj, speed, algorithm ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
var clip_area = viso_get_clip_area( vis_obj );
|
||||
|
||||
var bound_work_func = new Callback( viso_do_smooth_scroll, null,
|
||||
vis_obj, algorithm,
|
||||
new Pair( clip_area.x1, clip_area.x2 ) );
|
||||
TaskScheduler.schedule( bound_work_func, speed );
|
||||
}
|
||||
|
||||
function viso_do_smooth_scroll( vis_obj, algorithm, orig_position, counter ) {
|
||||
var shift = algorithm( counter );
|
||||
|
||||
var new_pos = orig_position.add( shift );
|
||||
|
||||
return viso_scroll_to( vis_obj, new_pos.x, new_pos.y, true );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// object background.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function viso_set_bg_color( vis_obj, color ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
if( ns4 )
|
||||
vis_obj.bgColor = color;
|
||||
else if( ie || dom )
|
||||
vis_obj.style.backgroundColor = color;
|
||||
}
|
||||
|
||||
function viso_set_bg_image( vis_obj, src ) {
|
||||
if( !vis_obj ) return;
|
||||
|
||||
if( ns4 )
|
||||
vis_obj.background.src = src;
|
||||
else if( ie || dom )
|
||||
vis_obj.style.backgroundImage = "url( " + src + " )";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// events.handling.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function viso_add_event_handler( event_id, handler, vis_obj, in_front ) {
|
||||
if( !handler.is_a( Callback ) )
|
||||
handler = new Callback( handler );
|
||||
|
||||
if( ie ) {
|
||||
vis_obj = vis_obj ? vis_obj : document.body;
|
||||
|
||||
var curr_handler = vis_obj[event_id];
|
||||
|
||||
if( !curr_handler ) {
|
||||
vis_obj[event_id] = function() {
|
||||
handler.run( window.event );
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( in_front ) {
|
||||
vis_obj[event_id] = function() {
|
||||
handler.run( window.event );
|
||||
curr_handler( window.event );
|
||||
};
|
||||
}
|
||||
else {
|
||||
vis_obj[event_id] = function() {
|
||||
curr_handler( window.event );
|
||||
handler.run( window.event );
|
||||
};
|
||||
}
|
||||
}
|
||||
else if( dom ) {
|
||||
vis_obj = vis_obj ? vis_obj : window;
|
||||
|
||||
var curr_handler = vis_obj[event_id];
|
||||
|
||||
if( !curr_handler ) {
|
||||
vis_obj[event_id] = function( e ) {
|
||||
handler.run( e );
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
if( in_front ) {
|
||||
vis_obj[event_id] = function( e ) {
|
||||
handler.run( e );
|
||||
curr_handler( e );
|
||||
};
|
||||
}
|
||||
else {
|
||||
vis_obj[event_id] = function() {
|
||||
curr_handler( e );
|
||||
handler.run( e );
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function viso_clean_event_handlers( event_id, vis_obj ) {
|
||||
if( !vis_obj )
|
||||
vis_obj = ie ? document.body : window;
|
||||
|
||||
delete vis_obj[event_id];
|
||||
}
|
||||
|
||||
function viso_event_offset_x( e ) {
|
||||
if( ie )
|
||||
return e.offsetX;
|
||||
if( dom )
|
||||
return e.layerX;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function viso_event_offset_y( e ) {
|
||||
if( ie )
|
||||
return e.offsetY;
|
||||
if( dom )
|
||||
return e.layerY;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function viso_event_target( e ) {
|
||||
if( ie )
|
||||
return e.srcElement;
|
||||
if( dom )
|
||||
return e.target;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function viso_event_to_target( e ) {
|
||||
if( ie )
|
||||
return e.toElement;
|
||||
if( dom )
|
||||
return e.relatedTarget;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// EOF
|
120
doc/js-lib/wipe_away_menu.js
Normal file
@ -0,0 +1,120 @@
|
||||
include ( 'vis_object_api.js', viso_path );
|
||||
include ( 'scheduler_api.js', viso_path );
|
||||
include ( 'transitions.js', viso_path );
|
||||
|
||||
function WipeAwayMenu( menu_id, menu_root_id, start_closed, direction, show_info, hide_info ) {
|
||||
this.menu_root = viso_get( menu_root_id );
|
||||
this.menu = viso_get( menu_id );
|
||||
this.menu_state = 1; // 0 - closing 1 - closed, 2 - opening, 3 - open
|
||||
this.trans_task_id = null;
|
||||
this.direction = direction ? direction : "right";
|
||||
this.start_closed = start_closed;
|
||||
this.menu_parent = viso_get_parent( this.menu );
|
||||
this.menu_size = viso_get_sizes( this.menu );
|
||||
|
||||
switch( this.direction ) {
|
||||
case "left":
|
||||
this.show_info = show_info ? show_info : { tran:"wipe-left", speed:10 };
|
||||
this.hide_info = hide_info ? hide_info : { tran:"wipe-right", speed:10 };
|
||||
break;
|
||||
case "right":
|
||||
this.show_info = show_info ? show_info : { tran:"wipe-right", speed:10 };
|
||||
this.hide_info = hide_info ? hide_info : { tran:"wipe-left", speed:10 };
|
||||
break;
|
||||
case "top":
|
||||
this.show_info = show_info ? show_info : { tran:"wipe-up", speed:10 };
|
||||
this.hide_info = hide_info ? hide_info : { tran:"wipe-down", speed:10 };
|
||||
break;
|
||||
case "down":
|
||||
this.show_info = show_info ? show_info : { tran:"wipe-down", speed:10 };
|
||||
this.hide_info = hide_info ? hide_info : { tran:"wipe-up", speed:10 };
|
||||
break;
|
||||
}
|
||||
|
||||
this.init();
|
||||
|
||||
viso_add_event_handler( "onresize", new Callback( WipeAwayMenu.prototype.init, this ) );
|
||||
viso_add_event_handler( "onscroll", new Callback( WipeAwayMenu.prototype.hide, this ) );
|
||||
}
|
||||
|
||||
WipeAwayMenu.prototype.init = function () {
|
||||
var root_pos = viso_get_page_position( this.menu_root );
|
||||
var root_size = viso_get_sizes( this.menu_root );
|
||||
|
||||
var parent_pos, menu_pos;
|
||||
|
||||
switch( this.direction ) {
|
||||
case "left":
|
||||
menu_pos = new Pair( root_pos.x - this.menu_size.x - 5,
|
||||
root_pos.y + (root_size.y-this.menu_size.y)/2 );
|
||||
parent_pos = new Pair( menu_pos.x,
|
||||
Math.min( root_pos.y,menu_pos.y ) );
|
||||
break;
|
||||
case "right":
|
||||
menu_pos = new Pair( root_pos.x + root_size.x + 5,
|
||||
root_pos.y + (root_size.y-this.menu_size.y)/2 );
|
||||
parent_pos = new Pair( root_pos.x,
|
||||
Math.min( root_pos.y,menu_pos.y ) );
|
||||
break;
|
||||
case "top":
|
||||
menu_pos = new Pair( root_pos.x + (root_size.x-this.menu_size.x)/2,
|
||||
root_pos.y - this.menu_size.y - 5 );
|
||||
parent_pos = new Pair( Math.min( root_pos.x,menu_pos.x ),
|
||||
menu_pos.y );
|
||||
break;
|
||||
case "down":
|
||||
menu_pos = new Pair( root_pos.x + (root_size.x-this.menu_size.x)/2,
|
||||
root_pos.y + root_size.y + 5 );
|
||||
parent_pos = new Pair( Math.min( root_pos.x,menu_pos.x ),
|
||||
root_pos.y );
|
||||
break;
|
||||
}
|
||||
if( !this.show_info.x_step )
|
||||
this.show_info.x_step = 0;
|
||||
|
||||
if( !this.show_info.y_step )
|
||||
this.show_info.y_step = 0;
|
||||
|
||||
if( viso_get_id( this.menu_parent ) == "wipe-away-menu-holder" ) {
|
||||
viso_move_to( this.menu_parent, parent_pos );
|
||||
viso_insure_width( this.menu_parent, this.menu_size.x + root_size.x + 5 );
|
||||
viso_insure_height( this.menu_parent, Math.max( this.menu_size.y, root_size.y ) );
|
||||
}
|
||||
|
||||
viso_move_to( this.menu, menu_pos );
|
||||
viso_set_displayed( this.menu, !this.start_closed );
|
||||
}
|
||||
|
||||
WipeAwayMenu.prototype._end_show = function() { this.menu_state = 3; }
|
||||
WipeAwayMenu.prototype._end_hide = function() { this.menu_state = 1; }
|
||||
|
||||
WipeAwayMenu.prototype.show = function () {
|
||||
if( this.menu_state > 1 )
|
||||
return;
|
||||
|
||||
if( this.menu_state == 0 )
|
||||
TaskScheduler.cancel_task( this.trans_task_id );
|
||||
|
||||
this.menu_state = 2;
|
||||
this.trans_task_id = viso_make_transition( null, this.menu,
|
||||
this.show_info.tran, this.show_info.speed,
|
||||
new Callback( WipeAwayMenu.prototype._end_show, this ),
|
||||
this.show_info.x_step, this.show_info.y_step, true );
|
||||
}
|
||||
|
||||
WipeAwayMenu.prototype.hide = function () {
|
||||
if( this.menu_state < 2 )
|
||||
return;
|
||||
|
||||
if( this.menu_state == 2 ) {
|
||||
TaskScheduler.cancel_task( this.trans_task_id );
|
||||
}
|
||||
|
||||
this.menu_state = 0;
|
||||
this.trans_task_id = viso_make_transition( this.menu, null,
|
||||
this.hide_info.tran, this.hide_info.speed,
|
||||
new Callback( WipeAwayMenu.prototype._end_hide, this ),
|
||||
this.show_info.x_step, this.show_info.y_step, true );
|
||||
}
|
||||
|
||||
// EOF
|
@ -1,116 +1,147 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Program Execution Monitor</title>
|
||||
<title>Output test Stream</title>
|
||||
<script language="javascript">var viso_path="js-lib"</script>
|
||||
<script language="javascript" src="js-lib/core.js" > </script>
|
||||
|
||||
<link id="screen_style" rel="stylesheet" type="text/css" href="style/btl.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="style/btl_print.css" media="print" />
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
||||
|
||||
<script language="JavaScript">
|
||||
include ( "btl.js" );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#808080" text="#000000" link="#336699" vlink="#3F7EBE" alink="#699BCD">
|
||||
<div align="center">
|
||||
<center>
|
||||
<table border="2" cellpadding="13" bordercolor="#CDCDCD" width="80%" id="AutoNumber1" cellspacing="3" style="border-collapse: collapse">
|
||||
<tr>
|
||||
<td width="100%" align="left" valign="top" bgcolor="#f0f0f0" border="0" >
|
||||
<body onload="btl_menu_init()">
|
||||
<div align="center">
|
||||
<table class="body-table" cellspacing="3" >
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<a name="TOP"><img border="0" src="../../../c++boost.gif" width="277" height="86"></a><br clear=left>
|
||||
<script language="Javascript">btl_header()</script>
|
||||
|
||||
<h1 align="center">Boost Test Library: output_test_stream tool</h1>
|
||||
</center>
|
||||
<h1>Boost Test Library: output_test_stream tool</h1>
|
||||
|
||||
<p align="left"><b>
|
||||
<p class="page-toc">
|
||||
<a href="#Introduction">Introduction</a><br>
|
||||
<a href="#Benifits">Benefits</a><br>
|
||||
<a href="#Specification">Specification<br></a>
|
||||
<a href="#Tests">Examples and Tests</a>
|
||||
</b></p>
|
||||
</p>
|
||||
|
||||
<h2><a name="Introduction">Introduction</a></h2>
|
||||
<p>The class <b>output_test_stream</b> is a simple tool for testing output
|
||||
operation with standard std::ostream facilities. The class <b>output_test_stream</b>
|
||||
comply to std::ostream interface so it can be used in place of any
|
||||
std::ostream argument. In addition it provide several methods to validate
|
||||
output content. Also it allows to match/save output content versus/into
|
||||
specified file. </p>
|
||||
|
||||
<p class="1-line-indented">The class <b>output_test_stream</b> is a simple tool for testing output
|
||||
operation with standard std::ostream facilities. The class output_test_stream
|
||||
comply to std::ostream interface so it can be used in place of any
|
||||
std::ostream argument. In addition it provide several methods to validate
|
||||
output content. Also it allows to match/save output content versus/into
|
||||
specified file. Working mode of the output_test_stream could
|
||||
be defined by framework parameter "<a href="unit_test_framework.htm#FrameworkParameters">Save
|
||||
pattern</a>"</p>
|
||||
|
||||
<h2><a name="Benifits">Benefits</a></h2>
|
||||
|
||||
<p>Simplified mechanism for checking correctness of output operations.<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p class="1-line-indented">Simplified mechanism for checking correctness of output operations.
|
||||
<script language="Javascript">put_ref_to_top()</script></p>
|
||||
|
||||
<h2><a name="Specification">Specification</a></h2>
|
||||
|
||||
<p><i>class</i> <b>output_test_stream</b> {<br>
|
||||
public:<br>
|
||||
<i>explicit</i> output_test_stream( <i>char const</i>*
|
||||
pattern_file = NULL, <i>bool</i> match_or_save = <i>true</i> );</p>
|
||||
<p> ~output_test_stream();</p>
|
||||
<p> <i>bool</i> is_empty( <i>bool</i>
|
||||
flush_stream = true );<br>
|
||||
<i>bool</i> check_length(
|
||||
std::size_t length, <i>bool</i> flush_stream = <i>true</i> );<br>
|
||||
<i>bool</i> is_equal( <i>char
|
||||
const</i>* arg, <i>bool</i> flush_stream = <i>true</i> );<br>
|
||||
<i>bool</i> is_equal( <i>char
|
||||
const</i>* arg, std::size_t n, bool flush_stream = true );</p>
|
||||
<p> <i>bool</i>
|
||||
match_pattern( <i>bool</i> flush_stream = <i>true</i> );</p>
|
||||
<p> <i>void</i> flush();<br>
|
||||
};</p>
|
||||
<p><i>explicit</i> <a name="output_test_stream constructor">output_test_stream</a>( <i>char const</i>*
|
||||
pattern_file = NULL, <i>bool</i> match_or_save = <i>true</i> );</p>
|
||||
<p>The class <b>output_test_stream</b> constructor accept pattern file
|
||||
<pre class="code"><span class="reserv-word">class</span> <b>output_test_stream</b> {
|
||||
<span class="reserv-word">pubic</span>:
|
||||
<span class="reserv-word">explicit</span> output_test_stream( <span class="cpp-type">char</span> <span class="reserv-word">const</span>* pattern_file = NULL,
|
||||
<span class="cpp-type">bool</span> match_or_save = <span class="reserv-word">true</span> );
|
||||
|
||||
~output_test_stream();
|
||||
|
||||
<span class="cpp-type">bool</span> is_empty( <span class="cpp-type">bool</span> flush_stream = <span class="reserv-word">true</span> );
|
||||
<span class="cpp-type">bool</span> check_length( std::size_t length, <span class="cpp-type">bool</span> flush_stream = <span class="reserv-word">true</span> );
|
||||
<span class="cpp-type">bool</span> is_equal( <span class="cpp-type">char</span> <span class="reserv-word">const</span>* arg, <span class="cpp-type">bool</span> flush_stream = <span class="reserv-word">true</span> );
|
||||
<span class="cpp-type">bool</span> is_equal( <span class="cpp-type">char</span> <span class="reserv-word">const</span>* arg, <span class="cpp-type">std::size_t</span> n,
|
||||
<span class="cpp-type">bool</span> flush_stream = <span class="reserv-word">true</span> );
|
||||
|
||||
<span class="cpp-type">bool</span> match_pattern( <span class="cpp-type">bool</span> flush_stream = <span class="reserv-word">true</span> );
|
||||
|
||||
<span class="cpp-type">void</span> flush();
|
||||
};
|
||||
</pre>
|
||||
|
||||
<p>explicit <b> <a name="output_test_stream constructor">output_test_stream</a></b>( char const*
|
||||
pattern_file = NULL, bool match_or_save = true );</p>
|
||||
|
||||
<p class="1-line-indented">The class output_test_stream constructor accept pattern file
|
||||
name and boolean switch match_or_save that are used by <a href="#match_pattern">match_pattern</a>
|
||||
facility. If they are not present you can still use other testing mechanisms.</p>
|
||||
<p><i>void</i> flush();</p>
|
||||
<p>The method <b>output_test_stream</b>::flush() is used to clean the
|
||||
content of the <b>output_test_stream</b> instance.</p>
|
||||
<p><i>bool</i> is_empty( <i>bool</i>
|
||||
flush_stream = true );</p>
|
||||
<p>The method <b>output_test_stream</b>::is_empty(...) is used to check
|
||||
that the content of the <b>output_test_stream</b> instance is empty. The
|
||||
flush_stream argument manage automatic call of the method <b>output_test_stream</b>::flush()
|
||||
|
||||
<p>void <b>flush</b>();</p>
|
||||
|
||||
<p class="1-line-indented">The method output_test_stream::flush() is used to clean the
|
||||
content of the output_test_stream instance.</p>
|
||||
|
||||
<p>bool <b>is_empty</b>( bool flush_stream = true );</p>
|
||||
|
||||
<p class="1-line-indented">The method output_test_stream::is_empty(...) is used to check
|
||||
that the content of the output_test_stream instance is empty. The
|
||||
flush_stream argument manage automatic call of the method output_test_stream::flush()
|
||||
after check is done.</p>
|
||||
<p> <i>bool</i> check_length(
|
||||
std::size_t length, <i>bool</i> flush_stream = <i>true</i> );</p>
|
||||
<p>The method <b>output_test_stream</b>::check_length(...) is used to
|
||||
check that the length of the content of the <b>output_test_stream</b>
|
||||
|
||||
<p> bool <b>check_length</b>( std::size_t length, bool flush_stream = true );</p>
|
||||
|
||||
<p class="1-line-indented">The method output_test_stream::check_length(...) is used to
|
||||
check that the length of the content of the output_test_stream
|
||||
instance is equal to supplied length value. The
|
||||
flush_stream argument manage automatic call of the method <b>output_test_stream</b>::flush()
|
||||
flush_stream argument manage automatic call of the method output_test_stream::flush()
|
||||
after check is done.</p>
|
||||
<p> <i>bool</i> is_equal( <i>char
|
||||
const</i>* arg, <i>bool</i> flush_stream = <i>true</i> );<br>
|
||||
<i>bool</i> is_equal( <i>char
|
||||
const</i>* arg, std::size_t n, bool flush_stream = true );</p>
|
||||
<p>The method <b>output_test_stream</b>::is_equal(...) is used to check
|
||||
that the content of the <b>output_test_stream</b> instance is equal to
|
||||
supplied character string. The first compare to zero-terminated
|
||||
|
||||
<p> bool <b>is_equal</b>( char const* arg, bool flush_stream = true );<br>
|
||||
bool <b>is_equal</b>( char const* arg, std::size_t n, bool flush_stream = true );</p>
|
||||
|
||||
<p class="1-line-indented">The method output_test_stream::is_equal(...) is used to check
|
||||
that the content of the output_test_stream instance is equal to
|
||||
supplied character string. The first compare to zero-terminated
|
||||
string. The second version allows to specify pattern string length. The
|
||||
flush_stream argument manage automatic call of the method <b>output_test_stream</b>::flush()
|
||||
flush_stream argument manage automatic call of the method output_test_stream::flush()
|
||||
after check is done.</p>
|
||||
<p><i>bool</i> <a name="match_pattern">match_pattern</a>( <i>bool</i> flush_stream = <i>true</i> );</p>
|
||||
<p>The method <b>output_test_stream</b>::match_pattern(...) is used to
|
||||
match the content of the <b>output_test_stream</b> instance versus the
|
||||
pattern file. The pattern file name is specified in the class <b>output_test_stream</b>
|
||||
|
||||
<p>bool <b><a name="match_pattern">match_pattern</a></b>( bool flush_stream = true );</p>
|
||||
|
||||
<p class="1-line-indented">The method output_test_stream::match_pattern(...) is used to
|
||||
match the content of the output_test_stream instance versus the
|
||||
pattern file. The pattern file name is specified in the class output_test_stream
|
||||
<a href="#output_test_stream constructor">constructor</a>. If second
|
||||
argument of the class <b>output_test_stream</b> <a href="#output_test_stream constructor">constructor</a>
|
||||
is false, then every call of the method <b>output_test_stream</b>::match_pattern(...)
|
||||
will cause the <b>output_test_stream</b> instance content to be <u>stored</u>
|
||||
at the end of the pattern file. The flush_stream argument manage
|
||||
automatic call of the method <b>output_test_stream</b>::flush()
|
||||
argument of the class output_test_stream <a href="#output_test_stream constructor">constructor</a>
|
||||
is false, then every call of the method output_test_stream::match_pattern(...)
|
||||
will cause the output_test_stream instance content to be <u>stored</u>
|
||||
at the end of the pattern file. The flush_stream argument manage
|
||||
automatic call of the method output_test_stream::flush()
|
||||
after check is done.</p>
|
||||
<h2><a name="Tests">Examlpes and Tests</a></h2>
|
||||
<p><a href="../test/output_test_stream_test.cpp">output_test_stream_test.cpp<br>
|
||||
</a><a href="../test/result_report_test.cpp">result_report_test.cpp<br>
|
||||
</a><a href="../test/test_tools_test.cpp">test_tools_test.cpp<br>
|
||||
</a><a href="../test/unit_test_test1.cpp">unit_test_test1.cpp</a><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
|
||||
<h2><a name="Tests">Examlpes and Tests</a></h2>
|
||||
|
||||
<p class="indented">
|
||||
<a href="../test/output_test_stream_test.cpp">output_test_stream_test.cpp</a><br>
|
||||
<a href="../test/result_report_test.cpp">result_report_test.cpp</a><br>
|
||||
<a href="../test/test_tools_test.cpp">test_tools_test.cpp</a><br>
|
||||
<a href="../test/unit_test_test1.cpp">unit_test_test1.cpp</a>
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
<hr>
|
||||
<p>© <a href="mailto:boost_test_library@consultant.com">Gennadiy Rozental</a> 2001</p>
|
||||
<p>© <script language="Javascript">contact_addess()</script>
|
||||
<script language="Javascript">get_copyright_date()</script>
|
||||
</p>
|
||||
|
||||
<p align="left">Revised:
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED"
|
||||
S-Format="%d %B, %Y" startspan -->25 December, 2001<!--webbot bot="Timestamp" endspan i-checksum="38513" -->
|
||||
S-Format="%d %B, %Y" startspan -->29 July, 2002<!--webbot bot="Timestamp" endspan i-checksum="21096" -->
|
||||
</p>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
@ -1,93 +1,112 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Program Execution Monitor</title>
|
||||
<script language="javascript">var viso_path="js-lib"</script>
|
||||
<script language="javascript" src="js-lib/core.js" > </script>
|
||||
|
||||
<link id="screen_style" rel="stylesheet" type="text/css" href="style/btl.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="style/btl_print.css" media="print" />
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
||||
|
||||
<script language="JavaScript">
|
||||
include ( "btl.js" );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#808080" text="#000000" link="#336699" vlink="#3F7EBE" alink="#699BCD">
|
||||
<div align="center">
|
||||
<center>
|
||||
<table border="2" cellpadding="13" bordercolor="#CDCDCD" width="80%" id="AutoNumber1" cellspacing="3" style="border-collapse: collapse">
|
||||
<tr>
|
||||
<td width="100%" align="left" valign="top" bgcolor="#f0f0f0" border="0" >
|
||||
<body onload="btl_menu_init()">
|
||||
<div align="center">
|
||||
<table class="body-table" cellspacing="3" >
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<a name="TOP"><img border="0" src="../../../c++boost.gif" width="277" height="86"></a><br clear=left>
|
||||
<script language="Javascript">btl_header()</script>
|
||||
|
||||
<h1 align="center">Boost Test Library: Program Execution Monitor</h1>
|
||||
<p><b><a href="#Introduction">Introduction</a><br>
|
||||
<h1>Boost Test Library: Program Execution Monitor</h1>
|
||||
|
||||
<p class="page-toc">
|
||||
<a href="#Introduction">Introduction</a><br>
|
||||
<a href="#Benefits">Benefits</a><br>
|
||||
<a href="#Specifications">Specifications</a><br>
|
||||
<a href="#MonitorCompilation">Compilation</a><br>
|
||||
<a href="#Example">Example Programs</a><br>
|
||||
<a href="#Rationale">Rationale</a><br>
|
||||
<a href="#Design">Design</a></b>
|
||||
<a href="#Design">Design</a>
|
||||
</p>
|
||||
|
||||
<h2><a name="Introduction">Introduction</a></h2>
|
||||
<p>The Boost Test Library's Program Execution Monitor provides a replacement <b>main()</b>
|
||||
|
||||
<p class="1-line-indented">The Boost Test Library's Program Execution Monitor provides a replacement <b>main()</b>
|
||||
function which calls a user-supplied <b>cpp_main()</b> function within a try
|
||||
block. The supplied <b>main()</b> then catches and reports
|
||||
exceptions, relieving users from messy error detection and reporting duties.</p>
|
||||
<p>For use with the Program Execution Monitor, the traditional Hello World
|
||||
program becomes:</p>
|
||||
<blockquote>
|
||||
<pre>#include <iostream>
|
||||
|
||||
<i>int</i> cpp_main( <i>int</i>, <i>char</i> *[] ) // note name
|
||||
<pre class="code">#<span class="reserv-word">include</span> <iostream>
|
||||
|
||||
<span class="cpp-type">int</span> cpp_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span> *[] ) <span class="comment">// note name</span>
|
||||
{
|
||||
std::cout << "Hello, world\n";
|
||||
<i>return</i> 0;
|
||||
}</pre>
|
||||
</blockquote>
|
||||
<p>It really is that simple - just change the name of your initial function from
|
||||
main to <b>cpp_main()</b>. Do make sure the argc and arcv parameters are specified
|
||||
std::cout << <span class="literal">"Hello, world\n"</span>;
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p class="1-line-indented">It really is that simple - just change the name of your initial function from
|
||||
main to <b>cpp_main()</b>. Do make sure the argc and arcv parameters are specified
|
||||
(although you don't have to name them if you don't use them). Now you can
|
||||
compile it and link with the Program Execution Monitor library.</p>
|
||||
<p>When the above program executes, the output will be:</p>
|
||||
<blockquote>
|
||||
<pre>Hello, world
|
||||
no errors detected</pre>
|
||||
</blockquote>
|
||||
<p>But what if some lower-level function had thrown a runtime_error with the
|
||||
message "big trouble"? Then the output would look something like
|
||||
<p class="1-line-indented">When the above program executes, the output will be:</p>
|
||||
<p class="test-output">
|
||||
Hello, world<br>
|
||||
no errors detected
|
||||
</p>
|
||||
<p class="1-line-indented">But what if some lower-level function had thrown a runtime_error with the
|
||||
message "big trouble"? Then the output would look something like
|
||||
this:</p>
|
||||
<blockquote>
|
||||
<pre>** exception: std::runtime_error: big trouble
|
||||
**** error return code 5
|
||||
********** errors detected; see <font COLOR="#000000">standard</font><font COLOR="#0000ff"> </font><font COLOR="#000000">output</font> for details ***********</pre>
|
||||
</blockquote>
|
||||
<p>And if a lower-level function had bubbled up a return code of 5, the output
|
||||
<p class="test-output">
|
||||
** exception: std::runtime_error: big trouble<br>
|
||||
**** error return code 5<br>
|
||||
********** errors detected; see standard output for details ***********
|
||||
</p>
|
||||
<p class="1-line-indented">And if a lower-level function had bubbled up a return code of 5, the output
|
||||
would look something like this:</p>
|
||||
<blockquote>
|
||||
<pre>**** error return code 5
|
||||
*********** errors detected; see <font COLOR="#000000">standard</font><font COLOR="#0000ff"> </font><font COLOR="#000000">output</font> for details ***********</pre>
|
||||
</blockquote>
|
||||
<p>Note that the primary messages appear on <font COLOR="#000000">standard</font><font COLOR="#0000ff">
|
||||
</font><font COLOR="#000000">output stream</font>, while the final message
|
||||
appears on <font COLOR="#000000">standard</font><font COLOR="#0000ff"> </font><font color="#000000">error
|
||||
stream</font>. This increases the visibility of error notification if
|
||||
standard output and error streams are directed to different devices or files.<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p class="test-output">
|
||||
**** error return code 5<br>
|
||||
*********** errors detected; see standard output for details ***********
|
||||
</p>
|
||||
<p class="1-line-indented">Note that the primary messages appear on standard output stream, while the final message
|
||||
appears on standard error stream. This increases the visibility of error notification if
|
||||
standard output and error streams are directed to different devices or files.
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<h2><a name="Benefits">Benefits</a></h2>
|
||||
<p>More uniform reporting of errors, particularly exceptions.</p>
|
||||
<p><b>In production programs:</b> </p>
|
||||
<p>More uniform error reporting is particularly useful for programs running
|
||||
|
||||
<p class="1-line-indented">More uniform reporting of errors, particularly exceptions.</p>
|
||||
<p><b>In production programs:</b></p>
|
||||
|
||||
<p class="1-line-indented">More uniform error reporting is particularly useful for programs running
|
||||
unattended under control of scripts or batch files. Some operating systems pop
|
||||
up message boxes if an uncaught exception occurs, and this requires operator
|
||||
intervention. By converting such exceptions to non-zero program return codes,
|
||||
the library makes the program a better citizen.</p>
|
||||
<p>More uniform reporting of errors isn't a benefit to some programs,
|
||||
|
||||
<p class="1-line-indented">More uniform reporting of errors isn't a benefit to some programs,
|
||||
particularly programs always run by hand by a knowledgeable person. So <b>
|
||||
cpp_main()</b>
|
||||
wouldn't be worth using in that environment.</p>
|
||||
cpp_main()</b> wouldn't be worth using in that environment.</p>
|
||||
<p><b>In test programs:</b></p>
|
||||
<p>More uniform error reporting could be useful in test environments such as the boost
|
||||
<p class="1-line-indented">More uniform error reporting could be useful in test environments such as the boost
|
||||
regression tests. But in this case it is preferable to use the <a href="test_exec_framework.htm">Test Execution Monitor</a>
|
||||
or <a href="unit_test_framework.htm">Unit Test Framework</a>, cause they allows
|
||||
you to use Test Tools and generate more detailed error information.</p>
|
||||
|
||||
<h2><a name="Specifications">Specifications</a> of the supplied main()</h2>
|
||||
<p>Uniformly detects and reports the occurrence of several types of errors,
|
||||
<h2><a name="Specifications">Specifications</a> of the supplied main()</h2>
|
||||
|
||||
<p class="1-line-indented">Uniformly detects and reports the occurrence of several types of errors,
|
||||
reducing the various errors to a uniform return value which is returned to the
|
||||
host environment.</p>
|
||||
<p>There are two intended uses:</p>
|
||||
@ -98,65 +117,67 @@ host environment.</p>
|
||||
specific errors, report them, and then return a presumably non-zero value.</li>
|
||||
</ul>
|
||||
<p>Requires:</p>
|
||||
<p>A user-supplied <b>cpp_main()</b> function with same interface as main().</p>
|
||||
<p class="1-line-indented">A user-supplied <b>cpp_main()</b> function with same interface as main().</p>
|
||||
Effects:
|
||||
<p>Call <b>cpp_main</b>( argc, argv ) in a try block.</p>
|
||||
<p class="1-line-indented">Call <b>cpp_main</b>( argc, argv ) in a try block.</p>
|
||||
<p>Treat as errors:</p>
|
||||
<ul>
|
||||
<li>Exceptions from <b>cpp_main()</b>.</li>
|
||||
<li>Non-zero return from <b>cpp_main()</b>.</li>
|
||||
</ul>
|
||||
<p>Report errors to both cout (with details) and cerr (summary). Rationale:
|
||||
<p class="1-line-indented">Report errors to both cout (with details) and cerr (summary). Rationale:
|
||||
Detail error reporting goes to cout so that it is properly interlaced with
|
||||
other output, thus aiding error analysis. Summary goes to cerr in case cout is
|
||||
redirected.</p>
|
||||
|
||||
<p>Returns:</p>
|
||||
|
||||
<p>non-zero if any error was detected, zero otherwise.
|
||||
<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p class="1-line-indented">non-zero if any error was detected, zero otherwise.
|
||||
<script language="Javascript">put_ref_to_top()</script></p>
|
||||
|
||||
<h2>The Program <a name="MonitorCompilation">Execution Monitor compilation</a></h2>
|
||||
<p>The Program Execution Monitor is supplied as an offline library and should be compiled and
|
||||
<p class="1-line-indented">The Program Execution Monitor is supplied as an offline library and should be compiled and
|
||||
linked with a test program. Following files, that are located in the Boost Test Library
|
||||
<b>src</b> directory, compose the component:</p>
|
||||
<blockquote>
|
||||
<p>
|
||||
src directory, compose the component:</p>
|
||||
<p class ="indented">
|
||||
<a href="../src/execution_monitor.cpp">execution_monitor.cpp</a><br>
|
||||
<a href="../src/cpp_main.cpp">cpp_main.cpp</a></p>
|
||||
</blockquote>
|
||||
<a href="../src/cpp_main.cpp">cpp_main.cpp</a>
|
||||
</p>
|
||||
|
||||
<h2><a name="Example">Example</a> Program</h2>
|
||||
<blockquote>
|
||||
<pre><a href="../example/prg_exec_example.cpp">prg_exec_example.cpp</a></pre>
|
||||
</blockquote>
|
||||
<p class ="indented">
|
||||
<a href="../example/prg_exec_example.cpp">prg_exec_example.cpp</a>
|
||||
|
||||
<h2><a name="Rationale">Rationale</a></h2>
|
||||
<p>The components of a C++ program may report user-detected errors in several
|
||||
ways, such as via a return value or throwing an exception. System-detected
|
||||
errors such as dereferencing an invalid pointer are reported in other ways,
|
||||
totally operating system and compiler dependent. </p>
|
||||
<p>Yet many C++ programs, both production and test, must run in an environment
|
||||
where uniform reporting of errors is necessary. For example, converting
|
||||
otherwise uncaught exceptions to non-zero program return codes allows many
|
||||
command line, script, or batch environments to continue processing in a
|
||||
controlled manner. Even some GUI environments benefit from the unification
|
||||
of errors into program return codes.</p>
|
||||
<h2><a name="Design">Design</a></h2>
|
||||
<p>The <a href="test_lib_design.htm">Boost Test Library Design</a>
|
||||
document describes the relationship between the Program Execution Monitor and <a href="execution_monitor.htm">
|
||||
Execution Monitor</a><u>.</u>
|
||||
<p class="1-line-indented">The components of a C++ program may report user-detected errors in several
|
||||
ways, such as via a return value or throwing an exception. System-detected errors such as dereferencing
|
||||
an invalid pointer are reported in other ways, totally operating system and compiler dependent.</p>
|
||||
|
||||
<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p class="1-line-indented">Yet many C++ programs, both production and test, must run in an environment
|
||||
where uniform reporting of errors is necessary. For example, converting otherwise uncaught exceptions
|
||||
to non-zero program return codes allows many command line, script, or batch environments to continue
|
||||
processing in a controlled manner. Even some GUI environments benefit from the unification of errors
|
||||
into program return codes.</p>
|
||||
|
||||
<h2><a name="Design">Design</a></h2>
|
||||
<p class="1-line-indented">The <a href="test_lib_design.htm">Boost Test Library Design</a>
|
||||
document describes the relationship between the Program Execution Monitor and <a href="execution_monitor.htm">
|
||||
Execution Monitor</a>.
|
||||
|
||||
<script language="Javascript">put_ref_to_top()</script></p>
|
||||
<hr>
|
||||
<p>© Beman Dawes, <a href="mailto:boost_test_library@consultant.com">Gennadiy Rozental</a> 2001</p>
|
||||
<p>© Beman Dawes 2000,
|
||||
<script language="Javascript">contact_addess()</script>
|
||||
<script language="Javascript">get_copyright_date()</script>
|
||||
</p>
|
||||
<p>Revised:
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED"
|
||||
S-Format="%d %B, %Y" startspan -->24 December, 2001<!--webbot bot="Timestamp" endspan i-checksum="38511" -->
|
||||
S-Format="%d %B, %Y" startspan -->09 August, 2002<!--webbot bot="Timestamp" endspan i-CheckSum="34422" -->
|
||||
</p>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
17
doc/style/btl-simple.css
Normal file
@ -0,0 +1,17 @@
|
||||
@import "btl.css";
|
||||
|
||||
BODY
|
||||
{
|
||||
background: white;
|
||||
}
|
||||
|
||||
table.body-table
|
||||
{
|
||||
border: none;
|
||||
width: 100%;
|
||||
}
|
||||
table.body-table td
|
||||
{
|
||||
color: black;
|
||||
background: white;
|
||||
}
|
196
doc/style/btl.css
Normal file
@ -0,0 +1,196 @@
|
||||
H1
|
||||
{
|
||||
FONT-SIZE: 200%;
|
||||
COLOR: #00008B;
|
||||
text-align: center;
|
||||
}
|
||||
H2
|
||||
{
|
||||
FONT-SIZE: 150%;
|
||||
}
|
||||
H3
|
||||
{
|
||||
FONT-SIZE: 125%;
|
||||
}
|
||||
H4
|
||||
{
|
||||
FONT-SIZE: 108%;
|
||||
}
|
||||
BODY
|
||||
{
|
||||
background: #808080;
|
||||
}
|
||||
a:link
|
||||
{
|
||||
color: #336699;
|
||||
}
|
||||
a:visited
|
||||
{
|
||||
color: #3F7EBE;
|
||||
}
|
||||
a:active
|
||||
{
|
||||
color: #699BCD;
|
||||
}
|
||||
|
||||
P.1-line-indented
|
||||
{
|
||||
text-indent: 10px;
|
||||
}
|
||||
P.indented
|
||||
{
|
||||
margin-left:20;
|
||||
margin-top:0;
|
||||
margin-bottom:0;
|
||||
}
|
||||
PRE.code
|
||||
{
|
||||
border-left-style: groove;
|
||||
border-left-width: 1px;
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
P.epigraph
|
||||
{
|
||||
text-align: right;
|
||||
font-family: Century Gothic;
|
||||
font-style: italic
|
||||
}
|
||||
|
||||
P.test-output
|
||||
{
|
||||
font-family: Arial;
|
||||
font-size: 12pt;
|
||||
margin-left: 2em;
|
||||
white-space: pre
|
||||
}
|
||||
|
||||
P.page-toc
|
||||
{
|
||||
font-weight: bold;
|
||||
margin-top:0;
|
||||
margin-bottom:0;
|
||||
}
|
||||
|
||||
P.page-toc-indented
|
||||
{
|
||||
font-weight: bold;
|
||||
margin-left:20;
|
||||
margin-top:0;
|
||||
margin-bottom:0;
|
||||
}
|
||||
|
||||
table.body-table
|
||||
{
|
||||
border: 5px solid #CDCDCD;
|
||||
width: 90%;
|
||||
}
|
||||
table.body-table td
|
||||
{
|
||||
margin: 3px;
|
||||
padding: 13px;
|
||||
color: black;
|
||||
background: #F0F0F0;
|
||||
}
|
||||
|
||||
table.parameter-table
|
||||
{
|
||||
border: none;
|
||||
border-bottom: ridge 2 black;
|
||||
width: 100%
|
||||
}
|
||||
table.parameter-table td
|
||||
{
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
table.parameter-values-table
|
||||
{
|
||||
border: none;
|
||||
width: 100%
|
||||
}
|
||||
table.parameter-values-table td
|
||||
{
|
||||
margin: 0px;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
table.2fields
|
||||
{
|
||||
border: none collapse;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
table.2fields td
|
||||
{
|
||||
margin-left: 0px;
|
||||
padding-left: 40px;
|
||||
valign: top;
|
||||
}
|
||||
|
||||
SPAN.literal
|
||||
{
|
||||
color: rgb(140,35,00);
|
||||
}
|
||||
SPAN.reserv-word
|
||||
{
|
||||
color: #6666FF;
|
||||
font-style: italic
|
||||
}
|
||||
SPAN.cpp-type
|
||||
{
|
||||
color: rgb(150,0,205);
|
||||
font-weight: bold;
|
||||
}
|
||||
SPAN.comment
|
||||
{
|
||||
color: rgb(00,99,33);
|
||||
}
|
||||
SPAN.new-term
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
IFRAME.inline-source-inlclusion
|
||||
{
|
||||
border-style: groove;
|
||||
border-width: 1;
|
||||
marginheight: 10;
|
||||
marginwidth: 10;
|
||||
width:'95%';
|
||||
height:200;
|
||||
scrolling:auto;
|
||||
}
|
||||
|
||||
DIV.print-header
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.header-menu
|
||||
{
|
||||
font-weight: bold;
|
||||
font-family: Arial;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.header-menu a:link
|
||||
{
|
||||
color: black;
|
||||
}
|
||||
.header-menu a:visited
|
||||
{
|
||||
color: black;
|
||||
}
|
||||
.header-menu a:active
|
||||
{
|
||||
color: black;
|
||||
}
|
||||
|
||||
.header-menu-root
|
||||
{
|
||||
border-style:none;
|
||||
}
|
158
doc/style/btl_print.css
Normal file
@ -0,0 +1,158 @@
|
||||
H1
|
||||
{
|
||||
FONT-SIZE: 200%;
|
||||
text-align: center;
|
||||
}
|
||||
H2
|
||||
{
|
||||
FONT-SIZE: 150%;
|
||||
}
|
||||
H3
|
||||
{
|
||||
FONT-SIZE: 125%;
|
||||
}
|
||||
H4
|
||||
{
|
||||
FONT-SIZE: 108%;
|
||||
}
|
||||
BODY
|
||||
{
|
||||
background: white;
|
||||
}
|
||||
a:link
|
||||
{
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:visited
|
||||
{
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:active
|
||||
{
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
P.1-line-indented
|
||||
{
|
||||
text-indent: 10px;
|
||||
}
|
||||
P.indented
|
||||
{
|
||||
margin-left:20;
|
||||
margin-top:0;
|
||||
margin-bottom:0;
|
||||
}
|
||||
PRE.code
|
||||
{
|
||||
border-left-style: groove;
|
||||
border-left-width: 1px;
|
||||
padding-left: 2em;
|
||||
font-size: 70%
|
||||
}
|
||||
|
||||
P.epigraph
|
||||
{
|
||||
text-align: right;
|
||||
font-family: Century Gothic;
|
||||
font-style: italic
|
||||
}
|
||||
|
||||
P.test-output
|
||||
{
|
||||
font-family: Arial;
|
||||
font-size: 10pt;
|
||||
margin-left: 2em;
|
||||
white-space: pre
|
||||
}
|
||||
|
||||
P.page-toc
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
P.page-toc-indented
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
table.body-table
|
||||
{
|
||||
border: none;
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
table.body-table td
|
||||
{
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
color: black;
|
||||
background: white;
|
||||
}
|
||||
|
||||
table.parameter-table
|
||||
{
|
||||
border: none;
|
||||
border-bottom: ridge 2 black;
|
||||
width: 100%
|
||||
}
|
||||
table.parameter-table td
|
||||
{
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
table.parameter-values-table
|
||||
{
|
||||
border: none;
|
||||
width: 100%
|
||||
}
|
||||
table.parameter-values-table td
|
||||
{
|
||||
margin: 0px;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
table.2fields
|
||||
{
|
||||
border: none collapse;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
table.2fields td
|
||||
{
|
||||
margin-left: 0px;
|
||||
padding-left: 40px;
|
||||
valign: top;
|
||||
}
|
||||
|
||||
SPAN.reserv-word
|
||||
{
|
||||
font-style: italic;
|
||||
}
|
||||
SPAN.cpp-type
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
SPAN.comment
|
||||
{
|
||||
font-style: oblique
|
||||
}
|
||||
SPAN.new-term
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
DIV.ref-to-top
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
DIV.screen-header
|
||||
{
|
||||
display: none;
|
||||
}
|
@ -1,66 +1,76 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Test Execution Monitor</title>
|
||||
<script language="javascript">var viso_path="js-lib"</script>
|
||||
<script language="javascript" src="js-lib/core.js" > </script>
|
||||
|
||||
<link id="screen_style" rel="stylesheet" type="text/css" href="style/btl.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="style/btl_print.css" media="print" />
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
||||
|
||||
<script language="JavaScript">
|
||||
include ( "btl.js" );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#808080" text="#000000" link="#336699" vlink="#3F7EBE" alink="#699BCD">
|
||||
<div align="center">
|
||||
<center>
|
||||
<table border="2" cellpadding="13" bordercolor="#CDCDCD" width="80%" id="AutoNumber1" cellspacing="3" style="border-collapse: collapse">
|
||||
<tr>
|
||||
<td width="100%" align="left" valign="top" bgcolor="#f0f0f0" border="0" >
|
||||
<body onload="btl_menu_init()">
|
||||
<div align="center">
|
||||
<table class="body-table" cellspacing="3" >
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<a name="TOP"><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></a><br clear="left">
|
||||
<script language="Javascript">btl_header()</script>
|
||||
|
||||
<h1 align="center">Boost Test Library: Test Execution Monitor</h1>
|
||||
<h1>Boost Test Library: Test Execution Monitor</h1>
|
||||
|
||||
<p><b><font color="#3F7EBE"><a href="#Introduction">Introduction</a><br>
|
||||
<p class="page-toc">
|
||||
<a href="#Introduction">Introduction</a><br>
|
||||
<a href="#Benefits">Benefits</a><br>
|
||||
<a href="#Introduction">Example</a><br>
|
||||
<a href="#MonitorCompilation">Compilation</a><br>
|
||||
<a href="#Tests">Test/Example Programs</a><br>
|
||||
<a href="#Rationale">Rationale</a><br>
|
||||
</font></b>
|
||||
<a href="#Design"><b>Design</b><br>
|
||||
</a><br>
|
||||
Also see: <b> <a href="uni_test_framework.htm">
|
||||
Unit Test Framework</a></b></p>
|
||||
<a href="#Design">Design</a><br><br>
|
||||
|
||||
Also see: <a href="uni_test_framework.htm">Unit Test Framework</a>
|
||||
</p>
|
||||
|
||||
<h2><a name="Introduction">Introduction</a></h2>
|
||||
<p>The Boost Test Library's Test Execution Monitor provides a <b>main()</b> function which calls a user-supplied <b>test_main()</b>
|
||||
<p class="1-line-indented">The Boost Test Library's Test Execution Monitor provides a <b>main()</b> function which calls a user-supplied <b>test_main()</b>
|
||||
function. The library supplied <b>main()</b> relieves users from messy error detection and reporting duties.
|
||||
The Test Execution Monitor is intended for fairly simple test programs or to dig a problem in
|
||||
an existent production code. <a href="prg_exec_monitor.htm">Program Execution Monitor</a> may be more suitable to monitor production (non-test) programs. <a href="unit_test_framework.htm">Unit Test Framework</a> may be more suitable for complex test programs. </p>
|
||||
|
||||
<h2><a name="Benefits">Benefits</a></h2>
|
||||
<p>The Test Execution Monitor provides a simple framework for program testing.<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p class="1-line-indented">The Test Execution Monitor provides a simple framework for program testing.<script language="Javascript">put_ref_to_top()</script></p>
|
||||
|
||||
<h2><a name="Example">Example</a></h2>
|
||||
<p>The example program shows six different ways to detect and report an error in the
|
||||
add() function.</p>
|
||||
<blockquote>
|
||||
<pre>#include <b><font color="#3F7EBE"><</font><a href="../../../boost/test/test_tools.hpp">boost/test/test_tools.hpp</a></b>>
|
||||
<p class="1-line-indented">The example program shows six different ways to detect and report an error in the
|
||||
<nobr>add()</nobr> function.</p>
|
||||
<pre class="code">#<span class="reserv-word">include</span> <<a href="../../../boost/test/test_tools.hpp">boost/test/test_tools.hpp</a>>
|
||||
|
||||
int add( int i, int j ) { return i+j; }
|
||||
<span class="cpp-type">int</span> add( <span class="cpp-type">int</span> i, <span class="cpp-type">int</span> j ) { <span class="reserv-word">return</span> i+j; }
|
||||
|
||||
int test_main( int, char *[] ) // note the name!
|
||||
<span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char </span>*[] ) <span class="comment">// note the name!</span>
|
||||
{
|
||||
// six ways to detect and report the same error:
|
||||
BOOST_CHECK( add(2,2) == 4 ); // #1 continues on error
|
||||
BOOST_REQUIRE( add(2,2) == 4 ); // #2 throws on error
|
||||
if ( add(2,2) != 4 )
|
||||
BOOST_ERROR( "Ouch..."); // #3 continues on error
|
||||
if ( add(2,2) != 4 )
|
||||
BOOST_FAIL("Ouch..."); // #4 throws on error
|
||||
if ( add(2,2) != 4 ) throw "Oops..."; // #5 throws on error
|
||||
return add(2,2) == 4 ? 0 : 1; // #6 returns error code
|
||||
// six ways to detect and report the same error:
|
||||
BOOST_CHECK( add( <span class="literal">2</span>,<span class="literal">2</span> ) == <span class="literal">4</span> ); <span class="comment">// #1 continues on error</span>
|
||||
BOOST_REQUIRE( add( <span class="literal">2</span>,<span class="literal">2</span> ) == <span class="literal">4</span> ); <span class="comment">// #2 throws on error</span>
|
||||
<span class="reserv-word">if</span>( add( <span class="literal">2</span>,<span class="literal">2</span> ) != <span class="literal">4</span> )
|
||||
BOOST_ERROR( <span class="literal">"Ouch..."</span> ); <span class="comment">// #3 continues on error</span>
|
||||
<span class="reserv-word">if</span>( add( <span class="literal">2</span>,<span class="literal">2</span> ) != <span class="literal">4</span> )
|
||||
BOOST_FAIL( <span class="literal">"Ouch..."</span> ); <span class="comment">// #4 throws on error</span>
|
||||
<span class="reserv-word">if</span>( add( <span class="literal">2</span>,<span class="literal">2</span> ) != <span class="literal">4</span> ) throw <span class="literal">"Oops..."</span>; <span class="comment">// #5 throws on error</span>
|
||||
|
||||
<span class="reserv-word">return</span> add( <span class="literal">2</span>, <span class="literal">2</span> ) == <span class="literal">4</span> ? <span class="literal">0</span> : <span class="literal">1</span>; <span class="comment">// #6 returns error code</span>
|
||||
}</pre>
|
||||
</blockquote>
|
||||
|
||||
<p><b>Approach #1</b> uses the BOOST_CHECK tool, which displays an error message
|
||||
on std::cout that includes the expression that failed, the source file name, and
|
||||
the source file line number. It also increments an error count. At program termination,
|
||||
the source file line number. It also increments an error count. At program termination,
|
||||
the error count will be displayed automatically by the Test Execution Monitor.</p>
|
||||
<p><b>Approach #2</b> using the BOOST_REQUIRE tool, is similar to #1, except that after
|
||||
displaying the error, an exception is thrown, to be caught by the Test Execution
|
||||
@ -70,25 +80,25 @@ testing impractical. BOOST_REQUIRE differs from the C++ Standard Library's
|
||||
assert() macro in that it is always generated, and channels error detection into
|
||||
the uniform Test Execution Monitor reporting procedure.</p>
|
||||
<p><b>Approaches #3 and #4</b> are similar to #1 and #2 respectively, except
|
||||
that the error detection is coded separately. This is most useful when the
|
||||
that the error detection is coded separately. This is most useful when the
|
||||
specific condition being tested is not indicative of the reason for failure.</p>
|
||||
<p><b>Approach #5</b> throws an exception, which will be caught and reported by the Test
|
||||
Execution Monitor. This approach is suitable for both production and test code, in
|
||||
libraries or not. The error message displayed when the exception is caught
|
||||
Execution Monitor. This approach is suitable for both production and test code, in
|
||||
libraries or not. The error message displayed when the exception is caught
|
||||
will be most meaningful if the exception is derived from std::exception, or is a
|
||||
char* or std::string.</p>
|
||||
<p><b>Approach #6</b> uses a return value to inform the caller of the error. This approach is particularly suitable for
|
||||
integrating existing test code with the test tools library. Although it
|
||||
integrating existing test code with the test tools library. Although it
|
||||
works fine with the Boost Program Execution Monitor or Test Execution Monitor libraries, and is very
|
||||
useful for running existing code under them, most C++ experts prefer using exceptions for error reporting.
|
||||
<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<script language="Javascript">put_ref_to_top()</script></p>
|
||||
|
||||
<h2>The Test <a name="MonitorCompilation">Execution Monitor compilation</a></h2>
|
||||
<p>The Test Execution Monitor is supplied as an offline library and should be compiled and
|
||||
<p class="1-line-indented">The Test Execution Monitor is supplied as an offline library and should be compiled and
|
||||
linked with a test program. Following files, that are located in the Boost Test Library
|
||||
<b>src</b> directory, compose the component:</p>
|
||||
<blockquote>
|
||||
<p>
|
||||
src directory, compose the component:</p>
|
||||
|
||||
<p class="indented">
|
||||
<a href="../src/execution_monitor.cpp">execution_monitor.cpp</a><br>
|
||||
<a href="../src/test_tools.cpp">test_tools.cpp</a><br>
|
||||
<a href="../src/unit_test_config.cpp">unit_test_config.cpp</a><br>
|
||||
@ -97,59 +107,64 @@ linked with a test program. Following files, that are located in the Boost Test
|
||||
<a href="../src/unit_test_result.cpp">unit_test_result.cpp</a><br>
|
||||
<a href="../src/unit_test_suite.cpp">unit_test_suite.cpp</a><br>
|
||||
<a href="../src/test_main.cpp">test_main.cpp</a></p>
|
||||
</blockquote>
|
||||
</p>
|
||||
|
||||
<h2><a name="Tests">Example and Test</a> Programs</h2>
|
||||
<blockquote>
|
||||
<pre><a href="../example/test_exec_example.cpp">test_exec_example.cpp</a>
|
||||
<a href="../test/test_exec_fail1.cpp">test_exec_fail1.cpp</a>
|
||||
<a href="../test/test_exec_fail2.cpp">test_exec_fail2.cpp</a>
|
||||
<a href="../test/test_exec_fail3.cpp">test_exec_fail3.cpp</a>
|
||||
<a href="../test/test_exec_fail4.cpp">test_exec_fail4.cpp</a></pre>
|
||||
</blockquote>
|
||||
<h2><a name="Rationale">Rationale</a><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></h2>
|
||||
<p>How should a test program report errors?</p>
|
||||
<p>Displaying an error message is an obvious possibility:</p>
|
||||
<blockquote>
|
||||
<pre>if ( something_bad_detected )
|
||||
<p class="indented">
|
||||
<a href="../example/test_exec_example.cpp">test_exec_example.cpp</a><br>
|
||||
<a href="../test/test_exec_fail1.cpp">test_exec_fail1.cpp</a><br>
|
||||
<a href="../test/test_exec_fail2.cpp">test_exec_fail2.cpp</a><br>
|
||||
<a href="../test/test_exec_fail3.cpp">test_exec_fail3.cpp</a><br>
|
||||
<a href="../test/test_exec_fail4.cpp">test_exec_fail4.cpp</a>
|
||||
</p>
|
||||
|
||||
<h2><a name="Rationale">Rationale</a><script language="Javascript">put_ref_to_top()</script></h2>
|
||||
<p class="1-line-indented">How should a test program report errors? Displaying an error message is an obvious possibility:</p>
|
||||
|
||||
<pre class="code"><span class="reserv-word">if</span>( something_bad_detected )
|
||||
std::cout << "something bad has been detected" << std::endl;</pre>
|
||||
</blockquote>
|
||||
<p>But that requires inspection of the program's output after each run to
|
||||
determine if an error occurred. Since test programs are often run as part
|
||||
|
||||
<p class="1-line-indented">But that requires inspection of the program's output after each run to
|
||||
determine if an error occurred. Since test programs are often run as part
|
||||
of a regression test suite, human inspection of output to detect error messages
|
||||
is too time consuming and unreliable. Test frameworks like GNU/expect can do the
|
||||
inspections automatically, but are overly complex for simple testing.</p>
|
||||
<p>A better simple way to report errors is for the test program to return
|
||||
<p class="1-line-indented">A better simple way to report errors is for the test program to return
|
||||
EXIT_SUCCESS (normally 0) if the test program completes satisfactorily, and
|
||||
EXIT_FAILURE if an error is detected. This allows a simple regression test script to
|
||||
automatically and unambiguous detect success or failure. Further
|
||||
automatically and unambiguous detect success or failure. Further
|
||||
appropriate actions such as creating an HTML table or emailing an alert can be
|
||||
taken by the script, and can be modified as desired without having to change the
|
||||
actual C++ test programs.</p>
|
||||
<p>A testing protocol based on a policy of test programs returning EXIT_SUCCESS or
|
||||
<p class="1-line-indented">A testing protocol based on a policy of test programs returning EXIT_SUCCESS or
|
||||
EXIT_FAILURE does not require any supporting tools; the C++ language and standard
|
||||
library are sufficient. The programmer must remember, however, to catch
|
||||
library are sufficient. The programmer must remember, however, to catch
|
||||
all exceptions and convert them to program exits with non-zero return codes. The
|
||||
programmer must also remember to not use the standard library assert() macro for
|
||||
test code, because on some systems it results in undesirable side effects like a message
|
||||
requiring manual intervention.</p>
|
||||
<p>The Test Execution Monitor automates those tasks, yet can be ignored by
|
||||
<p class="1-line-indented">The Test Execution Monitor automates those tasks, yet can be ignored by
|
||||
programmers who prefer to implement the zero return testing protocol themselves.</p>
|
||||
|
||||
<h2><a name="Design">Design</a></h2>
|
||||
<p>The <a href="test_lib_design.htm">Boost Test Library Design</a> document describes the relationship
|
||||
between Boost Test Library components.
|
||||
<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<script language="Javascript">put_ref_to_top()</script></p>
|
||||
<hr>
|
||||
<p>© Beman Dawes 2000, <a href="mailto:boost_test_library@consultant.com">Gennadiy Rozental</a> 2001</p>
|
||||
<p>© Beman Dawes 2000,
|
||||
<script language="Javascript">contact_addess()</script>
|
||||
<script language="Javascript">get_copyright_date()</script>
|
||||
</p>
|
||||
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED"
|
||||
S-Format="%d %b %Y" startspan -->24 Dec 2001<!--webbot bot="Timestamp" endspan i-checksum="14398" -->
|
||||
S-Format="%d %b %Y" startspan -->29 Jul 2002<!--webbot bot="Timestamp" endspan i-checksum="14998" -->
|
||||
</p>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
@ -1,32 +1,46 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Program Execution Monitor</title>
|
||||
<title>Bost Test Library Detailed Design</title>
|
||||
<script language="javascript">var viso_path="js-lib"</script>
|
||||
<script language="javascript" src="js-lib/core.js" > </script>
|
||||
|
||||
<link id="screen_style" rel="stylesheet" type="text/css" href="style/btl.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="style/btl_print.css" media="print" />
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
||||
|
||||
<script language="JavaScript">
|
||||
include ( "btl.js" );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#808080" text="#000000" link="#336699" vlink="#3F7EBE" alink="#699BCD">
|
||||
<div align="center">
|
||||
<center>
|
||||
<table border="2" cellpadding="13" bordercolor="#CDCDCD" width="80%" id="AutoNumber1" cellspacing="3" style="border-collapse: collapse">
|
||||
<tr>
|
||||
<td width="100%" align="left" valign="top" bgcolor="#f0f0f0" border="0" >
|
||||
<body onload="btl_menu_init()">
|
||||
<div align="center">
|
||||
<table class="body-table" cellspacing="3" >
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<a name="TOP"><img border="0" src="../../../c++boost.gif" width="277" height="86"></a><br clear=left>
|
||||
<script language="Javascript">btl_header()</script>
|
||||
|
||||
<h1 align="center">Boost Test Library: detailed design</h1>
|
||||
<h1>Boost Test Library: detailed design</h1>
|
||||
|
||||
<p>To be supplied. Sorry.</p>
|
||||
<hr>
|
||||
<p>© Beman Dawes, <a href="mailto:boost_test_library@consultant.com">Gennadiy Rozental</a> 2001</p>
|
||||
<p>© Beman Dawes 2000,
|
||||
<script language="Javascript">contact_addess()</script>
|
||||
<script language="Javascript">get_copyright_date()</script>
|
||||
</p>
|
||||
<p>Revised:
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED"
|
||||
S-Format="%d %B, %Y" startspan -->25 December, 2001<!--webbot bot="Timestamp" endspan i-checksum="38513" -->
|
||||
S-Format="%d %B, %Y" startspan -->25 July, 2002<!--webbot bot="Timestamp" endspan i-checksum="21088" -->
|
||||
</p>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
@ -1,379 +1,430 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Test Tools</title>
|
||||
<script language="javascript">var viso_path="js-lib"</script>
|
||||
<script language="javascript" src="js-lib/core.js" > </script>
|
||||
|
||||
<link id="screen_style" rel="stylesheet" type="text/css" href="style/btl.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="style/btl_print.css" media="print" />
|
||||
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
||||
|
||||
<script language="JavaScript">
|
||||
include ( "btl.js" );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#808080" text="#000000" link="#336699" vlink="#3F7EBE" alink="#699BCD">
|
||||
<div align="center">
|
||||
<center>
|
||||
<table border="2" cellpadding="13" bordercolor="#CDCDCD" width="80%" id="AutoNumber1">
|
||||
<tr>
|
||||
<td width="100%" align="left" valign="TOP" bgcolor="#f0f0f0" border="0" >
|
||||
<body onload="btl_menu_init()">
|
||||
<div align="center">
|
||||
<table class="body-table" cellspacing="3" >
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<a name="TOP"><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></a><br clear="left">
|
||||
<script language="Javascript">btl_header()</script>
|
||||
|
||||
<h1 align="center">Boost Test Library: Test Tools</h1>
|
||||
<p><b>
|
||||
<p class="page-toc">
|
||||
<a href="#Introduction">Introduction</a><br>
|
||||
<a href="#Benifits">Benefits</a><br>
|
||||
<a href="#Specification">Specification<br>
|
||||
</a>
|
||||
<a href="#BOOST_CHECKPOINT">BOOST_CHECKPOINT</a><br>
|
||||
<a href="#BOOST_WARN">BOOST_WARN</a><br>
|
||||
<a href="#BOOST_CHECK">BOOST_CHECK</a><br>
|
||||
<a href="#BOOST_CHECK_EQUAL">BOOST_CHECK_EQUAL</a><br>
|
||||
<a href="#BOOST_CHECK_CLOSE_tolerance">BOOST_CHECK_CLOSE</a><br>
|
||||
<a href="#BOOST_REQUIRE">BOOST_REQUIRE</a><br>
|
||||
<a href="#BOOST_MESSAGE">BOOST_MESSAGE</a><br>
|
||||
<a href="#BOOST_CHECK_MESSAGE">BOOST_WARN_MESSAGE</a><br>
|
||||
<a href="#BOOST_CHECK_MESSAGE">BOOST_CHECK_MESSAGE</a><br>
|
||||
<a href="#BOOST_CHECK_MESSAGE">BOOST_REQUIRE_MESSAGE</a><br>
|
||||
<a href="#BOOST_CHECK_PREDICATE">BOOST_CHECK_PREDICATE</a><br>
|
||||
<a href="#BOOST_REQUIRE_PREDICATE">BOOST_REQUIRE_PREDICATE</a><br>
|
||||
<a href="#BOOST_ERROR">BOOST_ERROR</a><br>
|
||||
<a href="#BOOST_FAIL">BOOST_FAIL</a><br>
|
||||
<a href="#BOOST_CHECK_THROW">BOOST_CHECK_THROW</a><br>
|
||||
<a href="#BOOST_CHECK_EQUAL_COLLECTIONS">BOOST_CHECK_EQUAL_COLLECTIONS</a><br>
|
||||
<a href="#BOOST_IS_DEFINED">BOOST_IS_DEFINED<br></a>
|
||||
<a href="output_test_stream.htm">output_test_stream</a></b><br>
|
||||
|
||||
<b><a href="#Examples">Example and Test Programs</a><br>
|
||||
<a href="#Design">Design</a>
|
||||
</b></p>
|
||||
<a href="#Specification">Specification</a><br></p>
|
||||
<p class="page-toc-indented">
|
||||
<a href="#BOOST_CHECKPOINT">BOOST_CHECKPOINT</a><br>
|
||||
<a href="#BOOST_WARN">BOOST_WARN</a><br>
|
||||
<a href="#BOOST_CHECK">BOOST_CHECK</a><br>
|
||||
<a href="#BOOST_CHECK_EQUAL">BOOST_CHECK_EQUAL</a><br>
|
||||
<a href="#BOOST_CHECK_CLOSE_tolerance">BOOST_CHECK_CLOSE</a><br>
|
||||
<a href="#BOOST_REQUIRE">BOOST_REQUIRE</a><br>
|
||||
<a href="#BOOST_MESSAGE">BOOST_MESSAGE</a><br>
|
||||
<a href="#BOOST_CHECK_MESSAGE">BOOST_WARN_MESSAGE</a><br>
|
||||
<a href="#BOOST_CHECK_MESSAGE">BOOST_CHECK_MESSAGE</a><br>
|
||||
<a href="#BOOST_CHECK_MESSAGE">BOOST_REQUIRE_MESSAGE</a><br>
|
||||
<a href="#BOOST_CHECK_PREDICATE">BOOST_CHECK_PREDICATE</a><br>
|
||||
<a href="#BOOST_REQUIRE_PREDICATE">BOOST_REQUIRE_PREDICATE</a><br>
|
||||
<a href="#BOOST_ERROR">BOOST_ERROR</a><br>
|
||||
<a href="#BOOST_FAIL">BOOST_FAIL</a><br>
|
||||
<a href="#BOOST_CHECK_THROW">BOOST_CHECK_THROW</a><br>
|
||||
<a href="#BOOST_CHECK_EQUAL_COLLECTIONS">BOOST_CHECK_EQUAL_COLLECTIONS</a><br>
|
||||
<a href="#BOOST_IS_DEFINED">BOOST_IS_DEFINED<br></a>
|
||||
<a href="output_test_stream.htm">output_test_stream</a>
|
||||
</p>
|
||||
<p class="page-toc">
|
||||
<a href="#Examples">Example and Test Programs</a><br>
|
||||
<a href="#Design">Design</a>
|
||||
</p>
|
||||
|
||||
<h2><a name="Introduction">Introduction</a></h2>
|
||||
<p> Boost Test Library's Test Tools supply a toolbox to ease a creation and a maintenance of test programs.
|
||||
|
||||
<p class="1-line-indented"> Boost Test Library's Test Tools supply a toolbox to ease a creation and a maintenance of test programs.
|
||||
The toolbox supplied in a form of macros and function declarations. While the functions can be called directly,
|
||||
the usual way to use Test Tools is via convenience macros. All macros arguments are calculated once, so it's safe to
|
||||
pass complex expressions in their place. All macros provide an error location: a
|
||||
file name and a line number. Boost Test Library's Test Tools are intended for test code rather than library or
|
||||
production code,
|
||||
where throwing exceptions, using assert(), or BOOST_STATIC_ASSERT() may be more suitable ways to
|
||||
detect and report errors.<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a>
|
||||
To use the Test Tools you need to link with either the
|
||||
<a href="prg_exec_monitor.htm">Program Execution Monitor</a> or the
|
||||
<a href="unit_test_framework.htm">Unit Test Framework</a>.</p>
|
||||
production code, where throwing exceptions, using assert(), or BOOST_STATIC_ASSERT() may be more suitable ways to
|
||||
detect and report errors.
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
To use the Test Tools you need to link with either the <a href="prg_exec_monitor.htm">Program Execution Monitor</a> or the
|
||||
<a href="unit_test_framework.htm">Unit Test Framework</a>.
|
||||
</p>
|
||||
|
||||
<h2><a name="Benifits">Benefits</a></h2>
|
||||
<p>Using of Test Tools simplify writing of test program and provide a uniform
|
||||
<p class="1-line-indented">Using of Test Tools simplify writing of test program and provide a uniform
|
||||
error reporting mechanism.</p>
|
||||
|
||||
<h2><a name="Specification">Specification</a></h2>
|
||||
<p><b><a name="BOOST_CHECKPOINT">BOOST_CHECKPOINT</a>( message ) </b>- to be used to
|
||||
<p><b><a name="BOOST_CHECKPOINT">BOOST_CHECKPOINT</a>( message )</b> - to be used to
|
||||
mark a test flow with a check points. The checkpoint can help to locate a source of
|
||||
a runtime exception.</p>
|
||||
<p> Example: test.cpp </p>
|
||||
<p> <i>int</i> test_main( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
BOOST_CHECKPOINT(
|
||||
"Going to throw an exception" );<br>
|
||||
<i>throw</i> "some
|
||||
error";<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial">Exception in
|
||||
test_main : C string:some_error<br>
|
||||
test.cpp(3) : last checkpoint: Going
|
||||
to throw an exception</font><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p><b><a name="BOOST_WARN">BOOST_WARN</a>( predicate ) </b>- to be used to
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
BOOST_CHECKPOINT( <span class="literal">"Going to throw an exception"</span> );
|
||||
<span class="reserv-word">throw</span> <span class="literal">"some error"</span>;
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
<p>Output:</p>
|
||||
<p class="test-output">
|
||||
Exception in test_main : C string:some_error<br>
|
||||
test.cpp(2) : last checkpoint: Going to throw an exception
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<p><b><a name="BOOST_WARN">BOOST_WARN</a>( predicate )</b> - to be used to
|
||||
perform a weak validation of the the predicate. If predicate is true, the tool produces
|
||||
a conformation message in other case it produces a warning message in
|
||||
a form "warning in ...: condition <predicate> is not satisfied"</p>
|
||||
<p> Example: test.cpp </p>
|
||||
<p> <i>int</i> test_main( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
BOOST_WARN( <i>sizeof</i>(<i>int</i>)
|
||||
== <i>sizeof</i>(<i>short</i>) );<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial">test.cpp(3) :
|
||||
warning in test_main: condition sizeof(int) == sizeof(short) is not satisfied</font><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p><b><a name="BOOST_CHECK">BOOST_CHECK</a>( predicate ) </b>- to be used to validate
|
||||
the predicate value. If
|
||||
predicate is <i> true</i>, the tool produces a conformation message (note here
|
||||
and further: to manage what massages appear in the test output stream set the
|
||||
proper log level) in other case it produces an error message in
|
||||
a form "error in ...: test <predicate> fail"</p>
|
||||
<p> Example: test.cpp </p>
|
||||
<p> <i>int</i> test_main( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
i=2;<br>
|
||||
BOOST_CHECK( i ==1 );<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial">test.cpp(4) :
|
||||
error in test_main: test i==1 failed</font><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p><b><a name="BOOST_CHECK_EQUAL">BOOST_CHECK_EQUAL</a>( left, right ) - </b>the<b> </b>same as BOOST_CHECK( left == right
|
||||
). The tools allows to see mismatched
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
BOOST_WARN( <span class="reserv-word">sizeof</span>(<span class="cpp-type">int</span>) == <span class="reserv-word">sizeof</span>(<span class="cpp-type">short</span>) );
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Output:</p>
|
||||
<p class="test-output">test.cpp(2) : warning in test_main: condition sizeof(int) == sizeof(short) is not satisfied
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<p><b><a name="BOOST_CHECK">BOOST_CHECK</a>( predicate )</b> - to be used to validate
|
||||
the predicate value. If predicate is true, the tool produces a conformation message (note here
|
||||
and further: to manage what massages appear in the test output stream set the proper log level)
|
||||
in other case it produces an error message in a form "error in ...: test <predicate> fail"</p>
|
||||
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
<span class="cpp-type">int</span> i=<span class="literal">2</span>;
|
||||
BOOST_CHECK( i == <span class="literal">1</span> );
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Output:</p>
|
||||
<p class="test-output">test.cpp(3) : error in test_main: test i==1 failed
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<p><b><a name="BOOST_CHECK_EQUAL">BOOST_CHECK_EQUAL</a>( left, right )</b> - the same as BOOST_CHECK( left == right ). The tools allows to see mismatched
|
||||
values.<br>
|
||||
<br>
|
||||
Example: test.cpp </p>
|
||||
<p> <i>int</i> test_main( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
<b><i> </i></b><i>int</i> i = 2;<br>
|
||||
<i>int</i> j = 1;<br>
|
||||
BOOST_CHECK_EQUAL( i, j );<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial"> </font> <font face="Arial">test.cpp(5) :
|
||||
error in test_main: test i == j failed [2 != 1]</font><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p><b><a name="BOOST_CHECK_CLOSE_tolerance">BOOST_CHECK_CLOSE</a>( left, right, tolerance_src ) </b>
|
||||
- to be used to check for the strong relationship defined by the predicate
|
||||
<a href="floating_point_comparison.htm">close_at_tolerance</a>( tolerance_src<b>
|
||||
)</b>
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
<span class="cpp-type">int</span> i = <span class="literal">2</span>;
|
||||
<span class="cpp-type">int</span> j = <span class="literal">1</span>;
|
||||
BOOST_CHECK_EQUAL( i, j );
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Output:</p>
|
||||
<p class="test-output"> test.cpp(4) : error in test_main: test i == j failed [2 != 1]
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<p><b><a name="BOOST_CHECK_CLOSE_tolerance">BOOST_CHECK_CLOSE</a>( left, right, tolerance_src )</b>
|
||||
- to be used to check for the strong relationship defined by the predicate
|
||||
<a href="floating_point_comparison.htm">close_at_tolerance</a>( tolerance_src )
|
||||
between <i>left</i> and <i>right</i>. To check for the weak relationship use
|
||||
<a href="#BOOST_CHECK_PREDICATE">BOOST_CHECK_PREDICATE</a>.<br>
|
||||
<a href="#BOOST_CHECK_PREDICATE">BOOST_CHECK_PREDICATE</a>. Note that you need
|
||||
to include <a href="../../../boost/test/detail/floating_point_comparison.hpp">
|
||||
detail/floating_point_comparison.hpp</a> yourself to use this tool since it
|
||||
depend on this file that does not get included automatically to minimize code
|
||||
dependency.<br>
|
||||
<br>
|
||||
Example: test.cpp </p>
|
||||
<p> <i>int</i> test_main( <i>int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
<b><i> </i></b><i>double</i> v1 =
|
||||
1.23456e-10;<br>
|
||||
<b><i> </i></b><i>double</i> v2 =
|
||||
1.23457e-10;<br>
|
||||
BOOST_CHECK_CLOSE( v1, v2,
|
||||
1e-6 ); // should fail at tolerance supplied<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial"> </font> <font face="Arial">test.cpp(5) :
|
||||
error in test_main: test v1 (==) v2 failed [1.23456e-10 != 1.23457e-10 (1e-06)]</font></p>
|
||||
<p> Example: test.cpp </p>
|
||||
<p> <i>int</i> test_main( <i>int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
<b><i> </i></b><i>double</i> v1 =
|
||||
4.1;<br>
|
||||
<b><i> </i></b>v1 = v1 *
|
||||
v1;<br>
|
||||
BOOST_CHECK_CLOSE( v1,
|
||||
16.81, 1+2 ); // 1(arithmetic operation)+2(decimal to binary conversions) -
|
||||
number of rounding errors; should pass<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p><b><a name="BOOST_REQUIRE">BOOST_REQUIRE</a>( predicate ) </b>- to be used to validate
|
||||
the predicate value. If
|
||||
predicate is <i> true</i>, the tool produces a conformation message in other case
|
||||
it produces an error message in
|
||||
a form "fatal error in ...: test <predicate> fail" and then abort
|
||||
the current test case processing.</p>
|
||||
<p> Example: test.cpp </p>
|
||||
<p> <i>int</i> test_main( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
i=3;<br>
|
||||
BOOST_REQUIRE( i
|
||||
> 5 );<br>
|
||||
BOOST_CHECK( i == 6 );
|
||||
// will never reach this check<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial">test.cpp(4) :
|
||||
fatal error in test_main: test i>5 failed</font><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p><b><a name="BOOST_MESSAGE">BOOST_MESSAGE</a>( message ) </b>- to be used to
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
<span class="cpp-type">double</span> v1 = <span class="literal">1.23456e-10</span>;
|
||||
<span class="cpp-type">double</span> v2 = <span class="literal">1.23457e-10</span>;
|
||||
|
||||
BOOST_CHECK_CLOSE( v1, v2, <span class="literal">1e-6</span> ); <span class="comment">// should fail at tolerance supplied</span>
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
<p>Output:</p>
|
||||
<p class="test-output">test.cpp(4) : error in test_main: test v1 (==) v2 failed [1.23456e-10 != 1.23457e-10 (1e-06)]
|
||||
</p>
|
||||
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
<span class="cpp-type">double</span> v1 = <span class="literal">4.1;</span>
|
||||
|
||||
v1 = v1 * v1;
|
||||
BOOST_CHECK_CLOSE( v1, <span class="literal">16.81</span>, <span class="literal">1</span>+<span class="literal">2</span> );
|
||||
<span class="comment">// 1(arithmetic operation) +
|
||||
// 2(decimal to binary conversions) -
|
||||
// number of rounding errors; should pass</span>
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Output:
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<p><b><a name="BOOST_REQUIRE">BOOST_REQUIRE</a>( predicate )</b> - to be used to validate
|
||||
the predicate value. If predicate is <i>true</i>, the tool produces a conformation message in other case
|
||||
it produces an error message in a form "fatal error in ...: test <predicate> fail"
|
||||
and then abort the current test case processing.</p>
|
||||
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
<span class="cpp-type">int</span> i = <span class="literal">3</span>;
|
||||
BOOST_REQUIRE( i > <span class="literal">5</span> );
|
||||
BOOST_CHECK( i == <span class="literal">6</span> ); <span class="comment">// will never reach this check</span>
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Output:</p>
|
||||
<p class="test-output">test.cpp(3) : fatal error in test_main: test i>5 failed
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<p><b><a name="BOOST_MESSAGE">BOOST_MESSAGE</a>( message )</b> - to be used to
|
||||
print the message in the test output stream. The message argument can be of any type and can
|
||||
be a result of concatenations using the operator <<.</p>
|
||||
<p> Example: test.cpp </p>
|
||||
<p> <i>struct</i> A { <br>
|
||||
<i>friend</i>
|
||||
std::ostream& operator<<( std::ostream& str, A const& a ) {
|
||||
str << "struct A"; <i> return</i> str;} <br>
|
||||
};</p>
|
||||
<p> <i>int</i> test_main( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
BOOST_MESSAGE(
|
||||
"Starting test" );<br>
|
||||
<i>int</i> i = 2 <br>
|
||||
BOOST_MESSAGE( "i="
|
||||
<< i );<br>
|
||||
BOOST_MESSAGE(
|
||||
"still testing..." );<br>
|
||||
<i>struct</i> A a;<br>
|
||||
BOOST_MESSAGE( a
|
||||
<< '.' );<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial">Starting test</font><br>
|
||||
<font face="Arial">i=2</font><br>
|
||||
<font face="Arial"> </font><i> </i><font face="Arial">still
|
||||
testing...</font><br>
|
||||
<font face="Arial"> </font><i> </i><font face="Arial">struct
|
||||
A.</font><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="reserv-word">struct</span> A {
|
||||
<span class="reserv-word">friend</span> <span class="cpp-type">std::ostream</span>& <span class=keyword>operator</span><<( <span class="cpp-type">std::ostream</span>& str, A <span class=keyword>const</span>& a ) {
|
||||
str << <span class="literal">"struct A"</span>;
|
||||
|
||||
<span class="reserv-word">return</span> str;
|
||||
}
|
||||
};
|
||||
|
||||
<span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
BOOST_MESSAGE( <span class="literal">"Starting test"</span> );
|
||||
|
||||
<span class="cpp-type">int</span> i = <span class="literal">2</span>;
|
||||
BOOST_MESSAGE( <span class="literal">"i="</span> << i );
|
||||
|
||||
BOOST_MESSAGE( <span class="literal">"still testing..."</span> );
|
||||
|
||||
<span class="reserv-word">struct</span> A a;
|
||||
BOOST_MESSAGE( a << <span class="literal">'.'</span> );
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Output:</p>
|
||||
<p class="test-output">Starting test</font><br>
|
||||
i=2<br>
|
||||
still testing...<br>
|
||||
struct A.
|
||||
<script language="Javascript">put_ref_to_top()</script></p>
|
||||
|
||||
<p><b><a name="BOOST_CHECK_MESSAGE">BOOST_WARN_MESSAGE</a>( predicate, message ) <br>
|
||||
BOOST_CHECK_MESSAGE( predicate, message )<br>
|
||||
<a name="BOOST_CHECK_MESSAGE">BOOST_REQUIRE_MESSAGE</a>( predicate, message ) </b>-
|
||||
this group of tools works the same way as their non _MESSAGE form. The only
|
||||
difference is test instead of generating of an error/confirm message these macros
|
||||
use the supplied one.</p>
|
||||
<p> Example: test.cpp </p>
|
||||
<p> <i>int</i> test.cpp( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
<i>double</i> res = sin( 45 );<br>
|
||||
BOOST_CHECK_MESSAGE( res
|
||||
> 3, "Why not?!?!" );<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial"> </font> <font face="Arial">test.cpp(4) :
|
||||
error in test_main: Why not?!?!</font><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
BOOST_CHECK_MESSAGE( predicate, message )<br> <a name="BOOST_CHECK_MESSAGE">BOOST_REQUIRE_MESSAGE</a>( predicate, message )</b> -
|
||||
this group of tools works the same way as their non _MESSAGE form. The only difference is
|
||||
test instead of generating of an error/confirm message these macros use the supplied one.</p>
|
||||
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test.cpp( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
<span class="cpp-type">double</span> res = sin( <span class="literal">45</span> );
|
||||
|
||||
BOOST_CHECK_MESSAGE( res > <span class="literal">3</span>, <span class="literal">"Why not?!?!"</span> );
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Output:</p>
|
||||
<p class="test-output">test.cpp(3) : error in test_main: Why not?!?!
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<p><b><a name="BOOST_CHECK_PREDICATE">BOOST_CHECK_PREDICATE</a>( prediate,
|
||||
number_of_arguments, arguments_list )</b> - to be used to validate the supplied
|
||||
predicate. If predicate produces <i> true</i> value, the tool produces a conformation message in other case it produces an error message in
|
||||
a form "error in ...: test <predicate>( arguments_list ) fail for
|
||||
(arguments values)". Right now only unary and binary predicates are
|
||||
supported.</p>
|
||||
<p> Example: test.cpp <br>
|
||||
<br>
|
||||
bool is_even( int i ) {<br>
|
||||
return i%2 == 0;<br>
|
||||
}</p>
|
||||
<p> <i>int</i> test.cpp( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
int i = 17;<br>
|
||||
BOOST_CHECK_PREDICATE( &is_even,
|
||||
1, (i) );<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial"> </font> <font face="Arial">test.cpp(4) :
|
||||
error in test_main: test &is_even(i) failed for 17</font></p>
|
||||
<p> Example: test.cpp <br>
|
||||
<br>
|
||||
<i>int</i> test.cpp( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
int i = 17;<br>
|
||||
BOOST_CHECK_PREDICATE(
|
||||
std::not_equal_to<int>(), 2, (i,17) );<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial"> </font> <font face="Arial">test.cpp(4) :
|
||||
error in test_main: test std::not_equal_to<int>()(i, 17) failed for (17, 17)</font><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p><b><a name="BOOST_REQUIRE_PREDICATE">BOOST_REQUIRE_PREDICATE</a>( prediate,
|
||||
number_of_arguments, arguments_list )</b> - to be used to validate the supplied
|
||||
<p>Example: test.cpp</p>
|
||||
|
||||
<pre class="code"><span class="cpp-type">bool</span> is_even( <span class="cpp-type">int</span> i ) {
|
||||
<span class="reserv-word">return</span> i%<span class="literal">2</span> == <span class="literal">0</span>;
|
||||
}
|
||||
|
||||
<span class="cpp-type">int</span> test.cpp( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
<span class="cpp-type">int</span> i = <span class="literal">17</span>;
|
||||
BOOST_CHECK_PREDICATE( &is_even, <span class="literal">1</span>, (i) );
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Output:</p>
|
||||
<p class="test-output">test.cpp(3) : error in test_main: test &is_even(i) failed for 17
|
||||
</p>
|
||||
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test.cpp( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
<span class="cpp-type">int</span> i = <span class="literal">17</span>;
|
||||
|
||||
BOOST_CHECK_PREDICATE( std::not_equal_to<<span class="cpp-type">int</span>>(), <span class="literal">2</span>, (i,<span class="literal">17</span>) );
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Output:</p>
|
||||
<p class="test-output">test.cpp(3) : error in test_main: test std::not_equal_to<int>()(i, 17) failed for (17, 17)
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<p><b><a name="BOOST_REQUIRE_PREDICATE">BOOST_REQUIRE_PREDICATE</a>( prediate, number_of_arguments, arguments_list )</b> - to be used to validate the supplied
|
||||
predicate. If predicate produces <i> true</i> value, the tool produces a conformation message in other case it produces an error message in
|
||||
a form "error in ...: test <predicate>( arguments_list ) fail for
|
||||
(arguments values)" and abort current test case processing. Right now only
|
||||
a form "error in ...: test <predicate>( arguments_list ) fail for (arguments values)" and abort current test case processing. Right now only
|
||||
unary and binary predicates are supported.</p>
|
||||
<p> Example: test.cpp <br>
|
||||
<br>
|
||||
<i>int</i> test.cpp( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
double fp1 = 1.23456e-10;<br>
|
||||
double fp2 = 1.23457e-10;<br>
|
||||
double epsilon = 8.1e-6;<br>
|
||||
BOOST_CHECK_PREDICATE(
|
||||
close_at_tolerance<double>( epsilon, false /* weak */ ), 2, ( fp1, fp2 )
|
||||
); // should pass<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial"> </font> <a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p>Example: test.cpp</p>
|
||||
|
||||
<pre class="code"><span class="cpp-type">int</span> test.cpp( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
<span class="cpp-type">double</span> fp1 = <span class="literal">1.23456e-10</span>;
|
||||
<span class="cpp-type">double</span> fp2 = <span class="literal">1.23457e-10</span>;
|
||||
<span class="cpp-type">double</span> epsilon = <span class="literal">8.1e-6</span>;
|
||||
|
||||
<span class="comment">// check weak closeness </span>
|
||||
BOOST_CHECK_PREDICATE( close_at_tolerance<double>( epsilon, <span class="reserv-word">false</span> ),
|
||||
<span class="literal">2</span>, ( fp1, fp2 ) ); <span class="comment">// should pass</span>
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
<p>Output:</p>
|
||||
|
||||
<p><b><a name="BOOST_ERROR">BOOST_ERROR</a>( message ) </b>- the
|
||||
same as BOOST_CHECK_MESSAGE( false, message ); to be used for an unconditional
|
||||
error message<br>
|
||||
<b><a name="BOOST_FAIL">BOOST_FAIL</a>( message ) </b>- the same as BOOST_REQUIRE_MESSAGE( false, message ); to be used for
|
||||
<b><a name="BOOST_FAIL">BOOST_FAIL</a>( message )</b> - the same as BOOST_REQUIRE_MESSAGE( false, message ); to be used for
|
||||
an unconditional error message and the current test case aborting</p>
|
||||
<p> Example: test.cpp </p>
|
||||
<p align="left"> <i>int</i> test_main( <i> int</i>,
|
||||
<i>char</i>* [] )<br>
|
||||
{<br>
|
||||
BOOST_ERROR(
|
||||
"Nothing to test" );<br>
|
||||
BOOST_FAIL( "Test is
|
||||
not ready yet" );<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial"> </font> <font face="Arial">test.cpp(4) : error in
|
||||
test_main: Nothing to test<br>
|
||||
</font> <font face="Arial">test.cpp(5) :
|
||||
fatal error in test_main: Test is not ready yet</font><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
BOOST_ERROR( <span class="literal">"Nothing to test"</span> );
|
||||
BOOST_FAIL( <span class="literal">"Test is not ready yet"</span> );
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Output:</p>
|
||||
<p class="test-output">
|
||||
test.cpp(3) : error in test_main: Nothing to test<br>
|
||||
test.cpp(4) : fatal error in test_main: Test is not ready yet
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<p><b><a name="BOOST_CHECK_THROW">BOOST_CHECK_THROW</a>( statement, exception ) </b> -
|
||||
to be used to perform an error detection check The tool executes the supplied
|
||||
statement and check that it throw the supplied exception.
|
||||
</p>
|
||||
<p> Example: test.cpp </p>
|
||||
<p> <i>class</i> my_exception{};<br>
|
||||
<i>int</i> test_main( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
<i><b> </b>int</i> i =0;<br>
|
||||
BOOST_CHECK_THROW( i++,
|
||||
my_exception );<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial"> </font> <font face="Arial">test.cpp(5) :
|
||||
error in test_main: exception my_exception expected</font><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p><b><a name="BOOST_CHECK_EQUAL_COLLECTIONS">BOOST_CHECK_EQUAL</a>_COLLECTIONS( left_begin,
|
||||
left_end, right_begin ) </b> - to be used to perform an element comparison of two
|
||||
collections
|
||||
</p>
|
||||
<p> Example: test.cpp </p>
|
||||
<p> <i>int</i> test_main( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
<i>int</i> col1 [] = { 1, 2, 3,
|
||||
4, 5, 6, 7 };<br>
|
||||
<i>int</i> col2 [] = { 1, 2, 4,
|
||||
4, 5, 7, 7 };<br>
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS( col1, col1+7, col2);<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial"> </font> <font face="Arial">test.cpp(5) :
|
||||
error in test_main: test {col1, col1+7} == {col2,...} failed [3 != 4]<br>
|
||||
</font> <font face="Arial">test.cpp(5) :
|
||||
error in test_main: test {col1, col1+7} == {col2,...} failed [6 != 7]</font><a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p><b><a name="BOOST_IS_DEFINED">BOOST_IS_DEFINED</a>( symbol ) </b>- to be used to
|
||||
check whether or not the supplied symbol is defined.</p>
|
||||
<p> Example: test.cpp </p>
|
||||
<p> <i>int</i> test_main( <i> int</i>, <i>char</i>* [] )<br>
|
||||
{<br>
|
||||
BOOST_CHECK(
|
||||
BOOST_IS_DEFINED(SYMBOL1) );<br>
|
||||
BOOST_CHECK(
|
||||
BOOST_IS_DEFINED(SYMBOL2(arg)) );<br>
|
||||
<i>return</i> 0;<br>
|
||||
}</p>
|
||||
<p> Output:<br>
|
||||
<font face="Arial">
|
||||
test.cpp(3) : error in test_main:
|
||||
test </font>BOOST_IS_DEFINED(SYMBOL1) failed <font face="Arial"><br>
|
||||
test.cpp(4) : error in test_main:
|
||||
test </font>BOOST_IS_DEFINED(SYMBOL2(arg)) failed<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
|
||||
<h2>Examples and Test Programs</h2>
|
||||
<blockquote>
|
||||
<pre><a href="../example/test_exec_example.cpp">test_exec_example.cpp</a>
|
||||
<a href="../test/test_exec_fail2.cpp">test_exec_fail2.cpp</a>
|
||||
<a href="../test/test_exec_fail3.cpp">test_exec_fail3.cpp</a>
|
||||
<p>Example: test.cpp</p>
|
||||
|
||||
<pre class="code"><span class="reserv-word">class</span> my_exception{};
|
||||
<span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
<span class="cpp-type">int</span> i = <span class="literal"> 0</span>;
|
||||
BOOST_CHECK_THROW( i++, my_exception );
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}</pre>
|
||||
<p>Output:</p>
|
||||
<p class="test-output">test.cpp(4) : error in test_main: exception my_exception expected
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<p><b><a name="BOOST_CHECK_EQUAL_COLLECTIONS">BOOST_CHECK_EQUAL</a>_COLLECTIONS( left_begin, left_end, right_begin )</b>
|
||||
- to be used to perform an element comparison of two collections
|
||||
</p>
|
||||
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
<span class="cpp-type">int</span> col1 [] = { <span class="literal">1</span>, <span class="literal">2</span>, <span class="literal">3</span>, <span class="literal">4</span>, <span class="literal">5</span>, <span class="literal">6</span>, <span class="literal">7</span> };
|
||||
<span class="cpp-type">int</span> col2 [] = { <span class="literal">1</span>, <span class="literal">2</span>, <span class="literal">4</span>, <span class="literal">4</span>, <span class="literal">5</span>, <span class="literal">7</span>, <span class="literal">7</span> };
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS( col1, col1+<span class="literal">7</span>, col2);
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}</pre>
|
||||
|
||||
<p>Output:</p>
|
||||
<p class="test-output">test.cpp(4) : error in test_main: test {col1, col1+7} == {col2,...} failed [3 != 4]<br>
|
||||
test.cpp(4) : error in test_main: test {col1, col1+7} == {col2,...} failed [6 != 7]
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<p><b><a name="BOOST_IS_DEFINED">BOOST_IS_DEFINED</a>( symbol )</b> - to be used to check whether or not the supplied symbol is defined.</p>
|
||||
|
||||
<p>Example: test.cpp</p>
|
||||
<pre class="code"><span class="cpp-type">int</span> test_main( <span class="cpp-type">int</span>, <span class="cpp-type">char</span>* [] ) {
|
||||
BOOST_CHECK( BOOST_IS_DEFINED(SYMBOL1) );
|
||||
BOOST_CHECK( BOOST_IS_DEFINED(SYMBOL2(arg)) );
|
||||
|
||||
<span class="reserv-word">return</span> <span class="literal">0</span>;
|
||||
}</pre>
|
||||
<p>Output:</p>
|
||||
<p class="test-output">test.cpp(2) : error in test_main: test BOOST_IS_DEFINED(SYMBOL1) failed<br>
|
||||
test.cpp(3) : error in test_main: test BOOST_IS_DEFINED(SYMBOL2(arg)) failed
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
|
||||
<h2><a name="Examples">Examples and Test Programs</a></h2>
|
||||
<p class="indented"><a href="../example/test_exec_example.cpp">test_exec_example.cpp</a><br>
|
||||
<a href="../test/test_exec_fail2.cpp">test_exec_fail2.cpp</a><br>
|
||||
<a href="../test/test_exec_fail3.cpp">test_exec_fail3.cpp</a><br>
|
||||
<a href="../test/test_tools_test.cpp">test_tools_test.cpp</a>
|
||||
</pre>
|
||||
</blockquote>
|
||||
</p>
|
||||
|
||||
<h2><a name="Design">Design</a></h2>
|
||||
<p>The <a href="test_lib_design.htm">Boost Test Library Design</a>
|
||||
document describes the relationship between Boost Test Library components.<a href="#TOP"><img border="0" src="uarrow.gif" align="right" width="19" height="20"></a></p>
|
||||
<p class="1-line-indented">The <a href="test_lib_design.htm">Boost Test Library Design</a>
|
||||
document describes the relationship between Boost Test Library components.
|
||||
<script language="Javascript">put_ref_to_top()</script>
|
||||
</p>
|
||||
<hr>
|
||||
<p>© <a href="mailto:boost_test_library@consultant.com">Gennadiy Rozental</a> 2001</p>
|
||||
<p>©
|
||||
<script language="Javascript">contact_addess()</script>
|
||||
<script language="Javascript">get_copyright_date()</script>
|
||||
</p>
|
||||
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED"
|
||||
S-Format="%d %b %Y" startspan -->24 Dec 2001<!--webbot bot="Timestamp" endspan i-checksum="14398" -->
|
||||
S-Format="%d %b %Y" startspan -->09 Aug 2002<!--webbot bot="Timestamp" i-CheckSum="14770" endspan -->
|
||||
</p>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</center>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
BIN
doc/uarrow.gif
Before Width: | Height: | Size: 160 B |